Jump to content

Timer Question


Yunix

Recommended Posts

Could somebody explain me how to make unique timers?

Like, i want to create a timer but only for that person that goes trough the function, so if multiple people go trough that function and also are going to get that timer i can kill the timers separately. So when the timer is assigned to a variable i don't want to kill all the timers but only the one that i need to kill.

Link to comment

This should answer your question:

  
local PunishLevels = { 
  
function(player) 
--[[ Level 1 Punish (Just Warn) ]] 
outputChatBox("You have been warned for spamming, Please dont spam!", player, 255,255,255) 
end, 
  
function(player) 
--[[ Level 2 Punish (Second Warning) ]] 
outputChatBox("You have been warned for spamming again, Please dont spam!", player, 255,255,255) 
end, 
  
function(player) 
--[[ Level 3 Punish (Third Warning) ]] 
outputChatBox("You have been warned for spamming for the third time!, Please dont spam!", player, 255,255,255) 
end, 
  
function(player) 
--[[ Level 4 Punish (Mute Short time) ]] 
MutePlayer(player,600, "AntiSpam", "4th Level Punish") 
end 
} 
  
  

Then just calling the function with the assigned player in my case:

  
PunishLevels[PunishLevel](player) 
  
--EG: 
PunishLevels[2](player) 
  

Link to comment

Yes, every player can have his own table with his own datas of any kind.

local data = {} 
  
addEventHandler ( "onPlayerJoin", root, 
    function () 
        data [ source ] = {} 
    end ) 
  
function setThings ( player ) 
    data[ player ].vehicle = createVehicle ( ... ) 
    data[ player ].timer1 = setTimer ( ... ) 
    data[ player ].timer2 = setTimer ( ...) 
    data[ player ].likes = "Trains" 
 end 
  
addEventHandler ( "onPlayerQuit", root, 
    function () 
        data [ source ] = nil -- don't forget to clear a player's data after quitting to save memory and even kill his timers if needed 
    end )  

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...