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

Lua No promotion is saving! Help!

luccagomes

New Member
Joined
Jul 30, 2015
Messages
153
Reaction score
1
PROMOTE.LUA
NPC!!!


Code:
local config = {
   promote1 = 20000, -- preço da primeira promotion
   promote2 = 10000000, -- preço da segunda promotion
   rookPromote1 = {13, 10000}, -- {id da vocação, preço}
   rookPromote2 = {14, 5000000} -- {id da vocação, preço}
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid)   end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end

function creatureSayCallback(cid, type, msg)
   msg = string.lower(msg)
   local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
   
   if not npcHandler:isFocused(cid) then
     return false
   end

   local price
   if (getPlayerVocation(cid) >= 1 and getPlayerVocation(cid) <= 4) then
     price = 20000
   elseif (getPlayerVocation(cid) >= 5 and getPlayerVocation(cid) <= 8) then
     price = 10000000
   elseif (getPlayerVocation(cid) == 0) then
     price = 10000
   elseif (getPlayerVocation(cid) == 13) then
     price = 5000000
   end
   
   if msgcontains(msg, 'hi') then
     selfSay('Hello ' .. getPlayerName(cid) .. '! I sell promotions.')

     elseif msgcontains(msg, 'promotion') or msgcontains(msg, 'promote') then
     if (getPlayerLevel(cid) < 20 ) then
       npcHandler:say("You need level 20 to be promoted!", cid)
       return true
     end
     if getPlayerVocation(cid) == 0 or getPlayerVocation(cid) == config.rookPromote1[1] then
       npcHandler:say('Do you want to buy promotion for ' .. price .. ' gold coins?', cid)
       talkState[talkUser] = 2
     elseif getPlayerVocation(cid) > 8  and getPlayerVocation(cid) < config.rookPromote1[1] then
       selfSay('Sorry, you are already promoted.')
       talkState[talkUser] = 0
     elseif not isPremium(cid) and ((getPlayerVocation(cid) > 4 and getPlayerVocation(cid) < config.rookPromote1[1]) or getPlayerVocation(cid) == config.rookPromote1[1]) then
       selfSay('Sorry, you must be premium to buy promotion.')
       talkState[talkUser] = 0
     else
       selfSay('Do you want to buy promotion for ' .. price .. ' gold coins?')
       talkState[talkUser] = 1
     end

   elseif talkState[talkUser] == 1 then
     if msgcontains(msg, 'yes') then
       if doPlayerRemoveMoney(cid, price) then
         doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
         selfSay('You are now promoted!')
       else
         selfSay('Sorry, you do not have enough money.')
       end
     end
     talkState[talkUser] = 0

   elseif talkState[talkUser] == 2 then
     if getPlayerVocation(cid) == 0 then
       if doPlayerRemoveMoney(cid, config.rookPromote1[2]) then
         doPlayerSetVocation(cid, config.rookPromote1[1])
         selfSay('You are now promoted!')
       else
         selfSay('Sorry, you do not have enough money.')
       end
     elseif getPlayerVocation(cid) == config.rookPromote1[1] then
       if doPlayerRemoveMoney(cid, config.rookPromote2[2]) then
         doPlayerSetVocation(cid, config.rookPromote2[1])
         selfSay('You are now promoted!')
       else
         selfSay('Sorry, you do not have enough money.')
       end
     end
     talkState[talkUser] = 0

   elseif msgcontains(msg, 'bye') then
     selfSay('Good bye, ' .. getPlayerName(cid) .. '!')
     talkState[talkUser] = 0
   end   
   return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
VOCATIONS.XML
Code:
<?xml version="1.0" encoding="UTF-8"?>
<vocations>
  <vocation id="0" name="None" description="none" needpremium="0" gaincap="5" gainhp="5" gainmana="5" gainhpticks="2" gainhpamount="2" gainmanaticks="1" gainmanaamount="4" manamultiplier="4.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="0" attackable="yes">
  <formula meleeDamage="1.5" distDamage="1.5" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="4.0" fishing="2.2" experience="1.0"/>
  </vocation>
  <vocation id="1" name="Sorcerer" description="a sorcerer" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="3" gainhpamount="2" gainmanaticks="2" gainmanaamount="4" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="1">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="5.0" shielding="1.5" fishing="1.1" experience="1.0"/>
  </vocation>
  <vocation id="2" name="Druid" description="a druid" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="3" gainhpamount="2" gainmanaticks="2" gainmanaamount="4" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="2">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="0.8" magHealingDamage="1.2" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="5.0" shielding="1.5" fishing="1.1" experience="1.0"/>
  </vocation>
  <vocation id="3" name="Paladin" description="a paladin" needpremium="0" gaincap="20" gainhp="10" gainmana="15" gainhpticks="3" gainhpamount="3" gainmanaticks="2" gainmanaamount="3" manamultiplier="1.4" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="3">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="1.1" shielding="1.4" fishing="1.1" experience="1.0"/>
  </vocation>
  <vocation id="4" name="Knight" description="a knight" needpremium="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="3" gainhpamount="4" gainmanaticks="2" gainmanaamount="2" manamultiplier="3.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="4">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="1.1" sword="1.1" axe="1.1" distance="5.0" shielding="1.1" fishing="1.1" experience="1.0"/>
  </vocation>
  <!-- promote FREE -->
  <vocation id="5" name="Master Sorcerer" description="a master sorcerer" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="3" gainhpamount="3" gainmanaticks="2" gainmanaamount="5" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="1">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="5.0" shielding="1.5" fishing="1.1" experience="1.0"/>
  </vocation>
  <vocation id="6" name="Elder Druid" description="a elder druid" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="3" gainhpamount="3" gainmanaticks="2" gainmanaamount="5" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="2">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="0.8" magHealingDamage="1.2" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="5.0" shielding="1.5" fishing="1.1" experience="1.0"/>
  </vocation>
  <vocation id="7" name="Royal Paladin" description="a royal paladin" needpremium="0" gaincap="20" gainhp="10" gainmana="15" gainhpticks="3" gainhpamount="4" gainmanaticks="2" gainmanaamount="4" manamultiplier="1.4" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="3">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="1.1" shielding="1.4" fishing="1.1" experience="1.0"/>
  </vocation>
  <vocation id="8" name="Elite Knight" description="a elite knight" needpremium="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="3" gainhpamount="5" gainmanaticks="2" gainmanaamount="3" manamultiplier="3.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="4">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="1.1" sword="1.1" axe="1.1" distance="5.0" shielding="1.1" fishing="1.1" experience="1.0"/>
  </vocation>
  <!-- promote VIP -->
  <vocation id="9" name="Epic Sorcerer" description="a epic sorcerer" needpremium="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="3" gainhpamount="4" gainmanaticks="2" gainmanaamount="8" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="5">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="5.0" shielding="1.5" fishing="1.1" experience="1.0"/>
  </vocation>
  <vocation id="10" name="Epic Druid" description="a epic druid" needpremium="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="3" gainhpamount="4" gainmanaticks="2" gainmanaamount="8" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="6">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="0.8" magHealingDamage="1.2" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="5.0" shielding="1.5" fishing="1.1" experience="1.0"/>
  </vocation>
  <vocation id="11" name="Epic Paladin" description="a epic paladin" needpremium="1" gaincap="20" gainhp="10" gainmana="15" gainhpticks="3" gainhpamount="6" gainmanaticks="2" gainmanaamount="6" manamultiplier="1.4" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="7">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="1.1" shielding="1.4" fishing="1.1" experience="1.0"/>
  </vocation>
  <vocation id="12" name="Epic Knight" description="a epic knight" needpremium="1" gaincap="25" gainhp="15" gainmana="5" gainhpticks="3" gainhpamount="8" gainmanaticks="2" gainmanaamount="4" manamultiplier="3.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="8">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="1.1" sword="1.1" axe="1.1" distance="5.0" shielding="1.1" fishing="1.1" experience="1.0"/>
  </vocation>
  <!-- ROOK promotes -->
  <!-- free -->
  <vocation id="13" name="Rooker" description="rooker" needpremium="0" gaincap="5" gainhp="5" gainmana="5" gainhpticks="2" gainhpamount="3" gainmanaticks="1" gainmanaamount="5" manamultiplier="4.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="0" attackable="yes">
  <formula meleeDamage="1.5" distDamage="1.5" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="4.0" fishing="2.2" experience="1.0"/>
  </vocation>
  <!-- VIP -->
  <vocation id="14" name="Rookgaardian" description="rookgaardian" needpremium="1" gaincap="5" gainhp="5" gainmana="5" gainhpticks="2" gainhpamount="4" gainmanaticks="1" gainmanaamount="8" manamultiplier="4.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="13" attackable="yes">
  <formula meleeDamage="1.5" distDamage="1.5" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="4.0" fishing="2.2" experience="1.0"/>
  </vocation>
</vocations>
 
VOCATIONS.XML
Code:
<?xml version="1.0" encoding="UTF-8"?>
<vocations>
  <vocation id="0" name="None" description="none" needpremium="0" gaincap="5" gainhp="5" gainmana="5" gainhpticks="2" gainhpamount="2" gainmanaticks="1" gainmanaamount="4" manamultiplier="4.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="0" attackable="yes">
  <formula meleeDamage="1.5" distDamage="1.5" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="4.0" fishing="2.2" experience="1.0"/>
  </vocation>
  <vocation id="1" name="Sorcerer" description="a sorcerer" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="3" gainhpamount="2" gainmanaticks="2" gainmanaamount="4" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="1">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="5.0" shielding="1.5" fishing="1.1" experience="1.0"/>
  </vocation>
  <vocation id="2" name="Druid" description="a druid" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="3" gainhpamount="2" gainmanaticks="2" gainmanaamount="4" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="2">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="0.8" magHealingDamage="1.2" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="5.0" shielding="1.5" fishing="1.1" experience="1.0"/>
  </vocation>
  <vocation id="3" name="Paladin" description="a paladin" needpremium="0" gaincap="20" gainhp="10" gainmana="15" gainhpticks="3" gainhpamount="3" gainmanaticks="2" gainmanaamount="3" manamultiplier="1.4" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="3">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="1.1" shielding="1.4" fishing="1.1" experience="1.0"/>
  </vocation>
  <vocation id="4" name="Knight" description="a knight" needpremium="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="3" gainhpamount="4" gainmanaticks="2" gainmanaamount="2" manamultiplier="3.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="4">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="1.1" sword="1.1" axe="1.1" distance="5.0" shielding="1.1" fishing="1.1" experience="1.0"/>
  </vocation>
  <!-- promote FREE -->
  <vocation id="5" name="Master Sorcerer" description="a master sorcerer" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="3" gainhpamount="3" gainmanaticks="2" gainmanaamount="5" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="1">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="5.0" shielding="1.5" fishing="1.1" experience="1.0"/>
  </vocation>
  <vocation id="6" name="Elder Druid" description="a elder druid" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="3" gainhpamount="3" gainmanaticks="2" gainmanaamount="5" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="2">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="0.8" magHealingDamage="1.2" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="5.0" shielding="1.5" fishing="1.1" experience="1.0"/>
  </vocation>
  <vocation id="7" name="Royal Paladin" description="a royal paladin" needpremium="0" gaincap="20" gainhp="10" gainmana="15" gainhpticks="3" gainhpamount="4" gainmanaticks="2" gainmanaamount="4" manamultiplier="1.4" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="3">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="1.1" shielding="1.4" fishing="1.1" experience="1.0"/>
  </vocation>
  <vocation id="8" name="Elite Knight" description="a elite knight" needpremium="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="3" gainhpamount="5" gainmanaticks="2" gainmanaamount="3" manamultiplier="3.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="4">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="1.1" sword="1.1" axe="1.1" distance="5.0" shielding="1.1" fishing="1.1" experience="1.0"/>
  </vocation>
  <!-- promote VIP -->
  <vocation id="9" name="Epic Sorcerer" description="a epic sorcerer" needpremium="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="3" gainhpamount="4" gainmanaticks="2" gainmanaamount="8" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="5">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="5.0" shielding="1.5" fishing="1.1" experience="1.0"/>
  </vocation>
  <vocation id="10" name="Epic Druid" description="a epic druid" needpremium="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="3" gainhpamount="4" gainmanaticks="2" gainmanaamount="8" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="6">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="0.8" magHealingDamage="1.2" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="5.0" shielding="1.5" fishing="1.1" experience="1.0"/>
  </vocation>
  <vocation id="11" name="Epic Paladin" description="a epic paladin" needpremium="1" gaincap="20" gainhp="10" gainmana="15" gainhpticks="3" gainhpamount="6" gainmanaticks="2" gainmanaamount="6" manamultiplier="1.4" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="7">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="1.1" shielding="1.4" fishing="1.1" experience="1.0"/>
  </vocation>
  <vocation id="12" name="Epic Knight" description="a epic knight" needpremium="1" gaincap="25" gainhp="15" gainmana="5" gainhpticks="3" gainhpamount="8" gainmanaticks="2" gainmanaamount="4" manamultiplier="3.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="8">
  <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="1.1" sword="1.1" axe="1.1" distance="5.0" shielding="1.1" fishing="1.1" experience="1.0"/>
  </vocation>
  <!-- ROOK promotes -->
  <!-- free -->
  <vocation id="13" name="Rooker" description="rooker" needpremium="0" gaincap="5" gainhp="5" gainmana="5" gainhpticks="2" gainhpamount="3" gainmanaticks="1" gainmanaamount="5" manamultiplier="4.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="0" attackable="yes">
  <formula meleeDamage="1.5" distDamage="1.5" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="4.0" fishing="2.2" experience="1.0"/>
  </vocation>
  <!-- VIP -->
  <vocation id="14" name="Rookgaardian" description="rookgaardian" needpremium="1" gaincap="5" gainhp="5" gainmana="5" gainhpticks="2" gainhpamount="4" gainmanaticks="1" gainmanaamount="8" manamultiplier="4.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="13" attackable="yes">
  <formula meleeDamage="1.5" distDamage="1.5" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
  <skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="4.0" fishing="2.2" experience="1.0"/>
  </vocation>
</vocations>
What TFS do you use? It promotes in-game, but after relog you lose promotion or it does not promote at all?
 
0.4 (8.60) r3777

NPC add all promotes, but all promotes, when u relog u lose :(
HOW IT SHOULD WORK:
For test you can try to replace:
PHP:
doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
with:
PHP:
doPlayerSetPromotionLevel(cid, getPlayerPromotionLevel(cid)+ 1)
because in TFS 0.4 they tried to make more then 1 promotion possible (on RL tibia only one). Maybe there is some bug and you need to use 'setPromotion' instead of 'setVocation'.
1 -> 5 (first promotion)
5 -> 9 (second promotion)

so player with vocation '9' in database table `players` should have:
vocation: 1
promotion: 2

It's based on 'fromvoc' parameter from vocations.xml.

FAST FIX:
Other way is to set 'fromvoc' 9-12 for vocations 9-12 in vocations.xml, but then you need to add them in spells/movements (by default promoted vocations got access to all spells/items for lower 'promotion level' vocations).
You can easily add new vocations to .xml files by 1 click with Notepad++. Don't do it by copy and paste :P
 
@Gesior.pl

Ty you so much

I put it now and work
but have a problem:
If i buy premmy and my premium end i dont lose premium promote :(

Code:
local config = {
  promote1 = 20000, -- preço da primeira promotion
  promote2 = 10000000, -- preço da segunda promotion
  rookPromote1 = {13, 10000}, -- {id da vocação, preço}
  rookPromote2 = {14, 5000000} -- {id da vocação, preço}
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid)  end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end

function creatureSayCallback(cid, type, msg)
  msg = string.lower(msg)
  local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
   
  if not npcHandler:isFocused(cid) then
  return false
  end

  local price
  if (getPlayerVocation(cid) >= 1 and getPlayerVocation(cid) <= 4) then
  price = 20000
  elseif (getPlayerVocation(cid) >= 5 and getPlayerVocation(cid) <= 8) then
  price = 10000000
  elseif (getPlayerVocation(cid) == 0) then
  price = 10000
  elseif (getPlayerVocation(cid) == 13) then
  price = 5000000
  end
   
  if msgcontains(msg, 'hi') then
  selfSay('Hello ' .. getPlayerName(cid) .. '! I sell promotions.')

  elseif msgcontains(msg, 'promotion') or msgcontains(msg, 'promote') then
  if (getPlayerLevel(cid) < 20 ) then
  npcHandler:say("You need level 20 to be promoted!", cid)
  return true
  end
  if getPlayerVocation(cid) == 0 or getPlayerVocation(cid) == config.rookPromote1[1] then
  npcHandler:say('Do you want to buy promotion for ' .. price .. ' gold coins?', cid)
  talkState[talkUser] = 2
  elseif getPlayerVocation(cid) > 8  and getPlayerVocation(cid) < config.rookPromote1[1] then
  selfSay('Sorry, you are already promoted.')
  talkState[talkUser] = 0
  elseif not isPremium(cid) and ((getPlayerVocation(cid) > 4 and getPlayerVocation(cid) < config.rookPromote1[1]) or getPlayerVocation(cid) == config.rookPromote1[1]) then
  selfSay('Sorry, you must be premium to buy promotion.')
  talkState[talkUser] = 0
  else
  selfSay('Do you want to buy promotion for ' .. price .. ' gold coins?')
  talkState[talkUser] = 1
  end

  elseif talkState[talkUser] == 1 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveMoney(cid, price) then
  doPlayerSetPromotionLevel(cid, getPlayerPromotionLevel(cid) + 1)
  selfSay('You are now promoted!')
  else
  selfSay('Sorry, you do not have enough money.')
  end
  end
  talkState[talkUser] = 0

  elseif talkState[talkUser] == 2 then
  if getPlayerVocation(cid) == 0 then
  if doPlayerRemoveMoney(cid, config.rookPromote1[2]) then
  doPlayerSetPromotionLevel(cid, 1)
  selfSay('You are now promoted!')
  else
  selfSay('Sorry, you do not have enough money.')
  end
  elseif getPlayerVocation(cid) == config.rookPromote1[1] then
    if not isPremium(cid)
      selfSay('Sorry, you must be premium to buy promotion.')
      talkState[talkUser] = 0
       return 1
    end
  if doPlayerRemoveMoney(cid, config.rookPromote2[2]) then
  doPlayerSetPromotionLevel(cid, 2)
  selfSay('You are now promoted!')
  else
  selfSay('Sorry, you do not have enough money.')
  end
  end
  talkState[talkUser] = 0

  elseif msgcontains(msg, 'bye') then
  selfSay('Good bye, ' .. getPlayerName(cid) .. '!')
  talkState[talkUser] = 0
  end   
  return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
@Gesior.pl

Ty you so much

I put it now and work
but have a problem:
If i buy premmy and my premium end i dont lose premium promote :(

Code:
local config = {
  promote1 = 20000, -- preço da primeira promotion
  promote2 = 10000000, -- preço da segunda promotion
  rookPromote1 = {13, 10000}, -- {id da vocação, preço}
  rookPromote2 = {14, 5000000} -- {id da vocação, preço}
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid)  end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end

function creatureSayCallback(cid, type, msg)
  msg = string.lower(msg)
  local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  
  if not npcHandler:isFocused(cid) then
  return false
  end

  local price
  if (getPlayerVocation(cid) >= 1 and getPlayerVocation(cid) <= 4) then
  price = 20000
  elseif (getPlayerVocation(cid) >= 5 and getPlayerVocation(cid) <= 8) then
  price = 10000000
  elseif (getPlayerVocation(cid) == 0) then
  price = 10000
  elseif (getPlayerVocation(cid) == 13) then
  price = 5000000
  end
  
  if msgcontains(msg, 'hi') then
  selfSay('Hello ' .. getPlayerName(cid) .. '! I sell promotions.')

  elseif msgcontains(msg, 'promotion') or msgcontains(msg, 'promote') then
  if (getPlayerLevel(cid) < 20 ) then
  npcHandler:say("You need level 20 to be promoted!", cid)
  return true
  end
  if getPlayerVocation(cid) == 0 or getPlayerVocation(cid) == config.rookPromote1[1] then
  npcHandler:say('Do you want to buy promotion for ' .. price .. ' gold coins?', cid)
  talkState[talkUser] = 2
  elseif getPlayerVocation(cid) > 8  and getPlayerVocation(cid) < config.rookPromote1[1] then
  selfSay('Sorry, you are already promoted.')
  talkState[talkUser] = 0
  elseif not isPremium(cid) and ((getPlayerVocation(cid) > 4 and getPlayerVocation(cid) < config.rookPromote1[1]) or getPlayerVocation(cid) == config.rookPromote1[1]) then
  selfSay('Sorry, you must be premium to buy promotion.')
  talkState[talkUser] = 0
  else
  selfSay('Do you want to buy promotion for ' .. price .. ' gold coins?')
  talkState[talkUser] = 1
  end

  elseif talkState[talkUser] == 1 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveMoney(cid, price) then
  doPlayerSetPromotionLevel(cid, getPlayerPromotionLevel(cid) + 1)
  selfSay('You are now promoted!')
  else
  selfSay('Sorry, you do not have enough money.')
  end
  end
  talkState[talkUser] = 0

  elseif talkState[talkUser] == 2 then
  if getPlayerVocation(cid) == 0 then
  if doPlayerRemoveMoney(cid, config.rookPromote1[2]) then
  doPlayerSetPromotionLevel(cid, 1)
  selfSay('You are now promoted!')
  else
  selfSay('Sorry, you do not have enough money.')
  end
  elseif getPlayerVocation(cid) == config.rookPromote1[1] then
    if not isPremium(cid)
      selfSay('Sorry, you must be premium to buy promotion.')
      talkState[talkUser] = 0
       return 1
    end
  if doPlayerRemoveMoney(cid, config.rookPromote2[2]) then
  doPlayerSetPromotionLevel(cid, 2)
  selfSay('You are now promoted!')
  else
  selfSay('Sorry, you do not have enough money.')
  end
  end
  talkState[talkUser] = 0

  elseif msgcontains(msg, 'bye') then
  selfSay('Good bye, ' .. getPlayerName(cid) .. '!')
  talkState[talkUser] = 0
  end  
  return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
It's like that in rl tibia, If you buy premium and promote yourself, You will still keep your promotion if your premium ends.
 
It's like that in rl tibia, If you buy premium and promote yourself, You will still keep your promotion if your premium ends.
Not quite.
You'll keep the promotion, but lose access to the promotion

Knight + premmy = Knight
Knight + no premmy = Knight
Knight + promote + premmy = Elite Knight
Knight + promote + no premmy = Knight
 
Not quite.
You'll keep the promotion, but lose access to the promotion

Knight + premmy = Knight
Knight + no premmy = Knight
Knight + promote + premmy = Elite Knight
Knight + promote + no premmy = Knight
Oh, Sorry. ;P didn't know. hehe. :P
 
Not quite.
You'll keep the promotion, but lose access to the promotion

Knight + premmy = Knight
Knight + no premmy = Knight
Knight + promote + premmy = Elite Knight
Knight + promote + no premmy = Knight

Yeah, ty

But why dont unpromote?
I put needpremium in vocations.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<vocations>
<vocation id="0" name="None" description="none" needpremium="0" gaincap="5" gainhp="5" gainmana="5" gainhpticks="2" gainhpamount="2" gainmanaticks="1" gainmanaamount="4" manamultiplier="4.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="0" attackable="yes">
<formula meleeDamage="1.5" distDamage="1.5" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="4.0" fishing="2.2" experience="1.0"/>
</vocation>
<vocation id="1" name="Sorcerer" description="a sorcerer" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="3" gainhpamount="2" gainmanaticks="2" gainmanaamount="4" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="1">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="5.0" shielding="1.5" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="2" name="Druid" description="a druid" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="3" gainhpamount="2" gainmanaticks="2" gainmanaamount="4" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="2">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="0.8" magHealingDamage="1.2" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="5.0" shielding="1.5" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="3" name="Paladin" description="a paladin" needpremium="0" gaincap="20" gainhp="10" gainmana="15" gainhpticks="3" gainhpamount="3" gainmanaticks="2" gainmanaamount="3" manamultiplier="1.4" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="3">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="1.1" shielding="1.4" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="4" name="Knight" description="a knight" needpremium="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="3" gainhpamount="4" gainmanaticks="2" gainmanaamount="2" manamultiplier="3.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="4">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.5" club="1.1" sword="1.1" axe="1.1" distance="5.0" shielding="1.1" fishing="1.1" experience="1.0"/>
</vocation>
<!-- promote FREE -->
<vocation id="5" name="Master Sorcerer" description="a master sorcerer" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="3" gainhpamount="3" gainmanaticks="2" gainmanaamount="5" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="1">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="5.0" shielding="1.5" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="6" name="Elder Druid" description="a elder druid" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="3" gainhpamount="3" gainmanaticks="2" gainmanaamount="5" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="2">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="0.8" magHealingDamage="1.2" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="5.0" shielding="1.5" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="7" name="Royal Paladin" description="a royal paladin" needpremium="0" gaincap="20" gainhp="10" gainmana="15" gainhpticks="3" gainhpamount="4" gainmanaticks="2" gainmanaamount="4" manamultiplier="1.4" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="3">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="1.1" shielding="1.4" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="8" name="Elite Knight" description="a elite knight" needpremium="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="3" gainhpamount="5" gainmanaticks="2" gainmanaamount="3" manamultiplier="3.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="4">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.5" club="1.1" sword="1.1" axe="1.1" distance="5.0" shielding="1.1" fishing="1.1" experience="1.0"/>
</vocation>
<!-- promote VIP -->
<vocation id="9" name="Epic Sorcerer" description="a epic sorcerer" needpremium="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="3" gainhpamount="4" gainmanaticks="2" gainmanaamount="8" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="5">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="5.0" shielding="1.5" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="10" name="Epic Druid" description="a epic druid" needpremium="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="3" gainhpamount="4" gainmanaticks="2" gainmanaamount="8" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="6">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="0.8" magHealingDamage="1.2" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="5.0" shielding="1.5" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="11" name="Epic Paladin" description="a epic paladin" needpremium="1" gaincap="20" gainhp="10" gainmana="15" gainhpticks="3" gainhpamount="6" gainmanaticks="2" gainmanaamount="6" manamultiplier="1.4" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="7">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.5" club="5.0" sword="5.0" axe="5.0" distance="1.1" shielding="1.4" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="12" name="Epic Knight" description="a epic knight" needpremium="1" gaincap="25" gainhp="15" gainmana="5" gainhpticks="3" gainhpamount="8" gainmanaticks="2" gainmanaamount="4" manamultiplier="3.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="8">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.5" club="1.1" sword="1.1" axe="1.1" distance="5.0" shielding="1.1" fishing="1.1" experience="1.0"/>
</vocation>
<!-- ROOK promotes -->
<!-- free -->
<vocation id="13" name="Rooker" description="rooker" needpremium="0" gaincap="5" gainhp="5" gainmana="5" gainhpticks="2" gainhpamount="3" gainmanaticks="1" gainmanaamount="5" manamultiplier="4.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="0" attackable="yes">
<formula meleeDamage="1.5" distDamage="1.5" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="4.0" fishing="2.2" experience="1.0"/>
</vocation>
<!-- VIP -->
<vocation id="14" name="Rookgaardian" description="rookgaardian" needpremium="1" gaincap="5" gainhp="5" gainmana="5" gainhpticks="2" gainhpamount="4" gainmanaticks="1" gainmanaamount="8" manamultiplier="4.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="13" attackable="yes">
<formula meleeDamage="1.5" distDamage="1.5" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="4.0" fishing="2.2" experience="1.0"/>
</vocation>
</vocations>
 
SJzQVSO.png


Code:
local config = {
  promote1 = 20000, -- preço da primeira promotion
  promote2 = 10000000, -- preço da segunda promotion
  rookPromote1 = {13, 10000}, -- {id da vocação, preço}
  rookPromote2 = {14, 5000000} -- {id da vocação, preço}
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid)  end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end

function creatureSayCallback(cid, type, msg)
  msg = string.lower(msg)
  local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
   
  if not npcHandler:isFocused(cid) then
  return false
  end

  local price
  if (getPlayerVocation(cid) >= 1 and getPlayerVocation(cid) <= 4) then
  price = 20000
  elseif (getPlayerVocation(cid) >= 5 and getPlayerVocation(cid) <= 8) then
  price = 10000000
  elseif (getPlayerVocation(cid) == 0) then
  price = 10000
  elseif (getPlayerVocation(cid) == 13) then
  price = 5000000
  end
   
  if msgcontains(msg, 'hi') then
  selfSay('Hello ' .. getPlayerName(cid) .. '! I sell promotions.')

  elseif msgcontains(msg, 'promotion') or msgcontains(msg, 'promote') then
  if (getPlayerLevel(cid) < 20 ) then
  npcHandler:say("You need level 20 to be promoted!", cid)
  return true
  end
  if getPlayerVocation(cid) == 0 or getPlayerVocation(cid) == config.rookPromote1[1] then
  npcHandler:say('Do you want to buy promotion for ' .. price .. ' gold coins?', cid)
  talkState[talkUser] = 2
  elseif getPlayerVocation(cid) > 8  and getPlayerVocation(cid) < config.rookPromote1[1] then
  selfSay('Sorry, you are already promoted.')
  talkState[talkUser] = 0
  elseif not isPremium(cid) and ((getPlayerVocation(cid) > 4 and getPlayerVocation(cid) < config.rookPromote1[1]) or getPlayerVocation(cid) == config.rookPromote1[1]) then
  selfSay('Sorry, you must be premium to buy promotion.')
  talkState[talkUser] = 0
  else
  selfSay('Do you want to buy promotion for ' .. price .. ' gold coins?')
  talkState[talkUser] = 1
  end

  elseif talkState[talkUser] == 1 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveMoney(cid, price) then
  doPlayerSetPromotionLevel(cid, getPlayerPromotionLevel(cid) + 1)
  selfSay('You are now promoted!')
  else
  selfSay('Sorry, you do not have enough money.')
  end
  end
  talkState[talkUser] = 0

  elseif talkState[talkUser] == 2 then
  if getPlayerVocation(cid) == 0 then
  if doPlayerRemoveMoney(cid, config.rookPromote1[2]) then
  doPlayerSetPromotionLevel(cid, 1)
  selfSay('You are now promoted!')
  else
  selfSay('Sorry, you do not have enough money.')
  end
  elseif getPlayerVocation(cid) == config.rookPromote1[1] then
  if not isPremium(cid)
  selfSay('Sorry, you must be premium to buy promotion.')
  talkState[talkUser] = 0
  return 1
  end
  if doPlayerRemoveMoney(cid, config.rookPromote2[2]) then
  doPlayerSetPromotionLevel(cid, 2)
  selfSay('You are now promoted!')
  else
  selfSay('Sorry, you do not have enough money.')
  end
  end
  talkState[talkUser] = 0

  elseif msgcontains(msg, 'bye') then
  selfSay('Good bye, ' .. getPlayerName(cid) .. '!')
  talkState[talkUser] = 0
  end   
  return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
@luccagomes
What if u make a function onLogin?
A function that checks if player are premium when log in...
Something like that:
Code:
function onLogin(cid)

  if not isPremium(cid) and (getPlayerVocation(cid) >= 9 and getPlayerVocation(cid) <= 12)
  doPlayerSetPromotionLevel(cid, getPlayerPromotionLevel(cid) - 4)
  end

end

[I will not explain the code since i think u can do it urself (tell me if u do not understand)]

Put this code on movements/scripts
and movements.xml:
Code:
<event type="login" name="urcodename" script="urcodename.lua"/>

EDIT: I am not a programmer or something like that, i would appreciate if some better guy check if my code are right!

EDIT2: if doPlayerSetPromotionLevel(cid, getPlayerPromotionLevel(cid) - 4) do not work, change it to:
doPlayerSetVocation(cid, getPlayerVocation(cid) - 4).

Than it should be:

Code:
function onLogin(cid)

  if not isPremium(cid) and (getPlayerVocation(cid) >= 9 and getPlayerVocation(cid) <= 12) then
  doPlayerSetVocation(cid, getPlayerVocation(cid) - 4)
  end

end
 
Last edited:
Back
Top