I'm trying to make a script where if someone spawns, they automatically freeze. I know for freezing players is player:Lock(), but I don't know how to make a command execute when spawning. (Sorry I'm such a noob.)
Hook to PlayerSpawn using code found ^
Also I think you should use Freeze()
Yeah, I just realized Player.Freeze() would be a bit easier.
[QUOTE=bmeeker625;46234304]Yeah, I just realized Player.Freeze() would be a bit easier.[/QUOTE]
To simplify:
[lua]
function GM:PlayerSpawn( ply )
ply:Freeze( true )
end
[/lua]
[QUOTE=SwikCoder;46235159]To simplify:
[lua]
function GM:PlayerSpawn( ply )
ply:Freeze( true )
end
[/lua][/QUOTE]
Use hooks instead of Gamemode functions.
Why does GM13 code have to be different from GM12?
[QUOTE=Exho;46235203]Use hooks instead of Gamemode functions.[/QUOTE]
Figured he was making a gm
Coincidentally I set this up a week ago.
[lua]timer.Create("FreezeTime", 0.5, 0, function()
for _,v in pairs(player.GetAll()) do
v:Freeze(true)
end
end)
timer.Simple(60, function()
timer.Stop("FreezeTime")
for _,v in pairs(player.GetAll()) do
v:Freeze(false)
v:Spawn()
end
timer.Start("RoundTimer")
print("round start")
end)[/lua]
[editline]a[/editline]
If you're going to use hooks, use something like this instead:
[lua]hook.Add("PlayerSpawn", "FreezeTime", function()
for _,v in pairs(player.GetAll()) do
v:Freeze(true)
end
end)
timer.Simple(60, function()
timer.Stop("FreezeTime")
for _,v in pairs(player.GetAll()) do
v:Freeze(false)
v:Spawn()
end
timer.Start("RoundTimer")
print("round start")
end)[/lua]
I've already gotten what I've wanted, this is the final result.
[code]
function GM:PlayerSpawn(ply)
if not ply:IsSuperAdmin() then
ply:Lock()
print("Frozen while in menu.")
end
end
[/code]
Sorry, you need to Log In to post a reply to this thread.