• How do I make this code for props getting cleared when no players are on
    4 replies, posted
Hey, I'm making an addon but I'm having trouble with this function. It has no errors but it doesn't work. function clearprops()     if player.GetAll() == nil then         RunConsoleCommand( "ulx", "cleanup" )         print("Cleaning up props because no players are on.")     end end
Thanks for the fast reply!
hook.Add("PlayerDisconnected","clear props when empty",function(ply)--called when a player leaves the game timer.Simple(0.1,function()--make sure the player has disappeared before we execute our function if player.GetCount()==0 then--player.GetCount returns how many player entities there are, it equals 0 if the server is empty game.CleanUpMap()--ulx cleanup uses this function internally print("Cleaning up props because no players are on.") end end) end)
Thanks, I was using ulx command instead of game.CleanUpMap()
Sorry, you need to Log In to post a reply to this thread.