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

Change vocation when using an item

leokart7

New Member
Joined
Mar 19, 2015
Messages
46
Reaction score
0
I want to create an item that when a player uses it changes ones vocation
 
Last edited:
Code:
<action itemid="ITEMID" script="vocationitem.lua"/>

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    player:setVocation(VOCATIONID)
end
 
@Sizaro actually it didnt work :s it gave me the following when I tried to sue it!
[24/03/2015 18:42:33] [Error - Action Interface]
[24/03/2015 18:42:33] data/actions/scripts/assassin.lua: onUse
[24/03/2015 18:42:33] Description:
[24/03/2015 18:42:33] data/actions/scripts/assassin.lua:2: attempt to call global 'Player' (a nil value)
[24/03/2015 18:42:33] stack traceback:
[24/03/2015 18:42:33] data/actions/scripts/assassin.lua:2: in function <data/actions/scripts/assassin.lua:1>
 
Assuming 0.3.6 has the setPlayerVocation function, you could replace it with that.
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
setPlayerVocation(cid,vocationid)
doRemoveCreature(cid)
end

As far as I know, this should work to change their vocation and then log them out.
 
I'll see if I can use those functions on my server and I'll test and see what happens

Edit
Can't get it to work on my server like this, I'm running TFS 1.0.
 
Last edited:
@Limos
[29/03/2015 19:25:21] [Error - Action Interface]
[29/03/2015 19:25:21] data/actions/scripts/assasssin.lua:onUse
[29/03/2015 19:25:21] Description:
[29/03/2015 19:25:21] data/actions/scripts/assasssin.lua:2: attempt to call global 'setPlayerVocation' (a nil value)
[29/03/2015 19:25:21] stack traceback:
[29/03/2015 19:25:21] data/actions/scripts/assasssin.lua:2: in function <data/actions/scripts/assasssin.lua:1>
gave me this
 
@Limos its working in a certain way but it's not changing to the vocation I want. I wrote to change for vocation 14 but it goes to the 8th. Another problem im having is that when the item is used i want it to be destroyed.. how can I do that.. I tried doPlayerRemoveItem but if the item isnt in his backpack it wont change his vocation.
Right now my code is like this
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
doPlayerSetVocation(cid,14)
doPlayerRemoveItem(cid,2345)
doRemoveCreature(cid)
return true
end
 
If the vocation you want it to set to is a promoted vocation, you have to set their vocation to the unpromoted version and set their promotion to whatever promotion level it is (first, second, etc.) to destroy it, you can use a function to destroy the item that was used. I think it's doRemoveItem(uid)
 
Back
Top