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

stackpos problem

Dominik ms

Member
Joined
Jan 20, 2010
Messages
424
Reaction score
6
this work, but if is there monster or player i have error and cant remove my item

PHP:
[Error - Action Interface]
data/actions/scripts/test2.lua:onUse
Description:
(luaDoRemoveItem) Item not found

PHP:
function onUse(cid, item, fromPosition, itemEx, toPos)
local s2 = getPlayerStorageValue(cid, 1102)
local s3 = getPlayerStorageValue(cid, 1103)
local s4 = getPlayerStorageValue(cid, 1104)
local corpsePos = {x=s2, y=s3, z=s4, stackpos=1}
local corpse1 = getThingfromPos(corpsePos)
		doRemoveItem(corpse1.uid)
return true
end
 
The problem is the stackpos. If there is a player on the tile he is on stackpos 1 ..

Fixed:
PHP:
function onUse(cid, item, fromPosition, itemEx, toPos) 	
local x,y,z = getPlayerStorageValue(cid, 1102),getPlayerStorageValue(cid, 1103),getPlayerStorageValue(cid, 1104)
		local pos = {{x=x, y=y, z=z, stackpos=1},{x=x, y=y, z=z, stackpos=2}}
		local getCorpse = getThingFromPos(pos[1]).uid
		return isCreature(getCorpse) and doRemoveItem(getThingFromPos(pos[2]).uid) or doRemoveItem(getCorpse)
end
 
Code:
local itemid = XXXX
function onUse(cid, item, fromPosition, itemEx, toPos)  
	return doRemoveItem(getTileItemById({x=getPlayerStorageValue(cid, 1102), y=getPlayerStorageValue(cid, 1103), z=getPlayerStorageValue(cid, 1104)}, itemid).uid)
end
getTileItemById is better :p
 
If there is no creature then work, item was delete

If i step in on item then error (i use your script):
PHP:
[Error - Action Interface]
data/actions/scripts/test2.lua:onUse
Description:
(luaDoRemoveItem) Item not found
 
If there is no creature then work, item was delete

If i step in on item then error (i use your script):
PHP:
[Error - Action Interface]
data/actions/scripts/test2.lua:onUse
Description:
(luaDoRemoveItem) Item not found

Using Rhux or Cykotitan's script?
 
I even tested mine and everything worked properly, even if I stood on the item.

Ofc you can use getTileItemById and it will return the uid anytime..
 
Code:
local itemid = XXXX
function onUse(cid, item, fromPosition, itemEx, toPos)  
	return doRemoveItem(getTileItemById({x=getPlayerStorageValue(cid, 1102), y=getPlayerStorageValue(cid, 1103), z=getPlayerStorageValue(cid, 1104)}, itemid).uid)
end
getTileItemById is better :p
with urs it will give an error "Item not found" cuz with getTileItemById you must check if the item is there
 
with urs it will give an error "Item not found" cuz with getTileItemById you must check if the item is there

Okaaaaaaaay, so here's the final sceript:
Code:
local itemid = XXXX
function onUse(cid, item, fromPosition, itemEx, toPos)
	local targetItem = getTileItemByIdgetTileItemById({x=getPlayerStorageValue(cid, 1102), y=getPlayerStorageValue(cid, 1103), z=getPlayerStorageValue(cid, 1104)}, itemid).uid
	if(targetItem) then
		doRemoveItem(targetItem)
	end
	return true
end
 
Okaaaaaaaay, so here's the final sceript:
Code:
local itemid = XXXX
function onUse(cid, item, fromPosition, itemEx, toPos)
	local targetItem = [B][COLOR="Red"]getTileItemByIdgetTileItemById[/COLOR][/B]({x=getPlayerStorageValue(cid, 1102), y=getPlayerStorageValue(cid, 1103), z=getPlayerStorageValue(cid, 1104)}, itemid).uid
	if(targetItem) then
		doRemoveItem(targetItem)
	end
	return true
end
wtf
 
15:37
15:38

trollface.png
 
Back
Top