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

CreatureEvent [TFS 1.2] Auto Promotion at Level Advance

Jeffro

Alpha
Joined
Jan 17, 2015
Messages
235
Reaction score
262
Location
New York
TFS 1.2 Tested
-Has no demotion compatibility, you can add that. You can add " or player:getLevel() <= 19" to login.lua, after "if player.isPremium()" on line 22. Not the best route though.
-Register event in creaturescripts.xml as "advance."

Code:
local config = {
  level = 20
}

function onAdvance(player, skill)
  local vocation = player:getVocation()
  local promotion = vocation:getPromotion()
  local vocName = player:getVocation():getName()
  if player:isPlayer() and skill == SKILL_LEVEL then
      if player:getLevel() == config.level then
          player:setVocation(promotion)
          player:sendTextMessage(MESSAGE_STATUS_WARNING, "You have gained an outstanding amount of experience.\nYou are now a " ..vocName.. ".", Player.getPosition())
     end
  end
end

[edit] Fixed a small bug with vocName
 
Last edited:
Pretty sure the game already has a feature to disable promotion if under level 20, not 100% sure though.
 
TFS 1.2 Tested
-Has no demotion compatibility, you can add that. You can add " or player:getLevel() <= 19" to login.lua, after "if player.isPremium()" on line 22. Not the best route though.
-Register event in creaturescripts.xml as "advance."

Code:
local config = {
  level = 20
}

function onAdvance(player, skill)
  local vocation = player:getVocation()
  local promotion = vocation:getPromotion()
  local vocName = player:getVocation():getName()
  if player:isPlayer() and skill == SKILL_LEVEL then
      if player:getLevel() == config.level then
          player:setVocation(promotion)
          player:sendTextMessage(MESSAGE_STATUS_WARNING, "You have gained an outstanding amount of experience.\nYou are now a " ..vocName.. ".", Player.getPosition())
     end
  end
end

[edit] Fixed a small bug with vocName

You Should set some storage so that if player downgrade to 19 then go up to 20.he doesn't get promoted again xD

Not sure about
Code:
player:getLevel() == 20
could they player hop from 19 to 21 o.o if not then that code is fine xD

Great job Mate!!:oops::oops:
 
You Should set some storage so that if player downgrade to 19 then go up to 20.he doesn't get promoted again xD

Not sure about
Code:
player:getLevel() == 20
could they player hop from 19 to 21 o.o if not then that code is fine xD

Great job Mate!!:oops::oops:
yeah, changing it to >= 20 and promotion would fix that
or >= 20 and (vocation:getId() % 4 < 4 and vocation:getId() / 4 <= 1)
 
You Should set some storage so that if player downgrade to 19 then go up to 20.he doesn't get promoted again xD

Not sure about
Code:
player:getLevel() == 20
could they player hop from 19 to 21 o.o if not then that code is fine xD

Great job Mate!!:oops::oops:
Yeah, all are valid points. Thanks for your criticism guys! I'll edit the script so I can fit in everything you guys mentioned.
 
Back
Top