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

Lua Player save information and addEvent (stopEvent)

viniciusturko

New Member
Joined
Jun 23, 2009
Messages
94
Reaction score
2
Location
Brasil
Hello,

I'm creating an action that the player just can use the item 1 time between 10 minutes. I'm using Addevent, something like this :

Code:
Function onUse(...)
        if getPlayerStorageValue(cid,2222) == -1 then
                 setPlayerStorageValue(cid, 2222, 1)
                 addEvent(function()
                       setPlayerStorageValue(cid, 2222, -1)
                 end, 10 * 60 * 1000)     
        else
                 doPlayerSendTextMessage(cid, 22, "You cannot use the item again")
        end

It is working very well, but just if the player stay onLine :(. If the player log out and after log in again, he can use the item again :(.

How can I do it to this time stay saved in the Player GUID?

My second doubt I think is easyer than the first x_x.
In this same script, I'm using so many addEvents. But I'm using them like a function, and in the end of the script, I want to use "stopEvent", but it is not working =/...

Here is an example of my doubt :

Code:
function kickall(clean, save)
       do....
       do....
end

function onUse(...)
      addEvent(kickall, 5000)
      do....
      do....
      do....
      stopEvent(kickall)
end

I'm using the Add and Stop event same in this example script, but the event is not stoping, it is continueing and it just stop when I clase the server or log out.

Some one can help me?
 
Last edited:
Code:
	if os.time() - getCreatureStorage(cid, 2222) >= 600 then
		doCreatureSetStorage(cid, 2222, os.time())
	else
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'You cannot use the item again')
	end
 
Back
Top