ply:GetPos():Distance Trouble

Objective : Make StopTime( ply ) and StartTime( ply ) functions trigger whenever you get within 500 units of the positions you make with Startpos and Endpos functions()

Error : No log errors, it just silently does not work.

CODE:


function StartPos( ply )
	if ply:IsAdmin() then
		file.Write( "bunnyhop/timepos/"..game.GetMap().."start.txt", tostring(ply:GetPos()) )
		print( file.Read( "bunnyhop/timepos/"..game.GetMap().."start.txt" ) )
	end
end
concommand.Add( "startpos", StartPos )

function EndPos( ply )
	if ply:IsAdmin() then
		file.Write( "bunnyhop/timepos/"..game.GetMap().."end.txt", tostring(ply:GetPos()) )
		print( file.Read( "bunnyhop/timepos/"..game.GetMap().."end.txt" ) )
	end
end
concommand.Add( "endpos", EndPos )



Startpos1 = file.Read( "bunnyhop/timepos/"..game.GetMap().."start.txt" )
Spos = string.Explode( " ", StartPos )
Xstart = Spos[1]
Ystart = Spos[2]
Zstart = Spos[3]

Endpos1 = file.Read( "bunnyhop/timepos/"..game.GetMap().."end.txt" )
Epos = string.Explode( " ", EndPos )
Xend = Spos[1]
Yend = Spos[2]
Zend = Spos[3]

function StartDist( ply )

if ply:GetPos():Distance( Vector( Xstart, Ystart, Zstart ) ) < 500 then
	StartTime( ply )
end
end

function EndDist( ply )
if ply:GetPos():Distance( Vector( Xend, Yend, Zend ) ) < 500 then
	StopTime( ply )
end
end

hook.Add( "Think", "StartDist", StartDist )
hook.Add( "Think", "EndDist", EndDist )


Notes : StartTime and EndTime functions work FOR SURE, that is definantly not the problem whatsoever.

[editline]30th June 2011[/editline]

If anyone knows another forum i can go to with people that might know the answer go ahead and pm me a link.

Well, im not very sure but try putting

if ply:GetPos():Distance( Vector( Xend, Yend, Zend ) ) < 500 then ply:ConCommand(“stoptime”) end – i remember you making a concommand for that timer thing.,
and the same with the other one

[lua]
local StartVector = Vector(0,0,0)
local EndVector = Vector(0,0,0)

local startfile = string.Explode( " ",file.Read( “bunnyhop/timepos/”…game.GetMap()…“start.txt” ))
StartVector = Vector(startfile[1],startfile[2],startfile[3])
local endfile = string.Explode( " ",file.Read( “bunnyhop/timepos/”…game.GetMap()…“end.txt” ))
EndVector = Vector(endfile[1],endfile[2],endfile[3])

function StartPos( ply )
if ply:IsAdmin() then
file.Write( “bunnyhop/timepos/”…game.GetMap()…“start.txt”, tostring(ply:GetPos()) )
print( file.Read( “bunnyhop/timepos/”…game.GetMap()…“start.txt” ) )
StartVector = ply:GetPos()
end
end
concommand.Add( “startpos”, StartPos )

function EndPos( ply )
if ply:IsAdmin() then
file.Write( “bunnyhop/timepos/”…game.GetMap()…“end.txt”, tostring(ply:GetPos()) )
print( file.Read( “bunnyhop/timepos/”…game.GetMap()…“end.txt” ) )
EndVector = ply:GetPos()
end
end
concommand.Add( “endpos”, EndPos )

function CheckDist( )
for _, ply in pairs(player.GetHumans()) do
if ply:GetPos():Distance( StartVector ) < 500 then
StartTime( ply )
end
if ply:GetPos():Distance( EndVector ) < 500 then
StopTime( ply )
end
end
end
timer.Create( “CheckDist”, 1, 0, CheckDist )
[/lua]

that was for debugging

Saved my ass