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

Lever that gives you items depending on your vocation and only if you have an item

Cris2387

Member
Joined
Dec 30, 2013
Messages
177
Reaction score
9
Hello i want a script that will allow players to get certain items for example this is my zone :
upload_2015-2-1_16-5-21.png
example: if the player has an x item and is a paladin then he will be able to get a set and weapon the paladin one is the one with bow and arrow hehe if someone could just make a script like that i will really appreciate it, you dont have to make 5 i just want 1 and ill edit it please! btw what do you guys think about the sets?
 
Hello i want a script that will allow players to get certain items for example this is my zone :
View attachment 28574
example: if the player has an x item and is a paladin then he will be able to get a set and weapon the paladin one is the one with bow and arrow hehe if someone could just make a script like that i will really appreciate it, you dont have to make 5 i just want 1 and ill edit it please! btw what do you guys think about the sets?

Since you said you wanted to edit it, I organized it nicely for you. Let me know if you have any issues, made this while at work.
Code:
local function setOne(cid)
local items = {1234, 1234, 1234, 1234, 1234}
    if getPlayerVocation(cid) == x then
        for i = 1, #items do
            doPlayerAddItem(cid, i, 1)
        end
    else
        doPlayerSendCancel(cid, "You must be a xxxx to obtain this set.")
    end
end

local function setTwo(cid)
local items = {1234, 1234, 1234, 1234, 1234}
    if getPlayerVocation(cid) == x then
        for i = 1, #items do
            doPlayerAddItem(cid, i, 1)
        end
    else
        doPlayerSendCancel(cid, "You must be a xxxx to obtain this set.")
    end
end

local function setThree(cid)
local items = {1234, 1234, 1234, 1234, 1234}
    if getPlayerVocation(cid) == x then
        for i = 1, #items do
            doPlayerAddItem(cid, i, 1)
        end
    else
        doPlayerSendCancel(cid, "You must be a xxxx to obtain this set.")
    end
end

local function setFour(cid)
local items = {1234, 1234, 1234, 1234, 1234}
    if getPlayerVocation(cid) == x then
        for i = 1, #items do
            doPlayerAddItem(cid, i, 1)
        end
    else
        doPlayerSendCancel(cid, "You must be a xxxx to obtain this set.")
    end
end

local function setFive(cid)
local items = {1234, 1234, 1234, 1234, 1234}
    if getPlayerVocation(cid) == x then
        for i = 1, #items do
            doPlayerAddItem(cid, i, 1)
        end
    else
        doPlayerSendCancel(cid, "You must be a xxxx to obtain this set.")
    end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
local item = xxxx
    if item.actionid == xxx and getPlayerItemCount(cid, item) >= 1 then
        setOne(cid)
    elseif item.actionid == xxx and getPlayerItemCount(cid, item) >= 1 then
        setTwo(cid)
    elseif item.actionid == xxx and getPlayerItemCount(cid, item) >= 1 then
        setThree(cid)
    elseif item.actionid == xxx and getPlayerItemCount(cid, item) >= 1 then
        setFour(cid)
    elseif item.actionid == xxx and getPlayerItemCount(cid, item) >= 1 then
        setFive(cid)
    else
        doPlayerSendCancel(cid, "You must have atleast x amount of xxxx to obtain this set.")
    end
return true
end
 
Since you said you wanted to edit it, I organized it nicely for you. Let me know if you have any issues, made this while at work.
Code:
local function setOne(cid)
local items = {1234, 1234, 1234, 1234, 1234}
    if getPlayerVocation(cid) == x then
        for i = 1, #items do
            doPlayerAddItem(cid, i, 1)
        end
    else
        doPlayerSendCancel(cid, "You must be a xxxx to obtain this set.")
    end
end

local function setTwo(cid)
local items = {1234, 1234, 1234, 1234, 1234}
    if getPlayerVocation(cid) == x then
        for i = 1, #items do
            doPlayerAddItem(cid, i, 1)
        end
    else
        doPlayerSendCancel(cid, "You must be a xxxx to obtain this set.")
    end
end

local function setThree(cid)
local items = {1234, 1234, 1234, 1234, 1234}
    if getPlayerVocation(cid) == x then
        for i = 1, #items do
            doPlayerAddItem(cid, i, 1)
        end
    else
        doPlayerSendCancel(cid, "You must be a xxxx to obtain this set.")
    end
end

local function setFour(cid)
local items = {1234, 1234, 1234, 1234, 1234}
    if getPlayerVocation(cid) == x then
        for i = 1, #items do
            doPlayerAddItem(cid, i, 1)
        end
    else
        doPlayerSendCancel(cid, "You must be a xxxx to obtain this set.")
    end
end

local function setFive(cid)
local items = {1234, 1234, 1234, 1234, 1234}
    if getPlayerVocation(cid) == x then
        for i = 1, #items do
            doPlayerAddItem(cid, i, 1)
        end
    else
        doPlayerSendCancel(cid, "You must be a xxxx to obtain this set.")
    end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
local item = xxxx
    if item.actionid == xxx and getPlayerItemCount(cid, item) >= 1 then
        setOne(cid)
    elseif item.actionid == xxx and getPlayerItemCount(cid, item) >= 1 then
        setTwo(cid)
    elseif item.actionid == xxx and getPlayerItemCount(cid, item) >= 1 then
        setThree(cid)
    elseif item.actionid == xxx and getPlayerItemCount(cid, item) >= 1 then
        setFour(cid)
    elseif item.actionid == xxx and getPlayerItemCount(cid, item) >= 1 then
        setFive(cid)
    else
        doPlayerSendCancel(cid, "You must have atleast x amount of xxxx to obtain this set.")
    end
return true
end
better use tables and loops
easy example how to: https://github.com/Znote/ZnoteAAC/blob/master/LUA/TFS_10/creaturescript firstitems/firstitems.lua
 
How's this Look?
Code:
local config = {
[1] = {
items = {{2175, 1}, {2190, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}},
},
[2] = {
items = {{2175, 1}, {2182, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}},
},
[3] = {
items = {{2525, 1}, {2389, 5}, {2660, 1}, {8923, 1}, {2643, 1}, {2661, 1}, {2480, 1}},
},
[4] = {
items = {{2525, 1}, {8601, 1}, {2465, 1}, {2460, 1}, {2478, 1}, {2643, 1}, {2661, 1}},
},
[5] = {
items = {{2525, 1}, {8601, 1}, {2465, 1}, {2460, 1}, {2478, 1}, {2643, 1}, {2661, 1}},
}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local vocations = config[getPlayerVocation(cid)]

    if not vocations then
        return true
    end
   
    if getPlayerItemCount(cid, xxxx) >= 1 then
        for i = 1, #vocations.items do
            doPlayerAdditems(cid, vocations.items[i][1], vocations.items[i][2])
        end
    end
return true
end
 
How's this Look?
Code:
local config = {
[1] = {
items = {{2175, 1}, {2190, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}},
},
[2] = {
items = {{2175, 1}, {2182, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}},
},
[3] = {
items = {{2525, 1}, {2389, 5}, {2660, 1}, {8923, 1}, {2643, 1}, {2661, 1}, {2480, 1}},
},
[4] = {
items = {{2525, 1}, {8601, 1}, {2465, 1}, {2460, 1}, {2478, 1}, {2643, 1}, {2661, 1}},
},
[5] = {
items = {{2525, 1}, {8601, 1}, {2465, 1}, {2460, 1}, {2478, 1}, {2643, 1}, {2661, 1}},
}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local vocations = config[getPlayerVocation(cid)]

    if not vocations then
        return true
    end
 
    if getPlayerItemCount(cid, xxxx) >= 1 then
        for i = 1, #vocations.items do
            doPlayerAdditems(cid, vocations.items[i][1], vocations.items[i][2])
        end
    end
return true
end
thank you, i hope this works
 
I think this is what you want.
Code:
local levers = {
    [5000] = { -- Action id of the lever
        vocs = {1, 5}, -- Vocation ids
        itemCost = {id = 2160, count = 10}, -- The item & count required
        items = { -- Items
            {id = 2175, count = 1},
            {id = 2190, count = 1},
            {id = 8819, count = 1},
            {id = 8820, count = 1},
            {id = 2468, count = 1},
            {id = 2643, count = 1},
            {id = 2661, count = 1}
        }
    },
    [5001] = {
        vocs = {2, 6},
        itemCost = {id = 2160, count = 10},
        items = {
            {id = 2175, count = 1},
            {id = 2182, count = 1},
            {id = 8819, count = 1},
            {id = 8820, count = 1},
            {id = 2468, count = 1},
            {id = 2643, count = 1},
            {id = 2661, count = 1}
        }
    },
    [5002] = {
        vocs = {3, 7},
        itemCost = {id = 2160, count = 10},
        items = {
            {id = 2525, count = 1},
            {id = 2389, count = 5},
            {id = 2660, count = 1},
            {id = 8923, count = 1},
            {id = 2643, count = 1},
            {id = 2661, count = 1},
            {id = 2480, count = 1}
        }
    },
    [5003] = {
        vocs = {4, 8},
        itemCost = {id = 2160, count = 10},
        items = {
            {id = 2525, count = 1},
            {id = 8601, count = 1},
            {id = 2465, count = 1},
            {id = 2460, count = 1},
            {id = 2478, count = 1},
            {id = 2643, count = 1},
            {id = 2661, count = 1}
        }
    },
    [5004] = {
        vocs = {0},
        itemCost = {id = 2160, count = 10},
        items = {
            {id = 2525, count = 1},
            {id = 8601, count = 1},
            {id = 2465, count = 1},
            {id = 2460, count = 1},
            {id = 2478, count = 1},
            {id = 2643, count = 1},
            {id = 2661, count = 1}
        }
    }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local lever = levers[item.actionid]
    if not isInArray(lever.vocs, getPlayerVocation(cid)) then
        doPlayerSendCancel(cid, "This is not for your vocation.")
        return true
    end
  
    if doPlayerRemoveItem(cid, lever.itemCost.id, lever.itemCost.count) then
        for _, item in ipairs(lever.items) do
            doPlayerAddItem(cid, item.id, item.count)
        end
    else
        doPlayerSendCancel(cid, "You do not have the required item.")
    end
    return true
end
 
Last edited:
Back
Top