• 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 Easy Action?

Sir Juninho

New Member
Joined
May 4, 2009
Messages
85
Reaction score
1
Hello!

I have a question for you guys haha.

How can I create an action that when I use an item it makes a bag with some itens inside of it?
 
Code:
local items = {
   {2160, 5},
   {2173, 1},
   {2173, 1},
}

function onUse(cid)
   local bag = doPlayerAddItem(cid, BAG_ID, 1)
   for _, v in pairs(items) do
      doAddContainerItem(bag, v[1], v[2])
   end
   return true
end
 
gonna give you a explaination
first to make any action it should start with

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
then add item you need a code lets see
Lua:
doPlayerAddItem(cid, 2000, 1)-- 2000 stands for itemid of backpack
then to add items inside the backpack we need another code
Lua:
doAddContainerItem(cid, itemid, 1)--choose items to add
we should send magic effect to make it cool
Lua:
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC)
we Should send a Message right??!
Lua:
doPlayerSendTextMessage(cid,14,"You Got Your First Items")
then done final code is
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition
		local items = {xxx,yyy,zzz,ttt}--change to numbers
		if doPlayerAddItem(cid, 2000, 1) then
		doAddContainerItem(cid, items, 1)--items stands for local items you can change them 
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC)
		doPlayerSendTextMessage(cid,14,"You Got Your First Items")
		end
		return true
	end
hope i help you

this script can be taken much times
--------------------------
can be taken once
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition
		local items = {xxx,yyy,zzz,ttt}--change to numbers
			if getPlayerStorageValue(cid, 50001) <= 0 then
			doPlayerAddItem(cid, 2000, 1)
			doAddContainerItem(cid, items, 1)--items stands for local items you can change them 
			doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC)
			doPlayerSendTextMessage(cid,14,"You Got Your First Items")
			setPlayerStorageValue(cid, 50001, 1)
			end
		else
		doPlayerSendCancel(cid,"You have Taken it Before")
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
		end
		return true
	end
 
Back
Top