[lua]
local x = 0
function Toggle ( ply )
if x == 0 then x = 1
ply:PrintMessage ( HUD_PRINTTALK, "1" )
else x = 0
ply:PrintMessage ( HUD_PRINTTALK, "0" )
end
end
concommand.Add ( "x", Toggle )
[/lua]
When entering the console command "x", x would be set to 1 if its 0, or 0 if its 1, however it does this for all players, I want it so player 1 can type x, without x being set to 1 for player 2, how would I do this?
[lua]
function Toggle ( ply, cmd, args )
if ply.x == 0 then ply.x = 1
ply:PrintMessage ( HUD_PRINTTALK, "1" )
else ply.x = 0
ply:PrintMessage ( HUD_PRINTTALK, "0" )
end
end
concommand.Add ( "x", Toggle )
[/lua]
[editline]2nd December 2010[/editline]
You need to store it in the player's table.
You'll need to do ply.x = 0 on the initial spawn.
[QUOTE=horseboy;26446219][lua]
function Toggle ( ply, cmd, args )
if ply.x == 0 then ply.x = 1
ply:PrintMessage ( HUD_PRINTTALK, "1" )
else ply.x = 0
ply:PrintMessage ( HUD_PRINTTALK, "0" )
end
end
concommand.Add ( "x", Toggle )
[/lua]
[editline]2nd December 2010[/editline]
You need to store it in the player's table.
You'll need to do ply.x = 0 on the initial spawn.[/QUOTE]
Thanks.
Sorry, you need to Log In to post a reply to this thread.