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

[Request] Help with onAdvance

Joined
Apr 17, 2008
Messages
1,922
Solutions
1
Reaction score
188
Location
Venezuela
Hello, i'm using TFS 0.3b2-gui

I have placed in my server the function "onAdvance", but this one does not work ... place the scripts as(according to) 4220niller, create the folder advances, place inside it the so called scripts: level, maglevel, fist, club, sword, fishing, distance, axe, shield.

In the folder of creaturescripts i created the file think.lua, place in lib/function.lua the lines specified for 4220niller, in end(purpose) I did everything what is needed in order that the function works...

Still this way scripts as this one they do not work:

creaturescripts/advances/level.lua
Code:
function onAdvance(cid, skill, oldlevel, newlevel)

local basesStorages = {
	local baseStrenght = 1000,
	local baseAgility = 1001,
	local baseVitality = 1002,
	local baseEnergy = 1003
}

local pointsPerLevel = 1
local checkStrenght = getPlayerStorageValue(cid, basesStorages.baseStrenght)
local checkAgility = getPlayerStorageValue(cid, basesStorages.baseAgility)
local checkVitality = getPlayerStorageValue(cid, basesStorages.baseVitality)
local checkEnergy = getPlayerStorageValue(cid, basesStorages.baseEnergy)

setPlayerStorageValue(cid, basesStorages.baseStrenght, checkStrenght+pointsPerLevel)
setPlayerStorageValue(cid, basesStorages.baseAgility, checkAgility+pointsPerLevel)
setPlayerStorageValue(cid, basesStorages.baseVitality, checkVitality+pointsPerLevel)
setPlayerStorageValue(cid, basesStorages.baseEnergy, checkEnergy+pointsPerLevel)

end

Why this function don't work for me?
What i need to write in creaturescripts.xml?

Can somebody make a guide "How to use onAdvance Function"?

Thanks

SORRY MY BAD ENGLISH, I'M USING A TRANSLATOR
 
1. You dont need niller's system

2. Add this to creaturescripts.xml:
PHP:
<event type="advance" name="advance" script="advance.lua"/>

Then open login.lua and add this below function:
PHP:
registerCreatureEvent(cid, "advance")

Reload creaturescripts and relog with any character!
 
Mmm.. and how i use the script only if the players up her level?

because i'm making a points system... for each level you gain 1 point...
 
Don't work :(

Look: This is my script:

Code:
function onAdvance(cid, skill, oldlevel, newlevel)

local pointsPerLevel = 1

local basesStorages = {
	baseStrenght = 1000,
	baseAgility = 1001,
	baseVitality = 1002,
	baseEnergy = 1003
}

local check = {
	Strenght = getPlayerStorageValue(cid, basesStorages.baseStrenght),
	Agility = getPlayerStorageValue(cid, basesStorages.baseAgility),
	Vitality = getPlayerStorageValue(cid, basesStorages.baseVitality),
	Energy = getPlayerStorageValue(cid, basesStorages.baseEnergy)
}

if skill == SKILL__LEVEL then

setPlayerStorageValue(cid, basesStorages.baseStrenght, check.Strenght+pointsPerLevel)
setPlayerStorageValue(cid, basesStorages.baseAgility, check.Agility+pointsPerLevel)
setPlayerStorageValue(cid, basesStorages.baseVitality, check.Vitality+pointsPerLevel)
setPlayerStorageValue(cid, basesStorages.baseEnergy, check.Energy+pointsPerLevel)
doSendMagicEffect(getCreaturePosition(cid), 15)

	end
end

In login.lua:
Code:
	registerCreatureEvent(cid, "advance")

in creaturescripts.xml:
Code:
	<event type="advance" name="advance" script="advance.lua"/>

Don't work and don't show any error in console
 
It is stupid.

Tell me where you will use this points (not set, use) and I will tell you how to implent it.

"pointsPerLevel * Level" instead of increase per advance!

Also if strength and agillity always increase by same number, they will always be the same. So there is no need to have many? OR is there other ways to gain them?

However, using level * the skill is best. Because you can also abuse this by dying several times and level back up to get a very high amount of points.
 
I use it something like this:

Code:
local basesStorages = {
	baseStamina = 1000,
	baseStaminaAdded = 1001,
	baseVitality = 1002,
	baseEnergy = 1003
}

local pointsPerLevel = 1
local checkStamina = getPlayerStorageValue(cid, basesStorages.baseStamina)
local checkStaminaAdded = getPlayerStorageValue(cid, basesStorages.baseStaminaAdded)
local checkVitality = getPlayerStorageValue(cid, basesStorages.baseVitality)
local checkEnergy = getPlayerStorageValue(cid, basesStorages.baseEnergy)

If i'm level 100 then i have 100 stamina, energy and vitality points.

you need a npc to add your points.I

If i've 100 points of vitality, that 100 points will set to your max health

for example:

Code:
Player: hi
Npc: Hello player!
Player: points
Npc: And what do you want add your points?.
Player: vitality
Npc: Do you want add 100 points to your vitality?
Player:Yes

setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+checkVitality)
setPlayerStorageValue(cid, basesStorages.baseVitality, 0)

^ use it with Energy too

Example of stamina
Code:
Player: hi
Npc: Hello player!
Player: points
Npc: And what do you want add your points?.
Player: stamina
Npc: Do you want add 100 points to your stamina?
Player:Yes

setPlayerStorageValue(cid, basesStorages.baseStaminaAdded, checkStaminaAdded+checkStamina)
setPlayerStorageValue(cid, basesStorages.baseStamina, 0)


And how use stamina?

I've changed the script of the potions.. with something like this:

Example: Ultimate health potion

Code:
local staminaFormula = checkStaminaAdded*2
if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 800, 1000+staminaFormula, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
 
Back
Top