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

Problem with doPlayerAddExp

president vankk

Web Developer & AuraOT Owner
Joined
Jul 10, 2009
Messages
5,719
Solutions
9
Reaction score
339
Hi everyone, I'm having a problem with the function doPlayerAddExp check the image below

dc90IJaj.png


Code:
player:doPlayerAddExp(150000, true)

Just want the 150000 multiplied by the actual stages.

and I have the function in the compat.lua
Code:
function doPlayerAddExp(cid, exp, useMult, ...)
   local player = Player(cid)
   if player == nil then
     return false
   end

   if useMult then
     exp = exp * Game.getExperienceStage(player:getLevel())
   end
   return player:addExperience(exp, ...)
end
 
Seems like "player" is not defined in quests/system.lua

Edit:

doPlayerAddExp(player:getId(),150000, true)

If player is defined with local = Player(cid) why pick the id of player again?
I mean, player = id of player already, why getId() again? That makes no sense to me
 
doPlayerAddExp(player:getId(),150000, true)

this is correct.
but u should remove :getId() and it should work correctly.


there's no need to put player: infront of the function since u already send the player and thats why u are getting the error since its not a metafunction or whatever. idk these words.
doPlayerAddExp(cid,150000, true)
in the bold text u send the player.

for example I just added this line
doPlayerAddExp(self, 5000, true)
in a script and it worked as intended.
 
Last edited:
Seems like "player" is not defined in quests/system.lua

Edit:



If player is defined with local = Player(cid) why pick the id of player again?
I mean, player = id of player already, why getId() again? That makes no sense to me
player is not = id, player is an object and can have a lot of proprieties besides id. He could use player:addExperience(exp[, send_text]) though. When you do player = Player(cid) you are creating the object player with a bunch of info for the player with the that cid. cid ~= player. cid == player.uid
 
Last edited:
player is not = id, player is an object and can have a lot of proprieties besides id. He could use player:addExperience(exp, mult) though. When you do player = Player(cid) you are creating the object player with a bunch of info for the player with the that cid. cid ~= player. cid == player.id
Oh, great to know..thanks :)
Not working with newer TFS so no clue about meta's :)
 
Code:
function Player.doPlayerAddExp(self, exp, useMult, ...)
   if self == nil then
     return false
   end

   if useMult then
     exp = exp * Game.getExperienceStage(self:getLevel())
   end

   return self:addExperience(exp, ...)
end

player:doPlayerAddExp(150000, true)
 
Back
Top