Help, I'm unarmed!

I’m currently working on a game mode and for some reason my GM:PlayerLoadout is not being called and I get no errors. and the GM:OnNPCKilled works and it’s in the same file. I have read and looked, and I just don’t see what the problem is.

function GM:PlayerLoadout( ply )

print("Player Loadout")




ply:GiveAmmo(3, "SMG1_Grenade",true)







Thanks for any help.

If you overwrite GM:PlayerSpawn then you need to call self:PlayerLoadout yourself

In your PlayerSpawn function make sure to call self.BaseClass.PlayerSpawn(self, ply).

Ok, well that makes sense, I was just messing with some stuff and found GM:PlayerSpawn is being called so I was just gonna give weapons in there, but now that i know I can fix it thanks.

Don’t just call PlayerLoadout in PlayerSpawn, this will prevent the loadout hooks from running, do what I posted earlier and PlayerLoadout and PlayerSetModel gamemode function and hooks will run correctly.

[editline]17th January 2011[/editline]

If you don’t want to call the base PlayerSpawn (I can’t think why) then you can **[Gamemode.Call](** PlayerLoadout yourself in your PlayerSpawn function.

Yea, i wasn’t planning on just calling it, I was gonna call the base of playerspawn like you suggested, just didn’t say it, anyway thank you for the information.

I like that the noobs (i’m actually an 05) says disagree when my post is 100% valid and correct.

You CAN call the base if you want, but if you’re making a custom gamemode you don’t need to use garry’s worthless base.

Also the way you called the base is dumb, should be self.BaseClass:PlayerSpawn(ply), metatables exist for a reason.

This has nothing to do with metatables (method calling with : can be used for normal table functions).
Calling it like that will pass self.BaseClass as the first argument to PlayerSpawn, which may work as intended in this case, but when any variables are set on the table, they will be set on the BaseClass gamemode table, not the current gamemode. Calling it the way that I posted will pass the current gamemode (self) not the base gamemode (self.BaseClass) as the first argument.

Your original post may have worked, but it would have fucked up any PlayerLoadout and PlayerSetModel hooks, preventing them from running.

Also, I am not a noob.

[editline]17th January 2011[/editline]

Since when did join date have anything to do with experience in Lua?

Couldn’t you just do GAMEMODE.PlayerLoadout(ply) ?

We have already discussed why you shouldn’t just call the PlayerLoadout function directly.

Thank you for your input, however, I do not think Garry’s code is worthless, it functions so it has worth, and calling the base class function is the proper way to do it, in any language, I just didn’t realize I needed to pass the call on myself.

Anyway thanks to everybody for your help and opinions.