nefinoo
Carnage.flv
I want to add vocation restriction on this script, this command just can be use for mages
Code:
function onSay(cid, words, param, channel)
--configuration --
local items =
{
['mana potion'] = {cost = 1, storage = 49990},
['strong mana potion'] = {cost = 2, storage = 49989},
['great mana potion'] = {cost = 3, storage = 49988},
['ultimate mana potion'] = {cost = 4, storage = 49987},
['mana rune'] = {cost = 5, storage = 49986},
['strong mana rune'] = {cost = 6, storage = 49985},
['great mana rune'] = {cost = 7, storage = 49984},
['ultimate mana rune'] = {cost = 8, storage = 49983}
}
-- Fin configuration --
local t = string.explode(param, ",")
local item = items[t[1]]
local amount = tonumber(t[2])
-- Checks if we can buy that itemname --
if item then
-- Checks if the player has enough money --
if doPlayerRemoveMoney(cid, item.cost*amount) == LUA_NO_ERROR then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You have bought '..amount..' '..t[1]..' charges for '..(item.cost*amount)..' golden pieces.')
setPlayerStorageValue(cid, item.storage, getPlayerStorageValue(cid, item.storage)+amount)
else
doPlayerSendCancel(cid, 'You dont have enough money to buy that many charges.')
doSendMagicEffect(getPlayerPosition (cid), CONST_ME_POFF)
end
else
-- Sends the player a message wich includes items he can buy --
text = "Charges you can buy:\n"
-- Getting the all itemnames and prics --
for item1 in pairs (items) do
-- Sends a message with each itemname and price --
text = text .. "\n" .. item1
end
text = text .. "\n\nexample: type '!cm mana potion, 100' to buy 100 mana potions."
text = text .. "\n\nejemplo: escribe '!cm mana potion, 100' para comprar 100 mana potions."
doPlayerPopupFYI(cid, text)
end
return true
end