• 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 How can i add 50% to this script?

1268995

Member
Joined
Sep 9, 2010
Messages
422
Reaction score
13
Hello, i have a very simple (noob) question.

In this script:

Code:
rate = 1.05
doPlayerSetExperienceRate(cid, rate)

Will make receive more 5% of exp.

How can i put to player receive 5% + 50% of xp?

I ask that because i have on my server a function that gives 50% more exp to player who are premium account.

Then, when when script gives more 5% exp, the script take off the 50% premium account receive...

So i want that player receive 50% because he is premium + 5% for using a item that gives him +5% exp.

Thanks for all!
 
How do you add the 5% experience?

This is just and example, you can replace condition1 and condition2 with the proper variables. Condition1 corresponds to the script that adds 5% exp bonus and Condition2 corresponds to premium player 50% bonus.

Code:
local rate = 1.05
local premRate = 1.50
local combinedRate = 1.55


function onLogin(cid)

    if (condition1 == true and condition2 == true) then  -- if they are Premium and they used the other EXP item
        doPlayerSetExperienceRate(cid, combinedRate)
    elseif condition1 == true then -- if they only used the EXP item
        doPlayerSetExperienceRate(cid, rate)
    elseif condition2 == true then -- if they are only premium
        doPlayerSetExperienceRate(cid, premRate)
    end
   
return true
end
 
something as simple as this could be used
Code:
local rates = {standard = 1, bonus = 0.05, prem = 0.50}
local bonus = true
function onLogin(cid)
    local p = getPlayerPremiumDays(cid)
    doPlayerSetExperienceRate(cid, rates.standard + (p > 0 and rates.prem or 0) + (bonus and rates.bonus or 0))
    return true
end
if bonus is triggered by a storage value or something, replace
Code:
local bonus = true
with
Code:
local bonus = getPlayerStorageValue(cid, xxxx)
and
Code:
(bonus and rates.bonus or 0)
with
Code:
(bonus == 1 and rates.bonus or 0)
etc.

Code:
local rates = {standard = 1, bonus = 0.05, prem = 0.50}
function onLogin(cid)
    local p = getPlayerPremiumDays(cid)
    local bonus = getPlayerStorageValue(cid, 1000)
    doPlayerSetExperienceRate(cid, rates.standard + (p > 0 and rates.prem or 0) + (bonus == 1 and rates.bonus or 0))
    return true
end
 
How do you add the 5% experience?

This is just and example, you can replace condition1 and condition2 with the proper variables. Condition1 corresponds to the script that adds 5% exp bonus and Condition2 corresponds to premium player 50% bonus.

Code:
local rate = 1.05
local premRate = 1.50
local combinedRate = 1.55


function onLogin(cid)

    if (condition1 == true and condition2 == true) then  -- if they are Premium and they used the other EXP item
        doPlayerSetExperienceRate(cid, combinedRate)
    elseif condition1 == true then -- if they only used the EXP item
        doPlayerSetExperienceRate(cid, rate)
    elseif condition2 == true then -- if they are only premium
        doPlayerSetExperienceRate(cid, premRate)
    end

return true
end
something as simple as this could be used
Code:
local rates = {standard = 1, bonus = 0.05, prem = 0.50}
local bonus = true
function onLogin(cid)
    local p = getPlayerPremiumDays(cid)
    doPlayerSetExperienceRate(cid, rates.standard + (p > 0 and rates.prem or 0) + (bonus and rates.bonus or 0))
    return true
end
if bonus is triggered by a storage value or something, replace
Code:
local bonus = true
with
Code:
local bonus = getPlayerStorageValue(cid, xxxx)
and
Code:
(bonus and rates.bonus or 0)
with
Code:
(bonus == 1 and rates.bonus or 0)
etc.

Code:
local rates = {standard = 1, bonus = 0.05, prem = 0.50}
function onLogin(cid)
    local p = getPlayerPremiumDays(cid)
    local bonus = getPlayerStorageValue(cid, 1000)
    doPlayerSetExperienceRate(cid, rates.standard + (p > 0 and rates.prem or 0) + (bonus == 1 and rates.bonus or 0))
    return true
end

Thanks for all codes, i will test thhem later, i am on class right now.

I just want to know if a detected a bug, because function 'onLogin' will only set player exp on player login. I mean, i maded a ring that add extra xp to player. So if player are using the ring when log in, will be added extra exp. But if he takes off the ring, the exp will not come back to normal xp. And more, even if xp somehow return to normal when he take off the ring, the player will not get extra exp if he equip the ring, because he are only giving extra xp when he logs in... my tought are correct?

EDIT: i will put here my codes that add extra exp:

creaturescript:
Code:
local expextra = 1.5 -- 50% de exp

function onLogin(cid)
         if isPremium(cid) == TRUE then
          doPlayerSetExperienceRate(cid,expextra)
          doPlayerSendTextMessage(cid,21,"u win 50% more exp for being premium!")
          else
              doPlayerSendTextMessage(cid,21,"get premium account and win more exp!")
end
return true
   end

movements:

Code:
function onEquip(cid, item, slot)

local rate = {}

if getPlayerLevel(cid) >= 1 then
rate = 1.05
end

doTransformItem(item.uid, 7697, 1)
doPlayerSendTextMessage(cid, 22, "U are using the exp ring and ur xp are rised to "..((rate - 1)*100).." %.")
doPlayerSetExperienceRate(cid, rate)
return true
end

function onDeEquip(cid, item, slot)
doTransformItem(item.uid, 7708, 1)
doPlayerSendTextMessage(cid, 22, "U removed the exp ring and ur xp back to normal.")
doPlayerSetExperienceRate(cid, 1.0)
return true
end
 
Last edited:
You need to set and reset the xp rate in movements not in login if your using an item to change the xp ratio.
 
You need to set and reset the xp rate in movements not in login if your using an item to change the xp ratio.

Maybe something like:

1- Onlogin gives 50% more exp to premium;
2- When equip ring and are premium, return experience to normal and give 55% exp;
3- When dequip ring and are premium, return experience to normal and just after that add 50% experience.
4- When equip ring again, return experience to normal + add 55%

What u guys think? If i am correct, ideas for the code?

EDIT: but u guys think it will bug if log in using the ring?
 
Code:
local xpStorage = 18000 -- change this to a storage value not used
local xpToAdd = 0.50

function onEquip(cid, item, slot)
    local rate = getPlayerExpRate(cid) + xpToAdd
    if getPlayerStorageValue(cid, xpStorage) == -1 then
        setPlayerStorageValue(cid, xpStorage, 1)
        doPlayerSetExperienceRate(cid, rate)
        doPlayerSendTextMessage(cid, 22, "You have gained "..(xpToAdd * 100).."% bonus exp!")
        doTransformItem(item.uid, 7697, 1)
    end
    return true
end

function onDeEquip(cid, item, slot)
    local rate = ((getPlayerExpRate(cid) - xpToAdd) <= 1) and 1 or getPlayerExpRate(cid) - xpToAdd
    if getPlayerStorageValue(cid, xpStorage) == 1 then
        doPlayerSetExperienceRate(cid, rate)
        setPlayerStorageValue(cid, xpStorage, -1)
        doTransformItem(item.uid, 7708, 1)
        doPlayerSendTextMessage(cid, 22, "Bounus xp has ended.")
    end
    return true
end
 
Last edited:
Code:
local xpStorage = 18000 -- change this to a storage value not used
local xpToAdd = 0.50

function onEquip(cid, item, slot)
    local rate = getPlayerExpRate(cid) + xpToAdd
    if getPlayerStorageValue(cid, xpStorage) == -1 then
        setPlayerStorageValue(cid, xpStorage, 1)
        doPlayerSetExperienceRate(cid, rate)
        doPlayerSendTextMessage(cid, 22, "You have gained "..(xpToAdd * 100).."% bonus exp!")
        doTransformItem(item.uid, 7697, 1)
    end
    return true
end

function onDeEquip(cid, item, slot)
    local rate = ((getPlayerExpRate(cid) - xpToAdd) <= 1) and 1 or getPlayerExpRate(cid) - xpToAdd
    if getPlayerStorageValue(cid, xpStorage) == 1 then
        doPlayerSetExperienceRate(cid, rate)
        setPlayerStorageValue(cid, xpStorage, -1)
        doTransformItem(item.uid, 7708, 1)
        doPlayerSendTextMessage(cid, 22, "Bounus xp has ended.")
    end
    return true
end

Appear this error:

Code:
[09/08/2015 17:27:45] [Error - MoveEvents Interface]
[09/08/2015 17:27:45] data/movements/scripts/exp_ring.lua:onEquip
[09/08/2015 17:27:45] Description:
[09/08/2015 17:27:45] data/movements/scripts/exp_ring.lua:27: attempt to call global 'getPlayerExpRate' (a nil value)
[09/08/2015 17:27:45] stack traceback:
[09/08/2015 17:27:45]    data/movements/scripts/exp_ring.lua:27: in function <data/movements/scripts/exp_ring.lua:26>

EDIT: line 26 = function onEquip(cid, item, slot)
I put -- on my old script, this way i can back using them if ur script do not work. That's the why line 26 are the beggining of ur script.
 
add this
Code:
function getPlayerExpRate(cid)
    return getPlayerRates(cid).experience
end

Code:
local xpStorage = 18000 -- change this to a storage value not used
local xpToAdd = 0.50

function onEquip(cid, item, slot)
    local rate = getPlayerExpRate(cid) + xpToAdd
    if getPlayerStorageValue(cid, xpStorage) == -1 then
        setPlayerStorageValue(cid, xpStorage, 1)
        doPlayerSetExperienceRate(cid, rate)
        doPlayerSendTextMessage(cid, 22, "You have gained "..(xpToAdd * 100).."% bonus exp!")
        doTransformItem(item.uid, 7697, 1)
    end
    return true
end

function onDeEquip(cid, item, slot)
    local rate = ((getPlayerExpRate(cid) - xpToAdd) <= 1) and 1 or getPlayerExpRate(cid) - xpToAdd
    if getPlayerStorageValue(cid, xpStorage) == 1 then
        doPlayerSetExperienceRate(cid, rate)
        setPlayerStorageValue(cid, xpStorage, -1)
        doTransformItem(item.uid, 7708, 1)
        doPlayerSendTextMessage(cid, 22, "Bounus xp has ended.")
    end
    return true
end

function getPlayerExpRate(cid)
    return getPlayerRates(cid).experience
end
 
Last edited by a moderator:
Code:
local xpStorage = 18000 -- change this to a storage value not used
local xpToAdd = 0.50

function onEquip(cid, item, slot)
    local rate = getPlayerExpRate(cid) + xpToAdd
    if getPlayerStorageValue(cid, xpStorage) == -1 then
        setPlayerStorageValue(cid, xpStorage, 1)
        doPlayerSetExperienceRate(cid, rate)
        doPlayerSendTextMessage(cid, 22, "You have gained "..(xpToAdd * 100).."% bonus exp!")
        doTransformItem(item.uid, 7697, 1)
    end
    return true
end

function onDeEquip(cid, item, slot)
    local rate = ((getPlayerExpRate(cid) - xpToAdd) <= 1) and 1 or getPlayerExpRate(cid) - xpToAdd
    if getPlayerStorageValue(cid, xpStorage) == 1 then
        doPlayerSetExperienceRate(cid, rate)
        setPlayerStorageValue(cid, xpStorage, -1)
        doTransformItem(item.uid, 7708, 1)
        doPlayerSendTextMessage(cid, 22, "Bounus xp has ended.")
    end
    return true
end

function getPlayerExpRate(cid)
    return getPlayerRates(cid).experience
end

Code:
[10/08/2015 09:25:06] [Error - MoveEvents Interface]
[10/08/2015 09:25:06] data/movements/scripts/exp_ring.lua:onEquip
[10/08/2015 09:25:06] Description:
[10/08/2015 09:25:06] data/movements/scripts/exp_ring.lua:27: attempt to perform arithmetic on a nil value
[10/08/2015 09:25:06] stack traceback:
[10/08/2015 09:25:06]    data/movements/scripts/exp_ring.lua:27: in function <data/movements/scripts/exp_ring.lua:26>

EDIT: line 26 = function onEquip(cid, item, slot)
 
I think it would help if we knew what distro / server version you are using
[11/08/2015 11:11:03] The Forgotten Server - Edited By Cyko V8, version 0.3.6 - Edited By Cyko V8 (Crying Damson - Edited By Cyko V8)
[11/08/2015 11:11:03] Compiled with GNU C++ version 3.4.5 (mingw special) at Apr 6 2013, 11:07:44.
 
Code:
local xpStorage = 18000 -- change this to a storage value not used
local xpToAdd = 0.50

function onEquip(cid, item, slot)
    local rate = getPlayerExpRate() + xpToAdd
    if getPlayerStorageValue(cid, xpStorage) == -1 then
        setPlayerStorageValue(cid, xpStorage, 1)
        doPlayerSetExperienceRate(cid, rate)
        doPlayerSendTextMessage(cid, 22, "You have gained "..(xpToAdd * 100).."% bonus exp!")
        doTransformItem(item.uid, 7697, 1)
    end
    return true
end

function onDeEquip(cid, item, slot)
    local rate = ((getPlayerExpRate() - xpToAdd) <= 1) and 1 or getPlayerExpRate() - xpToAdd
    if getPlayerStorageValue(cid, xpStorage) == 1 then
        doPlayerSetExperienceRate(cid, rate)
        setPlayerStorageValue(cid, xpStorage, -1)
        doTransformItem(item.uid, 7708, 1)
        doPlayerSendTextMessage(cid, 22, "Bounus xp has ended.")
    end
    return true
end

function getPlayerExpRate()
    return getConfigInfo('rateExperience')
end
 
Code:
local xpStorage = 18000 -- change this to a storage value not used
local xpToAdd = 0.50

function onEquip(cid, item, slot)
    local rate = getPlayerExpRate() + xpToAdd
    if getPlayerStorageValue(cid, xpStorage) == -1 then
        setPlayerStorageValue(cid, xpStorage, 1)
        doPlayerSetExperienceRate(cid, rate)
        doPlayerSendTextMessage(cid, 22, "You have gained "..(xpToAdd * 100).."% bonus exp!")
        doTransformItem(item.uid, 7697, 1)
    end
    return true
end

function onDeEquip(cid, item, slot)
    local rate = ((getPlayerExpRate() - xpToAdd) <= 1) and 1 or getPlayerExpRate() - xpToAdd
    if getPlayerStorageValue(cid, xpStorage) == 1 then
        doPlayerSetExperienceRate(cid, rate)
        setPlayerStorageValue(cid, xpStorage, -1)
        doTransformItem(item.uid, 7708, 1)
        doPlayerSendTextMessage(cid, 22, "Bounus xp has ended.")
    end
    return true
end

function getPlayerExpRate()
    return getConfigInfo('rateExperience')
end

I have stages exp.. <stage minlevel="1" maxlevel="100" multiplier="1"/>

So in level 1 to 100, player win normal exp like global tibia.

When i kill a wolf without putting the ring, it gives 18 exp.
When i kill a wolf with a ring i win 7209
When i remove the ring, wolf gives 7191..

The script should work like:
if free account:
Put the ring -> 18 (wolf exp) + 5% exp (bonus exp)
remove the ring -> 18 (wolf exp).

If player are premium then:
put the ring -> 18 (wolf exp) + 50% exp for being premium + 5% exp (bonus exp)
remove the ring -> 18 (wolf exp) + 50% exp for being premium.
 
I've done enough for you, your not even attempting to fix any of the code people are nice enough to write for you or even learn the framework or lua in general.. if it doesn't work then its your problem...
Code:
local xpStorage = 18000 -- change this to a storage value not used
local xpToAdd = 0.50

function onEquip(cid, item, slot)
    local rate = getPlayerExpRate(cid, true) + xpToAdd
    if getPlayerStorageValue(cid, xpStorage) == -1 then
        setPlayerStorageValue(cid, xpStorage, 1)
        doPlayerSetExperienceRate(cid, rate)
        doPlayerSendTextMessage(cid, 22, "You have gained "..(xpToAdd * 100).."% bonus exp!")
        doTransformItem(item.uid, 7697, 1)
    end
    return true
end

function onDeEquip(cid, item, slot)
    local rate = ((getPlayerExpRate(cid, true) - xpToAdd) <= 1) and 1 or getPlayerExpRate(cid, true) - xpToAdd
    if getPlayerStorageValue(cid, xpStorage) == 1 then
        doPlayerSetExperienceRate(cid, rate)
        setPlayerStorageValue(cid, xpStorage, -1)
        doTransformItem(item.uid, 7708, 1)
        doPlayerSendTextMessage(cid, 22, "Bounus xp has ended.")
    end
    return true
end

function getPlayerExpRate(cid, stages)
    if stages then
        return getExperienceStage(getPlayerLevel(cid), getVocationInfo(getPlayerVocation(cid)).experienceMultiplier)
    end
    return getConfigInfo('rateExperience')
end
 
I've done enough for you, your not even attempting to fix any of the code people are nice enough to write for you or even learn the framework or lua in general.. if it doesn't work then its your problem...
Code:
local xpStorage = 18000 -- change this to a storage value not used
local xpToAdd = 0.50

function onEquip(cid, item, slot)
    local rate = getPlayerExpRate(cid, true) + xpToAdd
    if getPlayerStorageValue(cid, xpStorage) == -1 then
        setPlayerStorageValue(cid, xpStorage, 1)
        doPlayerSetExperienceRate(cid, rate)
        doPlayerSendTextMessage(cid, 22, "You have gained "..(xpToAdd * 100).."% bonus exp!")
        doTransformItem(item.uid, 7697, 1)
    end
    return true
end

function onDeEquip(cid, item, slot)
    local rate = ((getPlayerExpRate(cid, true) - xpToAdd) <= 1) and 1 or getPlayerExpRate(cid, true) - xpToAdd
    if getPlayerStorageValue(cid, xpStorage) == 1 then
        doPlayerSetExperienceRate(cid, rate)
        setPlayerStorageValue(cid, xpStorage, -1)
        doTransformItem(item.uid, 7708, 1)
        doPlayerSendTextMessage(cid, 22, "Bounus xp has ended.")
    end
    return true
end

function getPlayerExpRate(cid, stages)
    if stages then
        return getExperienceStage(getPlayerLevel(cid), getVocationInfo(getPlayerVocation(cid)).experienceMultiplier)
    end
    return getConfigInfo('rateExperience')
end

Free player = script working!
Put the ring and the exp = 50%
remove the ring and the exp = normal exp

Premium ACC players = script NOT working!
A monster give 2000 exp with exprate 1x.
When i atack the monster withut putting the ring, exp = 4500
when i kil the monster with the ring, exp = 4500
EDIT: when i remove the ring and kill monster, exp = 3000

Dont forget about my other script with function onlogin

Code:
local expextra = 1.5 -- 50% de exp

function onLogin(cid)
      if isPremium(cid) == TRUE then
      doPlayerSetExperienceRate(cid,expextra)
      doPlayerSendTextMessage(cid,21,"Uget 50% more exp for being premiumm Account!")
   
      else
        doPlayerSendTextMessage(cid,21,"be premium to get more exp")
     
end
return true
  end

I've done enough for you, your not even attempting to fix any of the code people are nice enough to write for you or even learn the framework or lua in general.. if it doesn't work then its your problem...
Code:
local xpStorage = 18000 -- change this to a storage value not used
local xpToAdd = 0.50

function onEquip(cid, item, slot)
    local rate = getPlayerExpRate(cid, true) + xpToAdd
    if getPlayerStorageValue(cid, xpStorage) == -1 then
        setPlayerStorageValue(cid, xpStorage, 1)
        doPlayerSetExperienceRate(cid, rate)
        doPlayerSendTextMessage(cid, 22, "You have gained "..(xpToAdd * 100).."% bonus exp!")
        doTransformItem(item.uid, 7697, 1)
    end
    return true
end

function onDeEquip(cid, item, slot)
    local rate = ((getPlayerExpRate(cid, true) - xpToAdd) <= 1) and 1 or getPlayerExpRate(cid, true) - xpToAdd
    if getPlayerStorageValue(cid, xpStorage) == 1 then
        doPlayerSetExperienceRate(cid, rate)
        setPlayerStorageValue(cid, xpStorage, -1)
        doTransformItem(item.uid, 7708, 1)
        doPlayerSendTextMessage(cid, 22, "Bounus xp has ended.")
    end
    return true
end

function getPlayerExpRate(cid, stages)
    if stages then
        return getExperienceStage(getPlayerLevel(cid), getVocationInfo(getPlayerVocation(cid)).experienceMultiplier)
    end
    return getConfigInfo('rateExperience')
end

Buddy, i am ALLDAY making this script, I REALLY NEED HELP. I do not want u to make the script for me, sorry for that.
I made a script with what u sent me and i am really need to know what's going wrong.

Look: function onLogin -> will check if player are using the ring (player get a storage when equip the ring), if are using the ring, will set experience 50% for being premium + 10% for using the exp ring. If player are premium but are not using the ring, will put exp +50% for being premium. If are free account and are using the ring, will give him 10% of bonus for having the experience ring. If are free account and do not have the ring, say the mssage: buy premium.

Code:
local xpStorage = 188550 -- change this to a storage value not used
local xpToAdd = 0.1
local xpToAdd2 = 0.0

function onLogin(cid)

  local rate = getPlayerExpRate(cid, true) + xpToAdd
   local rate2 = getPlayerExpRate(cid, true) + xpToAdd2
   local rate3 = getPlayerExpRate(cid, true) + xpToAdd
    
     if isPremium(cid) == TRUE and getPlayerStorageValue(cid, 188550) >= 1 then
         doPlayerSetExperienceRate(cid, rate)
         setPlayerStorageValue(cid, xpStorage, 1)
         doPlayerSendTextMessage(cid,21,"U receive 50% more exp for being premium + 10% de exp for using the ring!")  
      
     elseif isPremium(cid) == TRUE and getPlayerStorageValue(cid, 188550) < 1 then
         doPlayerSetExperienceRate(cid, rate2)
         doPlayerSendTextMessage(cid,21,"U receive 50% exp fort being premium!")  
        
     elseif isPremium(cid) == FALSE and getPlayerStorageValue(cid, 188550) >= 1 then
         doPlayerSetExperienceRate(cid, rate3)
         doPlayerSendTextMessage(cid,21,"U receive 10% exp for having a ring. Become premium to receibe 50%!")        
    
     elseif isPremium(cid) == FALSE and getPlayerStorageValue(cid, 188550) < 1 then
         doPlayerSendTextMessage(cid,21,"Get premium to receibe 50% more exp!")        
     end      
return true
end

function getPlayerExpRate(cid, stages)
  if stages then
  return getExperienceStage(getPlayerLevel(cid), getVocationInfo(getPlayerVocation(cid)).experienceMultiplier)
  end
  return getConfigInfo('rateExperience')
end

Now the ring script:

Code:
--function onEquip(cid, item, slot)

--local rate = {}

--if getPlayerLevel(cid) >= 1 then
--rate = 1.05
--end

--doTransformItem(item.uid, 7697, 1)
--doPlayerSendTextMessage(cid, 22, "U aare using the exp ring and ur exp are increased "..((rate - 1)*100).." %.")
--doPlayerSetExperienceRate(cid, rate)
--return true
--end

--function onDeEquip(cid, item, slot)
--doTransformItem(item.uid, 7708, 1)
--doPlayerSendTextMessage(cid, 22, "U removed the exp ring and u exp back to normall.")
--doPlayerSetExperienceRate(cid, 1.0)
--return true
--end

local xpStorage = 188550 -- change this to a storage value not used
local xpToAdd = 0.1

function onEquip(cid, item, slot)
  local rate = getPlayerExpRate(cid, true) + xpToAdd
  if getPlayerStorageValue(cid, xpStorage) == -1 then
  setPlayerStorageValue(cid, xpStorage, 1)
  doPlayerSetExperienceRate(cid, rate)
  doPlayerSendTextMessage(cid, 22, "You have gained "..(xpToAdd * 100).."% bonus exp!")
  doTransformItem(item.uid, 7697, 1)
  end
  return true
end

function onDeEquip(cid, item, slot)
  local rate = ((getPlayerExpRate(cid, true) - xpToAdd) <= 1) and 1 or getPlayerExpRate(cid, true) - xpToAdd
  if getPlayerStorageValue(cid, xpStorage) == 1 then
  doPlayerSetExperienceRate(cid, rate)
  setPlayerStorageValue(cid, xpStorage, -1)
  doTransformItem(item.uid, 7708, 1)
  doPlayerSendTextMessage(cid, 22, "Bounus xp has ended.")
  end
  return true
end

function getPlayerExpRate(cid, stages)
  if stages then
  return getExperienceStage(getPlayerLevel(cid), getVocationInfo(getPlayerVocation(cid)).experienceMultiplier)
  end
  return getConfigInfo('rateExperience')
end

BOTH CODES WORK GOOD, but ONLY if player are level > 1 and < 100
Code:
<stage minlevel="1" maxlevel="100" multiplier="1"/>

If player are level > then 100, exp bug and player get 3789743897438943 exp, thats a lot of exp lol

So ur code worked for players bettwen level 1~100, more than that player win TOO MUCH exp..

What i did wrong?

Please help me, i do not want the done code, i am really making my head hot and spendind days (check when i make this post) trying to make this script work.
 
Last edited by a moderator:
https://otland.net/threads/how-can-i-add-50-to-this-script.235290/#post-2272456
I'm fairly certain if you use this exact script here everything will work 100%
If not.. this is the only part this needs modifying
Code:
function getPlayerExpRate(cid, stages)
if stages then
return getExperienceStage(getPlayerLevel(cid), getVocationInfo(getPlayerVocation(cid)).experienceMultiplier)
end
return getConfigInfo('rateExperience')
end
Someone smarter then me will have to figure out how to check the players current 'rateExperience' or 'experienceMultiplier' if it's not automatically modified/updated by your other script.
 
I don't know why you have that script for onLogin, you could apply that same msg inside movements, in the same script.

Code:
local xpStorage = 18000 -- change this to a storage value not used
local xpToAdd = {
    premacc = 0.50, -- premium account bonus xp
    freeacc = 0.10  -- free account bonus xp
}

function onEquip(cid, item, slot)
    local bonus = (isPremium(cid)) and xpToAdd['premacc'] or xpToAdd['freeacc']
    local rate = getPlayerExpRate(cid, true) + bonus
    if getPlayerStorageValue(cid, xpStorage) == -1 then
        setPlayerStorageValue(cid, xpStorage, 1)
        doPlayerSetExperienceRate(cid, rate)
        doPlayerSendTextMessage(cid, 22, "You have gained "..(bonus * 100).."% bonus exp!")
        if not isPremium(cid) then
            doPlayerSendTextMessage(cid,21,"If you were a premium player you would receive "..(xpToAdd['premacc'] * 100).."% instead of "..(xpToAdd['freeacc'] * 100).."% as a free account while using this ring.")
        end
        doTransformItem(item.uid, 7697, 1)
    end
    return true
end

function onDeEquip(cid, item, slot)
    local bonus = (isPremium(cid)) and xpToAdd['premacc'] or xpToAdd['freeacc']
    local rate = ((getPlayerExpRate(cid, true) - bonus) <= 1) and 1 or getPlayerExpRate(cid, true) - bonus
    if getPlayerStorageValue(cid, xpStorage) == 1 then
        doPlayerSetExperienceRate(cid, rate)
        setPlayerStorageValue(cid, xpStorage, -1)
        doTransformItem(item.uid, 7708, 1)
        doPlayerSendTextMessage(cid, 22, "Bonus xp has ended.")
    end
    return true
end

function getPlayerExpRate(cid, stages)
    if stages then
        return getExperienceStage(getPlayerLevel(cid), getVocationInfo(getPlayerVocation(cid)).experienceMultiplier)
    end
    return getConfigInfo('rateExperience')
end
 
Last edited:
I don't know why you have that script for onLogin, you could apply that same msg inside movements, in the same script.

Code:
local xpStorage = 18000 -- change this to a storage value not used
local xpToAdd = {
    premacc = 0.50, -- premium account bonus xp
    freeacc = 0.10  -- free account bonus xp
}

function onEquip(cid, item, slot)
    local bonus = (isPremium(cid)) and xpToAdd['premacc'] or xpToAdd['freeacc']
    local rate = getPlayerExpRate(cid, true) + bonus
    if getPlayerStorageValue(cid, xpStorage) == -1 then
        setPlayerStorageValue(cid, xpStorage, 1)
        doPlayerSetExperienceRate(cid, rate)
        doPlayerSendTextMessage(cid, 22, "You have gained "..(bonus * 100).."% bonus exp!")
        if not isPremium(cid) then
            doPlayerSendTextMessage(cid,21,"If you were a premium player you would receive "..(xpToAdd['premacc'] * 100).."% instead of "..(xpToAdd['freeacc'] * 100).."% as a free account while using this ring.")
        end
        doTransformItem(item.uid, 7697, 1)
    end
    return true
end

function onDeEquip(cid, item, slot)
    local bonus = (isPremium(cid)) and xpToAdd['premacc'] or xpToAdd['freeacc']
    local rate = ((getPlayerExpRate(cid, true) - bonus) <= 1) and 1 or getPlayerExpRate(cid, true) - bonus
    if getPlayerStorageValue(cid, xpStorage) == 1 then
        doPlayerSetExperienceRate(cid, rate)
        setPlayerStorageValue(cid, xpStorage, -1)
        doTransformItem(item.uid, 7708, 1)
        doPlayerSendTextMessage(cid, 22, "Bounus xp has ended.")
    end
    return true
end

function getPlayerExpRate(cid, stages)
    if stages then
        return getExperienceStage(getPlayerLevel(cid), getVocationInfo(getPlayerVocation(cid)).experienceMultiplier)
    end
    return getConfigInfo('rateExperience')
end

@Codex NG , As i said, premium player win 50% more exp for being premium, then they must win 50% exp when log in.
@Xikini , i will see what i can do, thanks for u repply!
 
Back
Top