• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action chest who sell demon set xD

Zerak456

Gorlex.net NEW!
Joined
Aug 13, 2008
Messages
1,060
Reaction score
6
Hello this is my first script "you can buy from a chest full demon" please rep++ me if you like it.. [my first script]

here is it
action/action.xml
Code:
	<action uniqueid="1510" script="set.lua" />


and now next...

action/scripts/set.lua
Code:
function onUse(cid, item, frompos, item2, topos)


if item.itemid == 1740 and doPlayerRemoveMoney(cid,500000) == 1 then
	for i = 1,1 do
	container = doPlayerAddItem(cid, 2000, 1)
	doAddContainerItem(container, 2493, 100)
	doAddContainerItem(container, 2494, 100)
	doAddContainerItem(container, 2495, 100)
	doAddContainerItem(container, 2520, 100)
	end
	doTransformItem(item.uid,item.itemid+0)
 
elseif item.itemid == 1740 and doPlayerRemoveMoney(cid,500000) == 1 then
	for i = 1,20 do
	doAddContainerItem(container, 2493, 100)
	doAddContainerItem(container, 2494, 100)
	doAddContainerItem(container, 2495, 100)
	doAddContainerItem(container, 2520, 100)
	end
 
else
doPlayerSendCancel(cid,"u dont got 50cc to buy demon set.")
end

return 1
end


thank you please rep++ me if it works and if u like it :) no bugs ^^
 
Last edited:
Don't know if will work. :confused:

LUA:
local set = 
{
    items = {2493, 2494, 2495, 2520},
    price = 100000
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.uid == 5000 and doPlayerRemoveMoney(cid, set.price) == TRUE then
        doPlayerAddItem(cid, set.items, 1)
    else
	doPlayerSendCancel(cid, "You don't have enough money.")
    end
    return TRUE
end
 
maybe a litte improved?

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
--Congif Starts
	local idOfItemWhatIsGivingPrize = 1740
	local containerId = 2000
	local storage = 5001
	local cost = 500000
	local giveItems = 
	{	
		--[Previous number+1] = {itemId = xxxx, amount = xx},
		[1] = {itemId = 2493, amount = 1},
		[2] = {itemId = 2494, amount = 1},
		[3] = {itemId = 2495, amount = 1},
		[4] = {itemId = 2520, amount = 1}--,
		--[x] = {itemId = xxxx amount = x}
	}
	local messages =
	{ msgGetItem = "You have bought a demon set.", 
	  msgEmpty = "You have already bought it.",
      msgNoCap = "You don\'t have enough cap to get demon set.",
	  msgNoSpace = "You don\'t have enough space in backpack to take it.",
	  msgNoCash = "You don\'t have enough money."
	}
-- Config End
if item.itemid == idOfItemWhatIsGivingPrize then
	if getPlayerMoney(cid) > cost then
		toPlayer = doCreateItemEx(2000,1)
		for i = 1,#giveItems do
			doAddContainerItem(toPlayer, giveItems[i].itemId, giveItems[i].amount)
		end
		ItemWeight = getItemWeight(toPlayer) --not sure
		if getPlayerStorageValue(cid,storage) < 1 then
			if getPlayerFreeCap(cid) => ItemWeight then
				addItemToPlayer = doPlayerAddItemEx(cid, toPlayer, 0)
				if addItemToPlayer == RETURNVALUE_NOERROR then
					doPlayerRemoveMoney(cid,cost)
					doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
					doSendAnimatedText(fromPosition, messages.msgGetItem, TEXTCOLOR_RED)
					setPlayerStorageValue(cid,storage,1)
				else
					doPlayerSendCancel(cid, messages.msgNoSpace)
				end
			else
				doPlayerSendCancel(cid, messages.msgNoCap)
			end
		else
			doPlayerSendCancel(cid, messages.msgEmpty)
		end
	else
		doPlayerSendCancel(cid, messages.msgNoCash)
	end
end

return TRUE
end

Looks better, don't you think that?;)

May there be bugs, cuz i wroted it in notepad, i am newbie in tables and not tested. fix this it there are bugs;)
 
Last edited:
i tested it and:

the chest opens normaly like if it doesnt had anything inside lol
and i've done all right

Tested with:

Action ID 1510
Unique ID 1510
 
Back
Top