• 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!

Time

VirrageS

←•†ĿuĀ && ©¤¤•→
Joined
May 30, 2010
Messages
984
Reaction score
63
Location
Poland
Hello :)

I looking for script. So when you say: "!countdown, 5" then it will be something like this (it will show every 1 second):

Code:
Count: 5
Count: 4
Count: 3
Count: 2
Count: 1
(And when 0 then) Hurra!!
I have tried to make script:
Lua:
function onSay(cid, words, param)
	param = param.explode(param, ',')
	
	if (param[1] ~= nil) then
		local count = param[1]
		
		for i = 1, param[1] do
			doSendAnimatedText(getPlayerPosition(cid), 'Count: '.. param[1] - 1 ..'', 11)
			if (param[1] == 0) then
				doSendAnimatedText(getPlayerPosition(cid), 'Hurra!!', 11)
			end
		end
	else
		doPlayerSendCancel(cid, 'You must set param!')
	end
end
And it is only showing "Count: 2".

Can someone make this script?? :thumbup:
Rep and thanks for script.
 
Last edited:
try this
Lua:
local a = 0
function onSay(cid,words,param)
	if tonumber(param) then
		for i = param,0 do
			a = a+1
			addEvent(doPlayerSendTextMessage,a*1000,cid,MESSAGE_STATUS_CONSOLE_BLUE,'Count: '..i..'.')
		end
	else
		doPlayerSendCancel(cid,'Requires numberic value.')
	end
	return true
end
 
Sorry for that, fixed.

Lua:
local a,b = 0,0
function onSay(cid,words,param)
	if tonumber(param) then
	c = param
		for i = 0,tonumber(param) do
			a = a+1
			b = param+1-a
			if a-1 ~= tonumber(param) then
				addEvent(doPlayerSendTextMessage,a*1000,cid,MESSAGE_STATUS_CONSOLE_BLUE,'Count: '..b..'.')
			else
				addEvent(doPlayerSendTextMessage,a*1000,cid,MESSAGE_STATUS_CONSOLE_BLUE,'hurray!')
			end
		end
		a = 0
		b = 0
	else
		doPlayerSendCancel(cid,'Requires numberic value.')
	end
	return true
end

use like this :
Lua:
 /countdown # -- # = param = seconds.
 
Last edited:
i think he want it animated text, and i think he want it to be on player if he moves too, and what about the hurra part , and yours would count till -1

Edit : Sorry i mean it woont count according to param untill 0 (before updated)

Another Edit : Now it work fine.


:D
 
Last edited:
Yeah it is working perfectly. :thumbup:

I have question to script. Can you add to script that player will stop's counting when he move or player get damage??
 
How do you want to stop the event from the talkaction script, with the onAttack/onStatsChange script?
Check player battle sign and position every second (every event) and if it change stop event? :huh:
.. and don't forget to store 'eventID' in table {} and use:
PHP:
eventStorage[cid]
in place of:
PHP:
eventStorage
or you will stop event of last player that use !xx command :thumbup:

@author
Do you want make somethink like logout in lineage2?
 
Last edited:
@unknown

I only said onmove and on battle sign, so this wont need any thing out of talkaction , just to make the script with other way
 
@phoOwned
If you want alot of memory leaks and unecessary RAM usage, sure, that's what to do.
How can you stop event if you don't store ID in table my master pro scripter? -.-
I don't get how can it make memory leak... maximum number of IDs stored is number of players online.
 
Then why don't you make it? my master pro scripter.
because...
* I write new class to Tibiando and new client 'like tibiando', but with more advanced options (stereo sound or even 5.1 support, play few sounds in same time)
* I write 'binary save players items and depots' for TFS
* I make scripts for 4 rpg projects
:thumbup:
but if you really want ^_^
PHP:
local countdownEvent = {}

function finalCountdown(cid, countLeft, playerPos)
	if(not isPlayer(cid) or countLeft == 0) then
		table.remove(countdownEvent, cid)
		return
	end
	local tmpPos = getCreaturePosition(cid)
	if((tmpPos.x == playerPos.x) and (tmpPos.y == playerPos.y) and (tmpPos.z == tmpPos.z) and (not isPlayerPzLocked(cid))) then
		doSendAnimatedText(getCreaturePosition(cid), 'Count: '.. countLeft ..'', 11)
		local eventId = addEvent(finalCountdown, 1000, cid, countLeft - 1, playerPos)
		countdownEvent[cid] = eventId
	else
		doPlayerSendCancel(cid,'You moved or start fight. You can\'t logout.')
		table.remove(countdownEvent, cid)
	end
end

function onSay(cid,words,param)
	c = tonumber(param)
	if(c) then
		if(countdownEvent[cid] == nil) then
			local eventId = addEvent(finalCountdown, 0, cid, c, getCreaturePosition(cid))
			countdownEvent[cid] = eventId
		else
			doPlayerSendCancel(cid,'Event is running.')
		end
	else
		doPlayerSendCancel(cid,'Requires numberic value.')
	end
	return true
end
Script not tested. Based only on 0.3.6pl1 luascripts.cpp
You can modify it to make something when isPlayer(cid) A N D countLeft == 0 (like doRemoveCreature(cid) ), but don't forget to add table.remove(countdownEvent, cid) or you can block player until relog/server restart.
 
Last edited:
It is working good but with small problem. So when it count to 1 (end of event) then it return "doPlayerSendCancel(cid,'Event is running.')"
 
try using that
Lua:
local countdownEvent = 12300

function finalCountdown(cid, countLeft, playerPos)
    if(not isPlayer(cid) or countLeft == 0) then
        setPlayerStorageValue(cid, countdownEvent,-1)
        return
    end
    local tmpPos = getCreaturePosition(cid)
    if((tmpPos.x == playerPos.x) and (tmpPos.y == playerPos.y) and (tmpPos.z == tmpPos.z) and (not isPlayerPzLocked(cid))) then
        doSendAnimatedText(getCreaturePosition(cid), 'Count: '.. countLeft ..'', 11)
		addEvent(finalCountdown, 1000, cid, countLeft - 1, playerPos)
    else
        doPlayerSendCancel(cid,'You moved or start fight. You can\'t logout.')
         setPlayerStorageValue(cid, countdownEvent,-1)
    end
end

function onSay(cid,words,param)
    c = tonumber(param)
    if(c) then
        if(getPlayerStorageValue(cid,countdownEvent) ~= cid) then
            setPlayerStorageValue(cid, countdownEvent,cid)
			addEvent(finalCountdown, 0, cid, c, getCreaturePosition(cid))
        else
            doPlayerSendCancel(cid,'Event is running.')
        end
    else
        doPlayerSendCancel(cid,'Requires numberic value.')
    end
    return true
end
 
TESTED on 0.3.6pl1. Work fine!
PHP:
local countdownEvent = {}

function finalCountdown(cid, countLeft, playerPos)
	if(not isPlayer(cid) or countLeft == 0) then
		if isPlayer(cid) then -- if count = 0 and player is still online
			doPlayerSendCancel(cid,'Event finish.')
		end
		countdownEvent[cid] = 0
		return
	end
	local tmpPos = getCreaturePosition(cid)
	if((tmpPos.x == playerPos.x) and (tmpPos.y == playerPos.y) and (tmpPos.z == tmpPos.z) and (not isPlayerPzLocked(cid))) then
		doSendAnimatedText(getCreaturePosition(cid), 'Count: '.. countLeft ..'', 11)
		local eventId = addEvent(finalCountdown, 1000, cid, countLeft - 1, playerPos)
		countdownEvent[cid] = eventId
	else
		doPlayerSendCancel(cid,'You moved or start fight. You can\'t logout.')
		countdownEvent[cid] = 0
	end
end

function onSay(cid,words,param)
	c = tonumber(param)
	if(c) then
		if(countdownEvent[cid] == nil or countdownEvent[cid] == 0) then
			local eventId = addEvent(finalCountdown, 0, cid, c, getCreaturePosition(cid))
			countdownEvent[cid] = eventId
		else
			doPlayerSendCancel(cid,'Event is running.')
		end
	else
		doPlayerSendCancel(cid,'Requires numberic value.')
	end
	return true
end
and still no storage in use :thumbup:
 
Last edited:
Back
Top