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

9.8 Globalevents

UpInSmoke

Supreme Ruler
Joined
Nov 16, 2008
Messages
303
Reaction score
21
So theres something strange with my global events .. It works but only once, so if i reload globalevents the script will work but then stops working.
I am using 9.8 heres the scripts:
Code:
<globalevent name="Add" interval="1" script="add.lua"/>
Lua:
function onThink(interval, lastExecution)
	for _, name in ipairs(getOnlinePlayers()) do
		local player = getPlayerByName(name)
			if getTileInfo(getThingPos(player)).protection then
				if getPlayerMana(player) < getPlayerMaxMana(player) then
					doPlayerAddMana(player, 1)
				end
				if getCreatureHealth(player) < getCreatureMaxHealth(player) then
					doCreatureAddHealth(player, 1)
				end
			end
	end
return true
end
any idea whats wrong?
 
Not sure but interval 1 seems ridiculously low number, put it least 1000 and see if it works, then you can try lowering it a bit, like 100 maybe.
 
Not sure but interval 1 seems ridiculously low number, put it least 1000 and see if it works, then you can try lowering it a bit, like 100 maybe.

I have tried it at 1000 there is no difference; it still only works the first time it loads.. :/
 
Code:
function onThink(interval, lastExecution, [COLOR="#FF0000"]thinkInterval[/COLOR])
	for _, name in ipairs(getOnlinePlayers()) do
		local player = getPlayerByName(name)
			if getTileInfo(getThingPos(player)).protection then
				if getPlayerMana(player) < getPlayerMaxMana(player) then
					doPlayerAddMana(player, 1)
				end
				if getCreatureHealth(player) < getCreatureMaxHealth(player) then
					doCreatureAddHealth(player, 1)
				end
			end
	end
return true
end

all i could think of..
 
Back
Top