[lua]
timer.Create(ply:Nick(),20,0,function()
ply:Give("weapon_crowbar")
ply:Give("weapon_key")
if(ply:IsAlive()) then
timer.Destroy(ply:Nick())
end
end)
[/lua]
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..
[lua]
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
[/lua]
You are missing an 'end' to close your if condition.
Also, this might be what you are looking for: [b][url=wiki.garrysmod.com/?title=Gamemode.PlayerLoadout]Gamemode.PlayerLoadout [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
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 [b][url=wiki.garrysmod.com/?title=Gamemode.PlayerLoadout]Gamemode.PlayerLoadout [img_thumb]http://wiki.garrysmod.com/favicon.ico[/img_thumb][/url][/b]
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?
[QUOTE=TheNerdPest14;25700883]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?[/QUOTE]
[b][url=wiki.garrysmod.com/?title=Gamemode.PlayerInitialSpawn]Gamemode.PlayerInitialSpawn [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] is called when the player first joins the server and spawns for the first time.
[b][url=wiki.garrysmod.com/?title=Gamemode.PlayerSpawn]Gamemode.PlayerSpawn [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] 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?
[QUOTE=TheNerdPest14;25700956]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?[/QUOTE]
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.
[QUOTE=LuckyLuke;25700930][b][url=wiki.garrysmod.com/?title=Gamemode.PlayerInitialSpawn]Gamemode.PlayerInitialSpawn [img_thumb]http://wiki.garrysmod.com/favicon.ico[/img_thumb][/url][/b] is called when the player first joins the server and spawns for the first time.
[b][url=wiki.garrysmod.com/?title=Gamemode.PlayerSpawn]Gamemode.PlayerSpawn [img_thumb]http://wiki.garrysmod.com/favicon.ico[/img_thumb][/url][/b] is called everyime the player spawns / respawns after he/she has died.[/QUOTE]
Also, would this work? ;
[code]
function GM:PlayerLoadout(ply)
ply:StripWeapons()
ply:Give("weapon_crowbar")
ply:Give("weapon_key")
if(ply:Team()==1) then
ply:Give("weapon_handcuffs")
ply:Give("weapon_sim_endfield")
end
end
[/code]
Because I think my problem is I didn't return false or something which caused it to give Base's default weapons.
Still not working, any ideas?
Care to tell us the issue, other then "it nawt workeh"?
[QUOTE=Banana Lord.;25728400]Care to tell us the issue, other then "it nawt workeh"?[/QUOTE]
The issue is that on the first spawn, players spawn with nothing, but on the second spawn things work fine.
[QUOTE=LuckyLuke;25699887][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 [b][url=wiki.garrysmod.com/?title=Gamemode.PlayerLoadout]Gamemode.PlayerLoadout [img_thumb]http://wiki.garrysmod.com/favicon.ico[/img_thumb][/url][/b][/QUOTE]
[b][url=http://wiki.garrysmod.com/?title=Timer.Simple]Timer.Simple [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
Timers arent' working for some reason.
Sorry, you need to Log In to post a reply to this thread.