• 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 Promotion_OnAdvance [worth to see it]

hodleo

Formerly cbrm -Crypto enthusiast, Retired scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,598
Solutions
3
Reaction score
955
Location
Caribbean Sea
:ninja:Another simple script. For those who prefer to give the promo in an unusual way...
(> Author: Cybermaster
(> Revised by: Shawak
(> Scripted in: TFS 0.3.6pl1


FEATURES
~Adds the vocation promotion to the player when he first reaches the configured level.
~Displays a configurable message with the new vocation name.
~Amazing effects when obtaining the new vocation(worth to see it!)
~Restores the player's health and mana when he gets the promotion.
~Saves the character's data too.
~May be useful for War ot's, I guess...


SETUP

1) Create the file "advpromo.lua" at data/creaturescripts/scripts
(> [ "advpromo.lua" ]
Lua:
--[[    
         Promotion_OnAdvance
        |-------------------|
        (> Author: Cybermaster
        (> Revised by: Shawak
        (> Scripted in: TFS 0.3.6pl1
        (> [url=http://www.otland.net]OtLand[/url]      
--]]

function onAdvance(cid, skill, oldLevel, newLevel)

local _SETUP = {
        level = 30,                             --level where the player will obtain the promotion when he reaches it
        type = MESSAGE_STATUS_CONSOLE_ORANGE,   --the message class
        text = "You have just been promoted to " .. getPlayerVocationName(cid) .."!",
        effect = 37                             --the effect for the leveling up animation
}

        if skill == SKILL__LEVEL and newLevel < _SETUP.level then
                return true
        end

        if getPlayerPromotionLevel(cid) ~= 0 then
                return true
        end

        local p = getPlayerPosition(cid)

        local positions = {
                { pos= {x=p.x+1,y=p.y,z=p.z}, delay = 100, delay2 = 900},
                { pos= {x=p.x+1,y=p.y+1,z=p.z}, delay = 200, delay2 = 980},
                { pos= {x=p.x,y=p.y+1,z=p.z}, delay = 300, delay2 = 1060},
                { pos= {x=p.x-1,y=p.y+1,z=p.z}, delay = 400, delay2 = 1140},
                { pos= {x=p.x-1,y=p.y,z=p.z}, delay = 500, delay2 = 1220},
                { pos= {x=p.x-1,y=p.y-1,z=p.z}, delay = 600, delay2 = 1300},
                { pos= {x=p.x,y=p.y-1,z=p.z}, delay = 700, delay2 = 1380},
                { pos= {x=p.x+1,y=p.y-1,z=p.z}, delay = 800, delay2 = 1460}
        }

        for i = 1, 8 do
                addEvent(doSendDistanceShoot, positions[i].delay, positions[i].pos, p, _SETUP.effect)
                addEvent(doSendDistanceShoot, positions[i].delay2, positions[i].pos, p, _SETUP.effect)
        end

        addEvent(doSendMagicEffect, 900, p, 49)
        setPlayerPromotionLevel(cid, 1)
        doPlayerSendTextMessage(cid, _SETUP.type, _SETUP.text)
        doSendAnimatedText(p, "Promoted!", math.random(1,255))
        doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
        doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
        doPlayerSave(cid, true)
        return true
end

2) Add this line to data/creaturescripts/creaturescripts.xml
Lua:
<event type="advance" name="Promo" script="advpromo.lua"/>

3) Add this line to data/creaturescripts/scripts/login.lua
Lua:
registerCreatureEvent(cid, "Promo")

Enjoy! Please report bugs and other issues.
You may Rep++ [
reputation.gif
] me in exchange.:peace:
 
Last edited:
Why did you put _ in front of variables?
_SETUP..
preference lol it can be almost anything, why do you ask?
wont harm the script;)
 
How do you know what "id" of vocation the player is getting when advanced?
 
in tfs 0.3? why should i know it?
 
So, if this is right. A player get's an promotion .. Can it be a custom vocation or is it as; Paladin -> Royal Paladin automatic?
 
Cyb3rmastr what you done?
I fixed it for you and you destroyed the script agian :(.

Lua:
--[[    
         Promotion_OnAdvance
        |-------------------|
        (> Author: Cybermaster
        (> Revised by: Shawak
        (> Scripted in: TFS 0.3.6pl1
        (> [url=http://www.otland.net]OtLand[/url]      
--]]

function onAdvance(cid, skill, oldLevel, newLevel)

local _SETUP = {
	level = 30, 				--level where the player will obtain the promotion when he reaches it
	type = MESSAGE_STATUS_CONSOLE_ORANGE,   --the message class
	text = "You have just been promoted to " .. getPlayerVocationName(cid) .."!",
	effect = 37 				--the effect for the leveling up animation
}

	if skill == SKILL__LEVEL and newLevel < _SETUP.level then
		return true
	end

	if getPlayerPromotionLevel(cid) ~= 0 then
		return true
	end

	local p = getPlayerPosition(cid)

	local positions = {
		{ pos= {x=p.x+1,y=p.y,z=p.z}, delay = 100, delay2 = 900},
		{ pos= {x=p.x+1,y=p.y+1,z=p.z}, delay = 200, delay2 = 980},
		{ pos= {x=p.x,y=p.y+1,z=p.z}, delay = 300, delay2 = 1060},
		{ pos= {x=p.x-1,y=p.y+1,z=p.z}, delay = 400, delay2 = 1140},
 		{ pos= {x=p.x-1,y=p.y,z=p.z}, delay = 500, delay2 = 1220},
		{ pos= {x=p.x-1,y=p.y-1,z=p.z}, delay = 600, delay2 = 1300},
		{ pos= {x=p.x,y=p.y-1,z=p.z}, delay = 700, delay2 = 1380},
		{ pos= {x=p.x+1,y=p.y-1,z=p.z}, delay = 800, delay2 = 1460}
	}

	for i = 1, 8 do
		addEvent(doSendDistanceShoot, positions[i].delay, positions[i].pos, p, _SETUP.effect)
		addEvent(doSendDistanceShoot, positions[i].delay2, positions[i].pos, p, _SETUP.effect)
	end

	addEvent(doSendMagicEffect, 900, p, 49)
	setPlayerPromotionLevel(cid, 1)
	doPlayerSendTextMessage(cid, _SETUP.type, _SETUP.text)
	doSendAnimatedText(p, "Promoted!", math.random(1,255))
	doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
	doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
	doPlayerSave(cid, true)
	return true
end
 
what do you mean, shawak?
 
Last edited:
what do you mean, shawak?

I mean this;
Lua:
if getPlayerPromotionLevel(cid) ~= 0 then
	return true
end
...
...
...
if getPlayerPromotionLevel(cid) == 0 then

-----------------

if skill == SKILL__LEVEL and newLevel < _SETUP.level then
	 return true
end
...
...
...
if skill == SKILL__LEVEL and newLevel >= _SETUP.level then
Repeating??!
 
yeah I know
everyone has a diff style of programming
 
@up lmao. And frankfarmer stfu, you were just thanking his ass for the script.

I see where your getting at with "your style" but...the best "style" is to optimize it as best as you can, you want the smallest script and greatest features. Smaller is better here.
 
yeh, I know
i dont care
 
Back
Top