• 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 multiple items in doAddContainerItem?

Evan

A splendid one to behold
Senator
Premium User
Joined
May 6, 2009
Messages
7,019
Solutions
1
Reaction score
1,029
Location
United States
How do I make it so I give multiple items in 1 container?
For example, I'm working on a script for someone and it's supposed take money and give a backpack with a rope and shovel inside when you say something.

This is what I have so far:
Lua:
items = {2120, 2554}
	
function onSay(cid, words, param, channel)
	if isPlayer(cid) and getPlayerMoney(cid) >= 500 then
		doPlayerRemoveMoney(cid, 500)
		doAddContainerItem(doPlayerAddItem(cid, 1988, 1), items, 1)
	end
	return true
end

I've tried everything, even using ipairs, but I could be using that incorrectly.
Anyone know a solution?
 
Code:
function onSay(cid, words, param, channel)
	if isPlayer(cid) and getPlayerMoney(cid) >= 500 then
		doPlayerRemoveMoney(cid, 500)
		local backpack = doPlayerAddItem(cid, BACKPACK_ID, 1)

		doAddContainerItem(backpack, ITEM_ID, 1)
		doAddContainerItem(backpack, SECOND_ITEM_ID, 1)
	end
	return true
end

i think it must work
 

Similar threads

Back
Top