Author Topic: I'm writing my own prop protection but..  (Read 3737 times)

0 Members and 1 Guest are viewing this topic.

Offline Chironex

  • Full Member
  • ***
  • Posts: 197
  • Karma: 11
  • Formerly known as Kyzer
I'm writing my own prop protection but..
« on: August 13, 2007, 07:57:00 PM »
I've a problem, the timer won't delete player props:

Code: [Select]
function UProtect_CreateTimer( ply )

local delay = 10
timer.Create("UProtect_Timer"..ply:UniqueID(), delay, 1, UProtect_RemoveEntities, ply)

end
hook.Add( "PlayerDisconnected", "UProtect_CreateTimer_Hook", UProtect_CreateTimer )


function UProtect_DestroyTimer( ply )

local utimer = "UProtect_Timer"..ply:UniqueID()
if ( timer.IsTimer(utimer) ) then
timer.Destroy(utimer)
end

end
hook.Add( "PlayerInitialSpawn", "UProtect_DestroyTimer_Hook", UProtect_DestroyTimer )



function UProtect_RemoveEntities( ply )

local count = 0
local entities = ents.GetAll()
for _, ent in pairs( entities ) do
if( ent && ent:IsValid() && !ent:IsPlayer() && UProtect_IsOwner(ply, ent) ) then
ent:Remove()
count = count + 1
end
end

if ( ulx && count > 0 ) then
local message = "Deleting " .. ply:Nick() .. "'s " .. count
if ( count < 2 ) then ulx.logString( message .. " entity." )
else ulx.logString( message .. " entities." )
end
end
UProtect_DestroyTimer( ply )

end
//hook.Add( "PlayerDisconnected", "UProtect_RemoveEntities_Hook", UProtect_RemoveEntities )

(The hook at the last line is working if i enable it)

Can someone help me, i don't understand why it don't work :/. Since i started lua coding i haven't did a working timer lol.

Edit:solved
« Last Edit: August 13, 2007, 09:44:40 PM by Kyzer »