[lua]
function Burn()
if Burnthem:GetBool() then -- ConCommand toggle
if LocalPlayer():WaterLevel() >= 1 then //NIL VALUE?????????????????????????
LocalPlayer():Ignite(10,0)
end
end
end
hook.Add( "Think", "walkOnWater", Burn )
Burnthem = CreateConVar( "Burnplayers", 0 )
[/lua]
attempt to call global 'LocalPlayer' (a nil value)
How do I fix this? It only works with for k,v in pairs do (player.GetAll()) do
blablabla
I want it for just yourself and not everyone on the server. Any ideas?
LocalPlayer() doesn't exist on server.
Try this
[lua]
Burnthem = CreateConVar( "Burnplayers", 0 )
function Burn(ply)
if Burnthem:GetBool() then -- ConCommand toggle
if ply:WaterLevel() >= 1 then //NIL VALUE?????????????????????????
ply:Ignite(10,0)
end
end
end
hook.Add( "Think", "walkOnWater", Burn )
[/lua]
You can call it on the think hook, but you will need to loop through all of the players.
Hummm, i think that you need to get the players name, i cant remember of the top of my head what the code is but heres what i think it is u gotta do
player=GetPlayerName()
and then replace all local player's with player
[lua]
Burnthem = CreateConVar( "Burnplayers", 0 )
function Burn()
if Burnthem:GetBool() then -- ConCommand toggle
for k,ply in pairs(player.GetAll()) do
if ply:WaterLevel() >= 1 then
ply:Ignite(10,0)
end
end
end
end
hook.Add( "Think", "walkOnWater", Burn )
[/lua]
[QUOTE=Freze;35002703]LocalPlayer() doesn't exist on server.
Try this
[lua]
Burnthem = CreateConVar( "Burnplayers", 0 )
function Burn(ply)
if Burnthem:GetBool() then -- ConCommand toggle
if ply:WaterLevel() >= 1 then //NIL VALUE?????????????????????????
ply:Ignite(10,0)
end
end
end
hook.Add( "Think", "walkOnWater", Burn )
[/lua][/QUOTE]
whoop fuck me think doesnt supply ply im stupid
run a for k, v in pairs(player.GetAll()) do
..
end
loop instead
Thanks to all that tried but all your answers were pretty much the exact same thing I had. So it is impossible to do what I am attempting? Or Is my mind set in a different way? The way I think about it is if its for k,v in pairs, if one player touches it I keep thinking all of them will set on fire instead of just the one, is that true?
I understand it now.
You don't want to use a think hook for something like that, try this..
[lua]
local Burnthem = CreateConVar( "Burnplayers", 0 )
timer.Create("WalkOnWater", 2, 0, function()
for _, ply in pairs(player.GetAll()) do
ply.lastIgnited = ply.lastIgnited or 0;
if Burnthem:GetBool() == true then
if ply:WaterLevel() >= 1 && ((CurTime() - ply.lastIgnited) >= 8) then
ply:Ignite(10,0)
ply.lastIgnited = CurTime();
end
end
end
end)
[/lua]
[QUOTE=zzaacckk;35015449]You don't want to use a think hook for something like that, try this..
[lua]
local Burnthem = CreateConVar( "Burnplayers", 0 )
timer.Create("WalkOnWater", 2, 0, function()
for _, ply in pairs(player.GetAll()) do
ply.lastIgnited = ply.lastIgnited or 0;
if Burnthem:GetBool() == true then
if ply:WaterLevel() >= 1 && ((CurTime() - ply.lastIgnited) >= 8) then
ply:Ignite(10,0)
ply.lastIgnited = CurTime();
end
end
end
end)
[/lua][/QUOTE]
If anything, not 2 seconds..
Maybe like .2 or something?
His code should work.
Every 2 seconds it ignites players that have not been ignited within the last 8 seconds of the timer being called.
Sorry, you need to Log In to post a reply to this thread.