Issues with initial spawning


if(ply:IsAlive()) then


I’m having issues that when the player first spawns they aren’t given their weapons, so I tried this timer to fix it, any ideas?

Copied from the Gmod Wiki, you have to select what teams…

if ply:Team() == 1 then //If he is team 1, then give him the following items

	ply:Give( "weapon_physcannon" ) // A Gravity gun
	ply:Give( "weapon_physgun" ) // A Physics gun
	ply:Give( "gmod_tool" ) // and don't forget the tool gun!

elseif ply:Team() == 2 then // So if he isn't team 1, he could be team 2?

	ply:Give( "weapon_physcannon" ) //Assuming he is, then give him Gravity gun
	ply:Give( "weapon_physgun" ) // Physics gun
	ply:Give( "weapon_ar2" ) // AR2 
	ply:Give( "gmod_tool" ) // and the gmod tool


You are missing an ‘end’ to close your if condition.

Also, this might be what you are looking for: **[Gamemode.PlayerLoadout](**

If you are already using that, post your code and any errors.

I tried using that, and when I did I got the normal base weapons in addition to my SWEPs can someone please explain?

[lua]function GM:PlayerInitialSpawn( ply )

ply:StripWeapons() --Strip all weapons, so they start with nothing

timer.Create( "Weapons", 20, 0, function() --After twenty second, our timer "weapons" activates, acting out the following code
								ply:Give("weapon_crowbar") --Give 'em a crowbar
								ply:Give("weapon_key") --Give 'em a key
								timer.Destroy("Weapons") --Don't need to check if the player is alive to do this, because it'll be called when they spawn
								end) --Stop timer

end --End function[/lua]

Try that, fully commented so you understand it.

Seeing as i’ve had bad luck with giving weapons in Gamemode.PlayerLoadout [img_thumb][/img_thumb]

Thanks, I’ll try that. With any luck, no spawning with SMGs, so hopefully killing won’t be as bad. But can I ask you, when this is called, for PlayerInitialSpawn, is it called when the player is in the server and has spawned, etc?

**[Gamemode.PlayerInitialSpawn](** is called when the player first joins the server and spawns for the first time.

**[Gamemode.PlayerSpawn](** is called everyime the player spawns / respawns after he/she has died.

Er, I meant PlayerLoadout, is it called everytime the player spawns, including the first time? Because if so, and its done when the player is fully in the server, the timer shouldn’t be necessary should it?

Oh, i’m not quite sure how PlayerLoadout works, but i’m pretty sure it works on the same basis as PlayerSpawn, as in, it’s called everytime the player spawns. But I may be wrong and PlayerLoadout could be a template of default weapons they spawn with. As in they spawn with the weapons defined in PlayerLoadout all the time, any extra weapons are just added into a temporary loadout during that life.

If that makes sense of course, sorry, but there’s no easier way of explaining it, but overall, im not sure how PlayerLoadout works, but it has to be one of the above.

Also, would this work? ;

function GM:PlayerLoadout(ply)

	if(ply:Team()==1) then


Because I think my problem is I didn’t return false or something which caused it to give Base’s default weapons.

[lua]function GM:PlayerLoadout(ply)


if(ply:Team()==1) then

return true;


Don’t return false, return true to stop the default weapons from loading.

Still not working, any ideas?

Care to tell us the issue, other then “it nawt workeh”?

The issue is that on the first spawn, players spawn with nothing, but on the second spawn things work fine.


Timers arent’ working for some reason.