Okay so I was trying to follow along with the
Hook Tutorial from the GMod Wiki unfortunately it was never 100% finished.
So I created a tweaked version to display death info in my DarkRP server.
// Hook Testing Msg("Loading Custom Scripts Test. ") if SERVER then AddCSLuaFile ("CustomScripts.lua") end include("CustomScripts.lua") local deathHookTest = function(victim, inflictor, killer) if killer:IsPlayer(true)then -- Only prints if the killer is a player. Msg( killer:Nick() .. " killed " ..victim:Nick() .. " " ) end if killer:IsPlayer(false)then -- Only prints if the killer is a prop. Msg( killer:Nick() .. " killed " ..victim:Nick().. " with " .. inflictor:GetOwner() .. "'s prop! ") end end hook.Add( "PlyerDeath", "Displays Player Deaths", deathHookTest )
1. Now here is where my questions come in. I added the “if SERVER” and “include” bits based off of looking at other things, but because the bits I used were all listed as “shared”, how needed is this and how should it properly be used in this context?
2. I added include(“CustomScripts.lua”) to my cl_init.lua and AddCSLuaFile(“CustomScripts.lua”) to the init.lua. From what I’ve gathered, include is for client an addcsluafile is for server, is this correct, and was it needed in this case?
3. What would be a better way to launch the script other than how I have done by connecting it to DarkRP files?
4. This is an error, it will spam “Loading Custom Scripts Test.” and then hault with the error “[darkrp\gamemode\CustomScripts.lua:15] chunk has too many syntax levels”. Line 15 is "Msg( killer:Nick() … " killed " … victim:Nick() … " with " … inflictor:GetOwner() … "'s prop!
Needless to say, it doesn’t work.
So, anyone care to help me on any of these aspects? I tried a few tweaks but still get some level of no effect or error.