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

doRemoveItemFromPos

slaw

Software Developer
Joined
Aug 27, 2007
Messages
3,667
Solutions
125
Reaction score
1,114
Location
Germany
GitHub
slawkens
Removing item from position, by ID, count parameter is <optional>.

Place in global.lua, or lib/function.lua if 0.3

Code:
function doRemoveItemFromPos(position, itemid, count)
	local item = getTileItemById(position, itemid)
	if item.uid ~= 0 then
		return doRemoveItem(item.uid, count or -1)
	end

	return FALSE
end
 
Last edited:
Old thread, yes i know, but just saw it in a list :p

doRemoveItem(getThingfromPos(pos) only remove 1 item
slawken's remove one item but with count :p

nice script tho :p

(old one too xD)
 
sorry for bumping such old thread.. but maybe someone will find it still useful. I just changed two things, 1) count parameter is optional, 2) should work with 0.4 and later 0.3 (where TRUE was changed to true)
 
Lua:
local pos = {160, 54, 7}
local item = 2160
local count = 100

function onUse (cid, item, fromposition, itemex, toposition)
doRemoveItemFromPos(pos, item, count)
docreaturesay(cid, 160, 54,7 elimitated ", talktype_orange_1)
end
 
Lua:
local pos = {x=160, y=54, z=7}
local item = 2160
local count = 100
 
function onUse (cid, item, fromPosition, itemEx, toPosition)
	if doRemoveItemFromPos(pos, item, count) then
		return doCreatureSay(cid, 'Eliminated', TALKTYPE_ORANGE_1, false, 0, pos)
	end
end
 
Lua:
local pos = {x=160, y=54, z=7}
local item = 2160
local count = 100
 
function onUse (cid, item, fromPosition, itemEx, toPosition)
	if doRemoveItemFromPos(pos, item, count) then
		return doCreatureSay(cid, 'Eliminated', TALKTYPE_ORANGE_1, false, 0, pos)
	end
end

Inside onUse variable item (2160) is changed to variable used in function item(as array).

Feelin' Pwned?
 
Back
Top