DarkRP Module help - Executing GM:PlayerSpawn breaks everything about player spawning.

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.


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

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

hook.Add. 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.

Where are you finding this? I’ve checked (some of) the documentation, but it seems very scrambled.

Here it is in the documentation. Scroll down to the last section (More Advanced Fields).

Beautiful. Thank you so much!