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

[Help] Quest script Bug

ond

Veteran OT User
Joined
Mar 24, 2008
Messages
2,782
Solutions
25
Reaction score
491
Location
Sweden
What I want it to do:

I want the first item to get an action of 6010

Here is the script:

LUA:
local ids = {2091, 2151, 2230, 2229, 1953}
local charges = {1, 2, 1, 1, 1}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, item.uid) ~= 1 then
        setPlayerStorageValue(cid, item.uid, 1)
        local bp = doPlayerAddItem(cid, 1987, 1)
        for i = 1, #ids do
            doAddContainerItem(bp, ids[i], charges[i])
		doSetItemActionId(ids, 6010)
	    doPlayerSendTextMessage(cid,22,"You have found a bag.")
    end
return TRUE
end
end
 
Code:
local ids =  {2091, 2151, 2230, 2229, 1953}
local charges = {1, 2, 1, 1, 1}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerStorageValue(cid, item.uid) ~= 1 then
		setPlayerStorageValue(cid, item.uid, 1)
		local bp = doPlayerAddItem(cid, 1987, 1)
		for i = 1, #ids do
			local cur = doAddContainerItem(bp, ids[i], charges[i])
			if i == 1 then
				doSetItemActionId(cur, 6010)
			end
		end
		doPlayerSendTextMessage(cid, 22, 'You have found a bag.')
	else
		doPlayerSendTextMessage(cid, 22, 'It is empty.')
	end
	return TRUE
end
 
Code:
local ids =  {2091, 2151, 2230, 2229, 1953}
local charges = {1, 2, 1, 1, 1}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, item.uid) ~= 1 then
        setPlayerStorageValue(cid, item.uid, 1)
        local bp = doPlayerAddItem(cid, 1987, 1)
        for i = 1, #ids do
			local added = doAddContainerItem(bp, ids[i], charges[i])
			if i == 1 then
				doItemSetAttribute(added,'aid',6010)
			end
            doPlayerSendTextMessage(cid,22,"You have found a bag.")
		end
	end
	
	return true
end
 
Code:
local ids =  {2091, 2151, 2230, 2229, 1953}
local charges = {1, 2, 1, 1, 1}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerStorageValue(cid, item.uid) ~= 1 then
		setPlayerStorageValue(cid, item.uid, 1)
		local bp = doPlayerAddItem(cid, 1987, 1)
		for i = 1, #ids do
			[B][COLOR="Red"]local cur = doAddContainerItem(bp, ids[i], charges[i])[/COLOR][/B]
			if i == 1 then
				[B][COLOR="Red"]doSetItemActionId(cur, 6010)[/COLOR][/B]
			end
		end
		doPlayerSendTextMessage(cid, 22, 'You have found a bag.')
	else
		doPlayerSendTextMessage(cid, 22, 'It is empty.')
	end
	return TRUE
end
also i guess, you should give he the item first either it will raise an error Item not found from the "doSetItemActionId"? must call global
 
Back
Top