• 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 Reward XP percentage?

highclick

New Member
Joined
Mar 21, 2011
Messages
80
Reaction score
4
What is up community!

Is it possible to reward a certain % XP instead of a fixed amount of XP?

Example: Finish a quest and get 23% XP instead of 131323 amount of XP

TFS: 0.3.6

Thank you!
 
Ive never created a script like this, but ill give you a little hint on how it Should look like


Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
doPlayerAddExperience(cid, getPlayerExperience(cid) * 0.30) --- Write 30 if you want it to be 30%
doCreatureSay(cid, "You have recieved ".. getPlayerExperience(cid) * 0.30.." Experience points!", 19)
return true
end

@highclick
Updated the post, use this instead.
 
Last edited:
This script:


PHP:
    if string.lower(msg) == "xp" then
        doPlayerAddExperience(cid, getPlayerExperience(cid)*0.3)
        selfSay("Here you go noob", cid)
    end

Is giving WAY more than 30%, it gives about 2 levels.

Could it be that "getPlayerExperience(cid)*0.3" gives 30% of your TOTAL experience?
 
My bad, its * yeah. I was kinda confused about the / or *. Thanks for correcting me
You can also do it with /, for 23% it's most easy to do * 0.23, else you have to do /4.347826086956522.
This script:


PHP:
    if string.lower(msg) == "xp" then
        doPlayerAddExperience(cid, getPlayerExperience(cid)*0.3)
        selfSay("Here you go noob", cid)
    end

Is giving WAY more than 30%, it gives about 2 levels.

Could it be that "getPlayerExperience(cid)*0.3" gives 30% of your TOTAL experience?
It does do that, I assumed that is what you ment, if it should give a % of a different amount of exp, you can do that * 0.3
 
You can also do it with /, for 23% it's most easy to do * 0.23, else you have to do /4.347826086956522.

It does do that, I assumed that is what you ment, if it should give a % of a different amount of exp, you can do that * 0.3


It's supposte too give % of the XP needed from lvl a to b.

For example, you need 1.000 XP from level 1-2. You get 30% of that = 300XP
 
It's supposte too give % of the XP needed from lvl a to b.

For example, you need 1.000 XP from level 1-2. You get 30% of that = 300XP
Oh, then the script is gonna be like this.
Code:
doPlayerAddExperience(cid, getPlayerLevel(cid) * 0.3)
Test it out and post back here
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    doPlayerAddExperience(cid, getExperienceForLevel(getPlayerLevel(cid) + 1) * .23)
    doCreatureSay(cid, "You have recieved ".. (getExperienceForLevel(getPlayerLevel(cid) + 1) * .23) .." Experience points!", 19)
return true
end
 
Code:
doPlayerAddExperience(cid, (getExperienceForLevel(getPlayerLevel(cid)+1) - getExperienceForLevel(getPlayerLevel(cid))) * 0.3)
 
Back
Top Bottom