• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Action Stop-watch

slaw

Software Developer
Joined
Aug 27, 2007
Messages
3,665
Solutions
125
Reaction score
1,111
Location
Germany
GitHub
slawkens
Screen (It won't show how it exactly work.. so better check it yourself ;p)
stopwatch.PNG


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"/>
 
Awsome script! it would be useful for.... ehm... RAces! and... ehh... what ever! but seriously, nice script, and very creative (i would never think of that :p)
 
stop-watch = a watch which counts down ^.-

Yup but it could be to much complicated to do in tibia ;p (new talkaction to set time or what?)
And you can name it whatever you want, its just reverted stop-watch xd
 
I think to make a nice stop-watch we'd need:
- onAcceptWrite(cid, item, newText)

Then we make so when click on watch it come up text and u write time and click enter and it counts down xD

Would be most realistic I assume ^.-
 
It's not working for me on TFS 0.3.4
Errors on line: 17 and 31
It's strange because it's showing that it can't find "Getplayerpos" function, but i have that function in my lib.
 
Back
Top