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

onThink function question

Marko999x

999x era
Premium User
Joined
Dec 14, 2017
Messages
2,849
Solutions
82
Reaction score
1,955
Location
Germany
Hi
im kinda confused but how do I stop a onThink Function once it started? ( creaturescript )
 
Hi
im kinda confused but how do I stop a onThink Function once it started? ( creaturescript )
To help will be better to know what u wanna do.
Example for using item you can do something like that.

Lua:
local function EventOnline(playerId, seconds)
local Ticks = 1000 -- Function will execute every  seconds (1000 = 1 second)
local player = Player(playerId)
    if seconds > 0 and player and player:getStorageValue(59000) == 1 then
-- Stuff for execute every tick
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Pam~! Pam~! Pam~!")
        addEvent(EventOnline, Ticks, playerId, seconds - 1)
    end
    return true
end

local StatusTime = 58000 -- Storage number for check active or not
local WorkingTime = 60 -- in seconds, event will work for 60 seconds
local Activator = 59000 -- This will for manually On/Off
function onUse(player, item, fromPosition, itemEx, toPosition)

        if player:getStorageValue(StatusTime) <= os.time() and player:getStorageValue(Activator) <= 0 then
        player:setStorageValue(StatusTime, os.time() + (WorkingTime - 1))
        player:setStorageValue(Activator, 1)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Ascuas The God xD")
        return EventOnline(player:getId(), WorkingTime)
    end
    -- if use item second time will stop event immediately
        player:setStorageValue(StatusTime, os.time())
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "What are you doing, bastard!")
        player:setStorageValue(Activator, 0)
        return
    end

You can use for it everything what u want, OnCastSpell, OnUse, OnExtendedOpcode, OnKill etc...
 
Last edited:
Sorry my fault in that case.
A summon should heal the master but for some reasons im to dumb to get it work with Spells so I tried out with onThink
It worked perfect but I had problems to stop the onThink
Make on healthchange script, then in script set summon and master check if true and for example add hp percent level before execute heal function then execute heal line. And register script in monster/summon.xm as event. Then you will avoid every addevent, onthink and other laggy stuff. Im on phone now, i will check how make this when i back to pc.

But if you have worked ir on onThink then just change it to healthchange :) and script will only execute when master lose hp.

If you wanna make it onHealtchange and need help with this, just paste script i will edit it.
 
Last edited:
Back
Top