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

Script to use item, and then get items + vocation

Cornwallis

Member
Joined
Jan 3, 2010
Messages
480
Reaction score
16
If that didn't explain it enough, I want a script that when you use an item ( the item has a certain actionid ) it gives you 1 vocation, meaning i will make 4 of this file, and it gives you items that i pick. Further questions just ask :)
Edit; And can you make it teleport me =)
 
Last edited:
Code:
function onUse (cid, item, fromPosition, itemEx, toPosition)
  if item.actionid == <action id> then
    doPlayerSetVocation (cid, <vocation id>)
    doPlayerAddItem (cid, <item id>)
  end
  return true
end

is it this what u meant?
 
can you make it tp the player to x1000 y997 z7? Also, for the doPlayerAddItem (cid, (can i put more than 1 item like 5 crystal coins(2160) and an aol (2173 and then i can figure out the rest.
 
Code:
local cfg = {
    action = 1234,
    items = {1234, 2345, 3456, 4567},
    stackItems = {1111, 2222, 3333},
    count = [COLOR=Red]5[/COLOR],
    newPos = {x = 1234, y = 1234, z = 7},
    }
local voc = {
--oldVoc, newVoc
    {1, 5},
    {2, 6},
    {3, 7},
    {4, 8},
    }

function onUse (cid, item, fromPosition, itemEx, toPosition)
    for _, a1 in ipairs(cfg.items) do
        for _, a2 in ipairs(cfg.stackItems) do
            for b = 1, #voc do
                if item.actionid == cfg.action then
                    if getPlayerVocation(cid) == b[1] then
                        doPlayerSetVocation(cid, b[2])
                        doPlayerAddItem(cid, a1, 1)
                        doPlayerAddItem(cid, a2, cfg.count)
                        doTeleportThing(cid, cfg.newPos, false)
                        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
                    end
                end
            end
        end
    end
    return true
end
The red 5 is how many x of the items in stackItems you will get. in stackItems you should add all the stackable items ;p
 
Last edited:
One more question, is there a way for it to put items in the backpack(1988) such as a mana potion(7620) im using the script Slakteran gave me
 
This doesn't seem to work..

Code:
local cfg = {
    action = 5627,
    items = {2190, 1988, 8820, 8819, 2648, 2214, 2643, 2173},
    stackItems = {2152},
    count = 75,
    newPos = {x = 1000, y = 997, z = 7},
    }
local voc = {
--oldVoc, newVoc
    {0, 1},
    }

function onUse (cid, item, fromPosition, itemEx, toPosition)
    for _, a1 in ipairs(cfg.items) do
        for _, a2 in ipairs(cfg.stackItems) do
            for b = 1, #voc do
                if item.actionid == cfg.action then
                    if getPlayerVocation(cid) == b[1] then
                        doPlayerSetVocation(cid, b[2])
                        doPlayerAddItem(cid, a1, 1)
                        doPlayerAddItem(cid, a2, cfg.count)
                        doTeleportThing(cid, cfg.newPos, false)
                        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
                    end
                end
            end
        end
    end
    return true
end

Code:
		<action itemid="5627" event="script" value="other/sorc.lua"/>
 
Back
Top