Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- isZero = false
- function checkTime () -- проверяет каждую минуту реальное время
- local time = getRealTime()
- local minutes = time.minute
- if minutes == 0 then
- isZero = true
- else
- isZero = false
- end
- end
- setTimer(checkTime, 1000,0)
- addEventHandler ( "onResourceStart", getResourceRootElement(), checkTime )
- function onlinePlayers(T)
- local count = 0
- for _ in pairs(T) do count = count + 1 end
- return count
- end
- function SetDogtagsTimer() -- таймер на выдачу жетонов
- if onlinePlayers(getElementsByType ("player")) > 15 then ammount = 2 else ammount = 1 end
- if isZero then -- если 00 минут
- for _,thePlayer in ipairs (getElementsByType ( "player" )) do
- if not isGuestAccount( getPlayerAccount( thePlayer ) ) then
- if getElementData(thePlayer, "onlineSpent") > 50 then
- setElementData(thePlayer , "Жетон", (getElementData(thePlayer, "Жетон") or 0) + ammount )
- setElementData(thePlayer , "onlineSpent", 0)
- setAccountData(getPlayerAccount(thePlayer), "onlineSpent", 0)
- end
- end
- end
- else
- for _,thePlayer in ipairs(getElementsByType ( "player" )) do
- if not isGuestAccount( getPlayerAccount( thePlayer )) then
- setElementData(thePlayer , "onlineSpent", getElementData( thePlayer, "onlineSpent") + 1)
- end
- end
- end
- end
- setTimer(SetDogtagsTimer, 60 * 1000,0)
- addEventHandler ( "onResourceStart", getResourceRootElement(), SetDogtagsTimer)
- function setOnlineTimeOnLogin() -- присвоить количетсво минут онлайн при логине
- local playerAccount = getPlayerAccount(source)
- if getAccountData(playerAccount, "onlineSpent") == false then
- setAccountData(playerAccount, "onlineSpent", 0)
- end
- setElementData(source, "onlineSpent", getAccountData(playerAccount, "onlineSpent"))
- outputChatBox( "Account:" .. tostring(getAccountData(playerAccount, "onlineSpent")))
- outputChatBox( "ElementData:" .. tostring(getElementData(source, "onlineSpent")))
- end
- addEventHandler ( "onPlayerLogin", getRootElement(), setOnlineTimeOnLogin )
- function setOnlineTimeOnLogout() -- присвоить количетсво минут онлайн при выходе игрока
- local playerAccount = getPlayerAccount(source)
- if getAccountData(playerAccount, "onlineSpent") == false then
- setAccountData(playerAccount, "onlineSpent", 0)
- end
- setAccountData(playerAccount, "onlineSpent", getElementData(source, "onlineSpent"))
- outputChatBox( "Account:" .. tostring(getAccountData(playerAccount, "onlineSpent")))
- outputChatBox( "ElementData:" .. tostring(getElementData(source, "onlineSpent")))
- end
- addEventHandler ( "onPlayerQuit", getRootElement(), setOnlineTimeOnLogout )
- addEventHandler ( "onPlayerLogout", getRootElement(), setOnlineTimeOnLogout )
- function setOnlineTimeOnResourceStart() -- задать elementdata всем игрокам при старте ресурса
- for _,thePlayer in ipairs(getElementsByType ( "player" )) do
- if not isGuestAccount( getPlayerAccount( thePlayer ) ) then
- if getAccountData(getPlayerAccount(thePlayer), "onlineSpent") == false then
- setAccountData(getPlayerAccount(thePlayer), "onlineSpent", 0)
- end
- setElementData(thePlayer, "onlineSpent", getAccountData(getPlayerAccount(thePlayer), "onlineSpent"))
- end
- end
- end
- addEventHandler ( "onResourceStart", getResourceRootElement(), setOnlineTimeOnResourceStart)
- function setOnlineTimeOnResourceStop() -- задать elementdata всем игрокам при остановке ресурса
- for _,thePlayer in ipairs(getElementsByType ( "player" )) do
- if not isGuestAccount( getPlayerAccount( thePlayer ) ) then
- setAccountData(getPlayerAccount(thePlayer), "onlineSpent", getElementData(thePlayer, "onlineSpent"))
- end
- end
- end
- addEventHandler ( "onResourceStop", getResourceRootElement(), setOnlineTimeOnResourceStop )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement