slaw
Software Developer
Screen (It won't show how it exactly work.. so better check it yourself ;p)
actions/scripts/other/stopwatch.lua
actions.xml
TFS 0.2
TFS 0.3
actions/scripts/other/stopwatch.lua
Code:
local config = {
storage = 20014,
color = TEXTCOLOR_YELLOW,
limit = 600, --max seconds
checkDelay = 10 -- how often script will check if player have still stoper, IN SECONDS
-- WARNING: it may consumpt much % CPU if you'll use lower value in checkDelay, and more players will use stopwatch in one time
}
local function repeatTimer(cid, repeats)
if(isPlayer(cid) == FALSE or getPlayerStorageValue(cid, config.storage) ~= 1) then
return
end
if(repeats < config.limit and ((repeats % config.checkDelay ~= 0) or (getPlayerItemCount(cid, 6091) > 0))) then
repeats = repeats + 1
doSendAnimatedText(getPlayerPos(cid), repeats, config.color)
addEvent(repeatTimer, 1000, cid, repeats)
else
setPlayerStorageValue(cid, config.storage, 0)
end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerStorageValue(cid, config.storage) == 1 then
setPlayerStorageValue(cid, config.storage, 0)
return TRUE
end
setPlayerStorageValue(cid, config.storage, 1)
repeatTimer(cid, 0)
return TRUE
end
actions.xml
TFS 0.2
Code:
<action itemid="6091" script="other/stopwatch.lua"/>
TFS 0.3
Code:
<action itemid="6091" event="script" value="other/stopwatch.lua"/>