4Muki4
HOROHOROHORO
- Joined
- May 1, 2012
- Messages
- 757
- Reaction score
- 70
Hello,
i have this script which is from centera datapack, and when you right click it gives you a backpack of runes or just 20 potions. I would like it to do like this just give 1 item no backpack example: 1 sd or 1 potion nothing else
Script:
i have this script which is from centera datapack, and when you right click it gives you a backpack of runes or just 20 potions. I would like it to do like this just give 1 item no backpack example: 1 sd or 1 potion nothing else
Script:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local cfg =
{
[8000] = {backpackid = 2004, rune = 7618, charges = 1, cost = 1000},
[8001] = {backpackid = 2002, rune = 7588, charges = 1, cost = 1000},
[8002] = {backpackid = 2000, rune = 7591, charges = 1, cost = 1000},
[8003] = {backpackid = 2001, rune = 8473, charges = 1, cost = 1000},
[8004] = {backpackid = 2000, rune = 8472, charges = 1, cost = 1000},
[8005] = {backpackid = 2000, rune = 7620, charges = 1, cost = 1000},
[8006] = {backpackid = 2000, rune = 7589, charges = 1, cost = 1000},
[8007] = {backpackid = 2000, rune = 7590, charges = 1, cost = 1000},
}
-- Variables --
local price = cfg[item.uid].cost
local types = cfg[item.uid].rune
local count = cfg[item.uid].charges
local bag = cfg[item.uid].backpackid
local name = getItemNameById(types)
local backpack_weight = getItemWeightById(bag,1)
local potions_weight = getItemWeightById(types,20)
local total_weight = backpack_weight + potions_weight
-- End --
if getPlayerMoney(cid) > price then
if getPlayerFreeCap(cid) > total_weight then
addBackpack = doCreateItemEx(bag,1)
for i=1,20 do
doAddContainerItem(addBackpack, types, count)
end
local addItemToPlayer = doPlayerAddItemEx(cid, addBackpack , 0)
if addItemToPlayer == RETURNVALUE_NOERROR then
doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
doSendAnimatedText(fromPosition, "Bought!", TEXTCOLOR_RED)
doPlayerRemoveMoney(cid, price)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have purchased a backpack of ".. name .."s for ".. price .." gold.")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don\'t have enough space in your backpack to put there a backpack of ".. name .."s.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need ".. total_weight .." oz. to take a backpack of ".. name .."s.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need ".. price .." gold coins for a backpack of ".. name .."s.")
end
return TRUE
end