DarkRP Module help - Executing GM:PlayerSpawn breaks everything about player spawning.
4 replies, posted
I'm trying to write a simple DarkRP module that gives CP classes 100 armor when they spawn. I whipped up a script in about 2 minutes, but it appears to break everything.
[CODE]function GM:PlayerSpawn( ply )
job = ply:getDarkRPVar("job")
if job == "Civil Protection" or job == "Civil Protection Chief" or job == "Mayor" then
ply:SetArmor( 100 )
end
end[/CODE]
This code works (CP classes spawn with 100 armor), but it breaks everything else. When players first spawn in after joining the server, they have no items. I have black screen on death enabled, and that doesn't go away after the player respawns. I'm going to assume I'm doing a whole lot wrong with this script. How do I fix this?
Since it's a module, use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/hook/Add]hook.Add[/url]. You should really only be overwriting GM:* functions when you are making a gamemode.
Actually, as I look through the DarkRP code, I see you can just add a custom PlayerSpawn function for each job. This is probably the cleaner way to do this.
[QUOTE=AK to Spray;49318531]Actually, as I look through the DarkRP code, I see you can just add a custom PlayerSpawn function for each job. This is probably the cleaner way to do this.[/QUOTE]
Where are you finding this? I've checked (some of) the documentation, but it seems very scrambled.
[QUOTE=RalphORama;49318608]Where are you finding this? I've checked (some of) the documentation, but it seems very scrambled.[/QUOTE]
[URL="http://wiki.darkrp.com/index.php/DarkRP:CustomJobFields"]Here it is in the documentation.[/URL] Scroll down to the last section (More Advanced Fields).
[QUOTE=AK to Spray;49318632][URL="http://wiki.darkrp.com/index.php/DarkRP:CustomJobFields"]Here it is in the documentation.[/URL] Scroll down to the last section (More Advanced Fields).[/QUOTE]
Beautiful. Thank you so much!
Sorry, you need to Log In to post a reply to this thread.