• 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!

Talksaction vocation restriction

nefinoo

Carnage.flv
Joined
Sep 11, 2010
Messages
549
Solutions
1
Reaction score
58
Location
Lo Mochis, Sinaloa
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
 
TFS...? Probably 0.4.

add that line on the top

Lua:
local allowedVocations = {1,2,5,6}
local playerVoc = getVocationInfo(cid) // or getPlayerVocation if dont works that another function


if not isInArray(allowedVocations,playerVoc) then
    doPlayerSendCancel(cid, 'You need to be a mage.')
    return false
end
 
Last edited:
Back
Top