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

Solved Stopping an addevent with a movement script?

Ahilphino

Excellent OT User
Joined
Jun 5, 2013
Messages
1,667
Solutions
1
Reaction score
727
Okay so recently I made a script that says "Danger!" over a players head every second after they used a specific item but I would also want a movement script that cancels this effect (so that it stops spamming Danger above the players head) I've tried it on my own without any success for a couple of hours now :(

The action script:
Code:
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    local time, t = 1 * 15, 0
        for x = 1, time do
        addEvent(function() player:say("Danger!", TALKTYPE_MONSTER_SAY) end, t)
        t = t + 1000
        end
    return true
end

Now I wonder how I could cancel this addevent with a movement script? I've searched around with little to no success, I would really appreciate some help with this!

I tried some stuff with globalstorages but just ended up crashing the server, and I don't think globalstorages would be good either since if one players
 
Last edited:
You can do it like this.
Code:
local function doEffects(cid, state)
     if state == 15 then
         return true
     end
     state = state + 1
     local player = Player(cid)
     if player then
         if effectstatus[cid] == 1 then
             effectstatus[cid] = 0
             return true
         end
         player:say("Danger!", TALKTYPE_MONSTER_SAY)
         addEvent(doEffects, 1000, cid, state)
     end
end

function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
     addEvent(doEffects, 1000, player.uid, 1)
     return true
end

Code:
function onStepIn(player, item, position, fromPosition)
     effectstatus[player.uid] = 1
     return true
end

In global.lua
Code:
effectstatus = {}
 
You can do it like this.
Code:
local function doEffects(cid, state)
     if state == 15 then
         return true
     end
     state = state + 1
     local player = Player(cid)
     if player then
         if effectstatus[cid] == 1 then
             effectstatus[cid] = 0
             return true
         end
         player:say("Danger!", TALKTYPE_MONSTER_SAY)
         addEvent(doEffects, 1000, cid, state)
     end
end

function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
     addEvent(doEffects, 1000, player.uid, 1)
     return true
end

Code:
function onStepIn(player, item, position, fromPosition)
     effectstatus[player.uid] = 1
     return true
end

In global.lua
Code:
effectstatus = {}


@Limos

need your help again with this! i am not home at the moment so i cannot post my modified scripts but i will try to explain the best i can!


the action script I adjusted so that it spams "danger" on u every second for 15 seconds, but it also sets an ACTION id to a posistion for 15 seconds.

the movement script I adjusted so that when you step on it, it's going to set the action id back to zero. However, when another player steps on this (the player that didnt use the item from the action script) it will keep spamming Danger over the player that used the item because of this "effectstatus[player.uid] = 1" I tried changing around it to effectstatus[posistion] and other stuff but it didn't work.

I want to make it like this:
player 1 uses the item that spams danger
player 2 steps on the tile that removes the danger effect
but it should also be possible for player 1 to remove the danger effect if he steps on it

right now if player 2 steps on the movement script nothing will happen to player 1
 
Last edited:
Then you can make it not based on the creatureid of the player, so you can just do it without a table.
Code:
effectstatus = 0
In the movement script.
Code:
effectstatus = 1
In function doEffects.
Code:
if effectstatus == 1 then
      effectstatus = 0
      return true
end
You can also use global storage btw, which will be kind of the same thing.
 
Back
Top