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

Lua Help with AddEvent problem

Gothric

New Member
Joined
Feb 6, 2010
Messages
264
Reaction score
1
I am writting a simple script. I use axe on ItemEx and this ItemEx transform to another item and i want to transform this item after 5 second

my part of this scripts

PHP:
addEvent(ex, 5000, parameters)
function ex(parameters)
parameter.itemex = itemEx.uid
doTransformItem(getThingFromPosition(getThingPosition(parameter.itemex)), xxxx)
return true
end


but there are bugs in console and it doesnt work ;| itemEx callbacck function blablabla -.-

please help me :D rep+
 
Put the function under the onuse function no need for param
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local function ex()
		doTransformItem(getTileItemById(toPosition,itemEx.itemid).uid,1947) 
		return true
	end
	addEvent(ex,5000)


return true
end
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	return addEvent(function() doTransformItem(itemEx.uid, [COLOR="red"][B]XXXX[/B][/COLOR]) end, 5 * 1000) and doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
end

With exhaust...

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local storage = 44511
	if exhaustion.check(cid, storage) == true then
		addEvent(function() doTransformItem(itemEx.uid, [COLOR="red"][B]XXXX[/B][/COLOR]) end, 5 * 1000)
		doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
		exhaustion.set(cid, storage, 5 * 1000)
	else
		return doPlayerSendCancel(cid, "Sorry, not possible.")
	end
	
	return true
end
 
@Doggynub
E=[Error - Action Interface]
In a timer event called from:
data/actions/scripts/xxxx/xxx.lua:onUse
Description:
(luaDoTransformItem) Item not found

@JDB
read what i wrote and then try tu write scripts.. i dont want to transform itemEx becouse its actually transformed
 
Then you did somthng wrong in mine, just copy mine and paste it as it is and any item you will click on will change after 5 sec to what ever you wrote in second param of transform function
 
LOok Copy this make a new file in actions. And then /reload actions, then use the item on what ever item it will change after 5 seconds.... lol
 
i think that u didnt test ur script ;) u wrong

look i used this edited line and it work fine
doTransformItem(getTileItemById({x=940, y=1026, z=7},8786).uid,7024)

but here i paste concrete position but i want to get id from itemEx.uid pos
whenever i write itemEx.uid there is fucking ERROR

E=[Error - Action Interface]
In a timer event called from:
data/actions/scripts/xxxx/xxx.luanUse
Description:
(luaDoTransformItem) Item not found

becouse itemEx is not declared in variants ;/ do you understand??
so i think that the only way i can fix it is parameters :|
 
do you understand??



yOU USING MY SCRIPTTTTT , WITH IT FUNCTION NOT YOURS FUNCTION.......


like this whole
LUA:
local itemid = 8457   -- the item id you want to remove from the place you clicked at
function onUse(cid, item, fromPosition, itemEx, toPosition)
local function ex()
		doTransformItem(getTileItemById(toPosition,itemid).uid,1947) 
		return true
	end
	addEvent(ex,5000)
 
 
return true
end

Take it like it is paste it dont change any shit do you need more explanation how and why


the own function is the under the main function so no need to put param in it ( param is the thing betwe () of the function)
Code:
doTransformItem(getTileItemById(toPosition,itemEx.itemid).uid,1947)

So this do what this get the toPosition(which is the postion where you clicked at..) , and the itemEx.itemid( check if there is an item id in the place you clicked at with
same id of ex) and then it is changed


Btw it is tested , dont try use on players of course.
 
Last edited:
As you described in the first post is what I made. Use an item on another and transform after five seconds.
 
Back
Top