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

Error but the global event works fine.

Summ

(\/)(;,,;)(\/) Y not?
Staff member
Global Moderator
Joined
Oct 15, 2008
Messages
4,136
Solutions
12
Reaction score
1,115
Location
Germany :O
Hello I made a script (globalevent) and it works like I want it to, but every 2 seconds when it executes this message appears:
Code:
[Error - GlobalEvents::onThink] Couldn't execute event: trainers

This is my script:
Code:
function onThink(interval, lastExecution)
pos = {x=626, y=286, z=9}
start =
{
	[1] = {x=635, y=286, z=10, stackpos=253},
	[2] = {x=635, y=293, z=10, stackpos=253},
}	
tablepos = {}
getTrainPos(6, start, 27, 4, 1, tablepos)
local free = #tablepos
for i = 1, #tablepos do	
	player = getThingFromPos({x = tablepos[i].x, y = tablepos[i].y, z = tablepos[i].z, stackpos = tablepos[i].stackpos})
		if isPlayer(player.uid) or isCreature(player.uid) then
			free = free - 1
		end
end
doSendAnimatedText(pos,""..free.."", 70)
end

getTrainPos is a function made by me and fills the array tablepos with positions. The script works but the errors appear.

Something wrong with the script?
 
Last edited:
Put a return TRUE before the last end :)
LUA:
function onThink(interval, lastExecution)
pos = {x=626, y=286, z=9}
start =
{
	[1] = {x=635, y=286, z=10, stackpos=253},
	[2] = {x=635, y=293, z=10, stackpos=253},
}	
tablepos = {}
getTrainPos(6, start, 27, 4, 1, tablepos)
local free = #tablepos
for i = 1, #tablepos do	
	player = getThingFromPos({x = tablepos[i].x, y = tablepos[i].y, z = tablepos[i].z, stackpos = tablepos[i].stackpos})
		if isPlayer(player.uid) or isCreature(player.uid) then
			free = free - 1
		end
       return TRUE
end
doSendAnimatedText(pos,""..free.."", 70)
    return TRUE
end
 
Thank you! :)

But can you explain me why I have to do that?
I want to understand it.

Btw. reputation added.
 
Code:
start =
{
	[1] = {x=635, y=286, z=10, stackpos=253},
	[2] = {x=635, y=293, z=10, stackpos=253}[COLOR="Red"],[/COLOR]
}

Well, you also got an error here. You dont put a comma (,) after the last value.

So:
Code:
start =
{
	[1] = {x=635, y=286, z=10, stackpos=253},
	[2] = {x=635, y=293, z=10, stackpos=253}
}

and use local variables ;(
 
But thats doesn't interrupt the script working how it should.

It was that I forgot the return TRUE at the end.
 
Back
Top