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

Globalevent problem ;/

Mooosie

- Lua Scripter -
Joined
Aug 2, 2008
Messages
702
Reaction score
27
Location
Sweden
What I am doing is,
If an itemid = 6289 is in this position then remove the item and create another item on the same position. I got this script but it seems to not working and I don't get any errors in console:

Lua:
local fire = 6289
local energy = 5069
local earth = 6238
local ice = 6746
local paoss = {x=911, z=1178, y=7}
local fireitempos = getTileItemById(paoss, fire)
local energyitempos = getTileItemById(paoss, energy)
local earthitempos = getTileItemById(paoss, earth)
local iceitempos = getTileItemById(paoss, ice)
function onThink(interval, lastExecution, thinkInterval)
	if getTileItemById(paoss, fire) == true then
		doRemoveItem(fireitempos.uid)
		doCreateItem(energy, 1, paoss)
	elseif getTileItemById(paoss, energy) == true then
		doRemoveItem(energyitempos.uid, 1)
		doCreateItem(earth, 1, paoss)
	elseif getTileItemById(paoss, earth) == true then
		doRemoveItem(earthitempos.uid)
		doCreateItem(ice, 1, paoss)
	elseif getTileItemById(paoss, ice) == true then
		doRemoveItem(iceitempos.uid)
		doCreateItem(fire, 1, paoss)
	end
return true
end

XML:
 <globalevent name="AaTeleport" interval="5000" event="script" value="attel.lua"/>
 
Havn't found errors in your script, but remade it so it looks sexy and might work.
Lua:
local t = {6289,5069,6238,6746}
local pos = {x=911, z=1178, y=7}
function onThink(interval, lastExecution, thinkInterval)
for i = 1, #t do
	if getTileItemById(pos, t[i]) then
		doRemoveItem(getTileItemById(pos,t[i]).uid, 1)
		doCreateItem(t[i+1], 1, pos)
		break;
	end
end
return true
end
 
Well then it must be something wrong with
XML:
		doCreateItem(t[i+1], 1, pos)

And the map editor position combined.

Since it is saying it can't create and item on that tile because that tile isn't found :eek:
So either the position is wrong, which you stated its correct :S
Or it must be something wrong with the "docreateitem" line .. Yet i don't see anything wrong with it
 
Lua:
function onTime()
	doCreateItem(itemid, 1, {x=32366, y=32233, z=6, stackpos=1})
	doCreateItem(itemid, 1, {x=32367, y=32233, z=6, stackpos=1})
	doCreateItem(itemid, 1, {x=32368, y=32233, z=6, stackpos=1})
	doCreateItem(itemid, 1, {x=32369, y=32233, z=6, stackpos=1})
	doCreateItem(itemid, 1, {x=32370, y=32233, z=6, stackpos=1})
	doCreateItem(itemid, 1, {x=32371, y=32233, z=6, stackpos=1})
	doCreateItem(itemid, 1, {x=32372, y=32233, z=6, stackpos=1})	

	for _, name in ipairs(getOnlinePlayers()) do
		local cid = getPlayerByName(name)
			doPlayerSendTextMessage(cid, 22, "Text send players.")
	end
	return true
end

In globalevents.xml
Lua:
	<globalevent name="Createitem" time="00:10:00" event="script" value="name.lua"/>
	<globalevent name="Createitem" time="04:10:00" event="script" value="name.lua"/>
	<globalevent name="Createitem" time="08:10:00" event="script" value="name.lua"/>
	<globalevent name="Createitem" time="12:10:00" event="script" value="name.lua"/>
	<globalevent name="Createitem" time="16:10:00" event="script" value="name.lua"/>
	<globalevent name="Createitem" time="20:10:00" event="script" value="name.lua"/>
Online edit positions where create item.. also edit the time
done!
 
Last edited:
@UP
Error:
<LuaDoCreateItem> Tile Not Found

I've checked the position and it is right.

Code:
local pos = {x=911, [B][COLOR="#FF0000"]z[/COLOR][/B]=1178, [B][COLOR="#FF0000"]y[/COLOR][/B]=7}
lolo fail ;D
Lua:
local pos = {x=911, y=1178, z=7}

EDIT: Ah ye make another pos with stackpos to remove item
 
@UP
I am using your script. I put a fire wall at the position and it removes it and puts energy wall. But when it tries to do it again, it says item not found...
 
If your using this code.

Lua:
local t = {6289,5069,6238,6746}
local pos = {x=911, z=1178, y=7}
function onThink(interval, lastExecution, thinkInterval)
for i = 1, #t do
	if getTileItemById(pos, t[i]) then
		doRemoveItem(getTileItemById(pos,t[i]).uid, 1)
		doCreateItem(t[i+1], 1, pos)
		break;
	end
end
return true
end

You never set a new uid to the item you create.
This might help doItemSetAttribute(variable, "uid", uid)
 
Last edited:
Back
Top