• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

How to make an action that breaks other action.

Status
Not open for further replies.

Hermes

dziwki kola gramy w lola
Joined
Nov 17, 2007
Messages
1,867
Reaction score
14
Location
Poland
Hi there.

I am wondering how to make as in title, something that will break other script.

So.

I am making /afk command. If you write /afk then "Zzz.." effect comes on your character. I am using addEvents for this. How to break addEvent when player will move?

Also, is there any way to get player idle time? It's also nice idea to launch this effect when player's idle for 5+ minutes :D

Thanks in advance,
Hermes.
 
Last edited:
Well have a onthink event on the creature that always checks the player direction, position and I guess a few other things depending on if you want to check them.

have 1 storage value for weather afk and 1 storage for counting the seconds between actions. then based on that seconds of actions then.
Then the other scripts can use that first storage value to determine weather it should do the action. You could even have the first onthink event triger the second event once the idle time gets long enough.

If you want me to make the code for you just ask.
 
Use a loop?

If storageID is 1, addEvent() goes for 1 second, checks again etc.

If storageID is 0, exit the loop? :)
 
Impossible, as you can't determine if player has moved.

Yes we can use onThink and check if position has changed.. but, this way is very . ugly ?

Best way could be adding new variable to Player class, e.q afkModekActivated. Than changing this function (Because resetIdleTime is executed, every time player move, attack via battle, rotate item, change outfit etc):
void resetIdleTime() {idleTime = 0;}
To:
void resetIdleTime() {idleTime = 0; afkModeActivated = false;}

Now you can create lua function to check/set afkMode. And add new onThink creature event, which will send effect, + talkaction.

Easy, right? :P
 
Well kokoko the addevent() would make it a loop but not a tight loop like calling while.But the way I was thinking is one event that look's in the background for each player setting a storage value for how long they have been idle and weather they are idle or not.Also if you need other things to be counted regular then you could add that in the monitoring event ex: pay by the hour instead of the day. Then any other function can call that storage value to tell weather the player is idle then do or dont do event. And it doesn't take a source edit and recompiling.For larger servers the source code edit would be better.
 
maybe use storage values?

like.. when player say /afk it's saving position on storages and in event looks for positions where player stay. If Player stay on position saved in storages add event to say "zZZZZz..." else break this event. easy? :D

example... ;d

PHP:
local storageX = 50001
local storageY = 50002
local storageZ = 50003
function sayZZZ(cid)
local pos=getPlayerPosition(cid)
 if(pos.x == getPlayerStorageValue(cid, storageX) and pos.y == getPlayerStorageValue(cid, storageY) and pos.z == getPlayerStorageValue(cid, storageZ))then
 doPlayerSay(cid, "ZzZzzz...", 16)
 addEvent(sayZZZ, 1000, cid)
 end
end

function onSay(cid, words, param)
local pos=getPlayerPosition(cid)
setPlayerStorageValue(cid, storageX, pos.x)
setPlayerStorageValue(cid, storageY, pos.y)
setPlayerStorageValue(cid, storageZ, pos.z)
addEvent(sayZZZ, 1000, cid)
return TRUE
end
np,np. ;d
 
@up!

I think that the function "getPlayerPosition(cid)" was changed to "getCreaturePosition(cid)", or the two can be used?

The same thing with doPlayerSay(cid) = doCreatureSay(cid)
 
Status
Not open for further replies.
Back
Top