• 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 me in a function...

morramead

New Member
Joined
Jan 23, 2008
Messages
74
Reaction score
0
Hi guys, i so making every quests, and i have a simple problem.
Look: It is basic function of quests "setPlayerQuest".

( Code )
function onUse(cid, item, frompos, item2, topos)
if item.uid == 1987 then

setPlayerQuest(cid, 6669, 2000, 1)

end
return TRUE
end

Ok...

6669 = Storage player.
2000 = Backpack.
1987 = Id Chest.


setPlayerQuest is a function added in global.lua
Look:

( Function )
function setPlayerQuest(ud, stor, itemquest, qnt)

local itemWeight = getItemWeight(itemquest, 1)
local playerCap = getPlayerFreeCap(ud)
if getPlayerStorageValue(ud, stor) == -1 then

if playerCap >= itemWeight then
doPlayerAddItem(ud, itemquest, qnt)
setPlayerStorageValue(ud, stor, 1)
doPlayerSendTextMessage(ud, MESSAGE_INFO_DESCR, 'You have found a ' .. getItemName(itemquest) .. '.')
else
doPlayerSendTextMessage(ud, MESSAGE_INFO_DESCR, 'You have found a ' .. getItemName(itemquest) .. '. It is weighing ' .. itemWeight .. ' oz . It\'s too heavy.')
end
else
doPlayerSendTextMessage(ud, MESSAGE_INFO_DESCR, "It is empty.")
end
end

I need modify any in global.lua? or the code? For add itens inside backpack.


please help me thanks for all :)
 
Last edited:
In global.lua add:
PHP:
function doAddContainerWithItems(cid, bp, item, type, amount)
	container = doPlayerAddItem(cid, bp, 1)
	for i = 1,amount do
		doAddContainerItem(container, item, type)
	end
end
In the script you can use:
doAddContainerWithItems(cid, bp, item, type, amount)
--
Ex:
PHP:
local ITEMbag = 1987
local ITEMrune = 2261

function onUse(cid, item, frompos, item2, topos) 
  if item.uid == 1987 then
     doAddContainerWithItems(cid, ITEMbag, ITEMrune, 5, 20)
    end
  return TRUE
end
doAddContainerWithItems(cid, ITEMbag, ITEMrune, 5, 20)
RED = Charges of the item(rune).
ORANGE = xRunes(20 rune).
 
Code:
function setPlayerQuest(cid, stor, itemquest, qnt)
	local itemWeight = getItemWeightById(itemquest, qnt)
	local playerCap = getPlayerFreeCap(cid)
	if getPlayerStorageValue(cid, stor) == -1 then
		if playerCap >= itemWeight then
			doPlayerAddItem(cid, itemquest, qnt)
			setPlayerStorageValue(cid, stor, 1)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a ' .. getItemNameById(itemquest) .. '.')
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a ' .. getItemNameById(itemquest) .. '. It is weighing ' .. itemWeight .. ' oz . It\'s too heavy.')
		end
	else
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
	end
end
 
Back
Top