Tenta assim:
function getItemCap(itemid, quant) -- function by MatheusMkalo
return getItemInfo(itemid).weight * (quant or 1)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local configs = {
[45690] = {itemid = 2160, quant = 100, cost = 5},
[45691] = {itemid = 2268, quant = 100, cost = 2},
}
local coinid = 9971 -- Use o id da gold coin (2148) se voce quizer usar o sistema de dinheiro mesmo. (Caso o itemid for 2148 o cost sera de gps ou seja 30 = 30 gps)
if configs[item.actionid] then
if getPlayerFreeCap(cid) >= math.ceil(getItemCap(configs[item.actionid].itemid, configs[item.actionid].quant)) then
if coinid ~= 2148 and getPlayerItemCount(cid, coinid) >= configs[item.actionid].cost or doPlayerRemoveMoney(cid, configs[item.actionid].cost) then
doPlayerAddItem(cid, configs[item.actionid].itemid, configs[item.actionid].quant)
doPlayerRemoveItem(cid, coinid, configs[item.actionid].cost)
else
return doPlayerSendCancel(cid, ("You need " .. configs[item.actionid].cost) .. (coinid == 2148 and " gold coins" or (" " .. getItemPluralNameById(coinid):lower())) .. " to buy this item.")
end
else
return doPlayerSendCancel(cid, "You need " .. math.ceil(getItemCap(configs[item.actionid].itemid, configs[item.actionid].quant)) .. " cap for buy that.")
end
end
return true
end






info
Grupo: Visconde
Registrado: 24/05/11
Posts: 391
Reputação: +102
Olá Ekz,
Bom eu estou precisando de um script que ao puxar a alavanca ele compre 100 Runas/Potions.
Sim tem alguns scripts aqui no Fórum sobre isso, porém não é o que procuro, pois os que tem, ou compram apenas 1, ou compra por backpack.
Cheguei a pegar esse AQUI:
function getItemCap(itemid, quant) -- function by MatheusMkalo return getItemInfo(itemid).weight*(quant or 1) end function onUse(cid, item, fromPosition, itemEx, toPosition) local configs = { [45690] = {itemid = 2160, quantperslot = 10, cost = 5, backpackid = 2002}, [45691] = {itemid = 2268, quantperslot = 50, cost = 2, backpackid = 2003}, } local coinid = 9971 -- Use o id da gold coin (2148) se voce quizer usar o sistema de dinheiro mesmo. (Caso o itemid for 2148 o cost sera de gps ou seja 30 = 30 gps) if configs[item.actionid] then if getPlayerFreeCap(cid) >= math.ceil((getItemCap(configs[item.actionid].itemid, configs[item.actionid].quantperslot)*20)+getItemCap(configs[item.actionid].backpackid)) then if coinid ~= 2148 and getPlayerItemCount(cid, coinid) >= configs[item.actionid].cost or doPlayerRemoveMoney(cid, configs[item.actionid].cost) then local backpack = doPlayerAddItem(cid, configs[item.actionid].backpackid) for i = 1, 20 do doAddContainerItem(backpack, configs[item.actionid].itemid, configs[item.actionid].quantperslot) end doPlayerRemoveItem(cid, coinid == 2148 and 0000 or coinid, configs[item.actionid].cost) else return doPlayerSendCancel(cid, ("You need " .. configs[item.actionid].cost) .. (coinid == 2148 and " gold coins" or (" " .. getItemPluralNameById(coinid):lower())) .. " to buy this item.") end else return doPlayerSendCancel(cid, "You need " .. math.ceil((getItemCap(configs[item.actionid].itemid, configs[item.actionid].quantperslot)*20)+getItemCap(configs[item.actionid].backpackid)) .. " cap for buy that.") end end return TRUE endPorém ele é com backpack, mesmo eu tirando a parte da backpack ID, ele não funciona.
Gostaria se alguém pudesse fazer algum nesse estilo ou configurar esse mesmo pra não ter backpack.