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

Solved Vocation Upgrade Potion

Extrodus

|| Blazera.net ||
Premium User
Joined
Dec 22, 2008
Messages
2,740
Solutions
7
Reaction score
541
Location
Canada
I am trying to create a script that uses an item for promotion but I am getting an error; and the error doesn't even make sense since everything in the script is the same and using the same function.

Error:
Code:
[11/12/2013 01:11:01] [Error - Action Interface]
[11/12/2013 01:11:01] data/actions/scripts/war/donor_potion.lua:onUse
[11/12/2013 01:11:01] Description:
[11/12/2013 01:11:01] (luaDoPlayerRemoveItem) Player not found

Script:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
  
   voc = getPlayerVocation(cid)
   if voc == 1 then --Is sorcerer
   doPlayerSetVocation(cid,5) -- new sorcerer vocation
   doCreatureSay(cid, "You feel smarter.", TALKTYPE_ORANGE_1, cid)
   doPlayerRemoveItem(cid, 5080)
   elseif voc == 2 then -- is druid
   doPlayerSetVocation(cid,6) -- new druid vocation
   doCreatureSay(cid, "You feel smarter.", TALKTYPE_ORANGE_1, cid)
   doPlayerRemoveItem(cid, 5080)
   elseif voc == 3 then -- is paladin
   doPlayerSetVocation(cid,7) -- new paladin vocation
   doCreatureSay(cid, "You feel smarter.", TALKTYPE_ORANGE_1, cid)
   doPlayerRemoveItem(cid, 5080)
   elseif voc == 4 then -- is knight
   doPlayerSetVocation(cid,8) -- new knight vocation
   doCreatureSay(cid, "You feel smarter.", TALKTYPE_ORANGE_1, cid)
   doPlayerRemoveItem(cid, 5080)
   else
   doPlayerSendTextMessage(cid,19,"You do not need this potion.")
   end

   return true
end

Not the greatest script, but I am za beginner plix! At least I am trying right? Thanks in advance.


Solved thanks to Ninja (scroll down)
 
Last edited:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = {
    [1] = {newVoc = 5, msg = "smarter"}, -- Master Sorcerer
    [2] = {newVoc = 6, msg = "wiser"}, -- Elder Druid
    [3] = {newVoc = 7, msg = "steadier"}, -- Royal Paladin
    [4] = {newVoc = 8, msg = "stronger"} -- Elite Knight
} 
    voc = getPlayerVocation(cid)
    if v[voc] then
        local _v_ = v[voc]
        doPlayerSetVocation(cid,_v_.newVoc)
        doCreatureSay(cid, "You feel " .. _v_.msg .. ".", TALKTYPE_ORANGE_1)
    else
        doPlayerSendTextMessage(cid,19,"You do not need this potion.")
        return false
    end
return true
end
 
@Shinmaru - Thank you, but the item does not get removed. -doPlayerRemoveItem(cid, 5080)-

Also, once I relog the vocation is gone ;\
 
Just add doRemoveItem(item.uid, 1) below doCreatureSay~ :p

I don't have any issue with vocation disappearing, could you try purchasing promotion from an NPC?
 
Last edited:
Oh, thought this were about TFS 1.0. xd

Well, try with this.
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerPromotionLevel(cid) < 1 then
        doPlayerSetPromotionLevel(cid, 1)
        doCreatureSay(cid, "You feel smarter.", TALKTYPE_ORANGE_1)
        doRemoveItem(item.uid, 1)
    else
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You do not need this potion.")
    end
    return true
end
 
Haha, got to have multiple projects to keep us going right? Luls, I got projects coming out my butt; just non-stop trying to figure TFS out and build with it. Again, thank you so much - for like the 1000th time; You sir are a gem! It works like a charm now and saves the vocation!

Solved thanks to Ninja!
 
Last edited:
Back
Top