• 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] Action OnUse Buy bp of mana porions

Ralfegor

New Member
Joined
Apr 6, 2008
Messages
297
Reaction score
1
When i Use the action Id i Buy the bp but only 1 mana potion :( can anyone help me?


function onUse(cid, item, fromPosition, itemEx, toPosition)
if doPlayerRemoveMoney(cid, 10000) == 1 then
backpack = doPlayerAddItem(cid, 2001, 1)
doAddContainerItem(backpack, 7620, 20) -- here i put 20 amount but only give 1 mana potion :(
else
doPlayerSendCancel(cid, 'You don\'t have enough money.')
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
end
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if doPlayerRemoveMoney(cid, 10000) == 1 then
        backpack = doPlayerAddItem(cid, 2001, 1)
        for i = 1,20 do
            doAddContainerItem(backpack, 7620, 1)
        end
    else
        doPlayerSendCancel(cid, 'You don\'t have enough money.')
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    end
    return TRUE
end
 
The Function(add in global.LUA):
PHP:
function doAddContainerWithItems(cid, bp, item, type, amount)
	container = doPlayerAddItem(cid, bp, 1)
	for i = 1,amount do
		doAddContainerItem(container, item, type)
	end
end

The Script:
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if doPlayerRemoveMoney(cid, 10000) == 1 then
	doAddContainerWithItems(cid, 2001, 7620, 1, 20)
    else
        doPlayerSendCancel(cid, 'You don\'t have enough money.')
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    end
    return TRUE
end
 
This is fine, many thx for all, i'm test all two scripts and work fine, congratulations for all.... and thx for help...
 
Back
Top