Since evolution-based server and clean SVN does not have onThink, I decided to create one. I tested it and it works perfectly fine
Credits: Ispiro
Comments please
login.lua
onthink.lua
Fix: Fixed a bug where it wouldn't cancel player's addEvents if he logged out 2 seconds immediatly after he logged in
Fix2: Fixed a bug where it would take more than the interval time to trigger onThink.
update: changed onThink(cid) to onThink(cid, interval). So it's possible to know the interval time using a script.
update2: interval time is now configurable by changing the variable "intervalTime" to the time in miliseconds.
update3: returning "FALSE" in the onThink() function will now kick the player off the server.
update4: removed global variable, using local variable instead
fix3: removing playing by returning onThink didn't trigger his onLogout, so instead, used isPlayer check.
update5: removed eventsForOnThink variable, isPlayer check moved to function "onThinkPrepare(cid)" to avoid events for offline players.
Credits: Ispiro
Comments please
login.lua
Code:
local intervalTime = 2000 -- time between onThink() for player.
function onLogin(cid)
onThinkPrepare(cid)
return 1
end
-- do not edit what's below this line.
function onThinkPrepare(cid)
if(isPlayer(cid) == FALSE) then
return false
end
onThinkCallback(cid)
addEvent(onThinkPrepare, intervalTime, cid)
end
dofile("./data/creaturescripts/scripts/onthink.lua")
function onThinkCallback(cid)
if(onThink(cid, intervalTime) == FALSE) then
doRemoveCreature(cid)
end
end
onthink.lua
Code:
function onThink(cid, interval)
-- return FALSE will kick the player
return TRUE
end
Fix: Fixed a bug where it wouldn't cancel player's addEvents if he logged out 2 seconds immediatly after he logged in
Fix2: Fixed a bug where it would take more than the interval time to trigger onThink.
update: changed onThink(cid) to onThink(cid, interval). So it's possible to know the interval time using a script.
update2: interval time is now configurable by changing the variable "intervalTime" to the time in miliseconds.
update3: returning "FALSE" in the onThink() function will now kick the player off the server.
update4: removed global variable, using local variable instead
fix3: removing playing by returning onThink didn't trigger his onLogout, so instead, used isPlayer check.
update5: removed eventsForOnThink variable, isPlayer check moved to function "onThinkPrepare(cid)" to avoid events for offline players.
Last edited: