• 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 Function like doPlayerAddExperience

dchampag

Well-Known Member
Joined
Jul 15, 2008
Messages
679
Reaction score
55
Location
USA
is there a function like doPlayerAddExperience that takes into account the exp rate that is set on the player?
 
Solution
I think you can easily fix it with something like this:

Lua:
function calibrateExpRate(cid)
	local rate = config.rateExperience
-- TODO: make legit if statements. 
	if PLAYERVIP then
		rate = rate * 1.5
	end
	if PLAYERREDSKULL then
		rate = rate * 0.5
	end
	if BOTTERPENALTY then
		rate = rate * 0.5
	end
	return rate
end


-- usage:
doPlayerAddExperience(cid, 100 * calibrateExpRate(cid))
-- change 100 with base exp.

You can figure out the accurate if statements yourself?
Here:
Lua:
local exp = getExperienceStage(getPlayerLevel(cid), getVocationInfo(getPlayerVocation(cid)).experienceMultiplier)
doPlayerAddExperience(cid, 100 * exp)

If player have 3x exp in his current stage, he will get 100 * 3 experience (300).

So just change 100 with the amount of experience you want to be staged to the player.
 
Well, if you are not using stages, then this function or Znote posted is useless, can you explain what you mean? You mean the exp in config.lua?

What do you mean cocky? i just trying to help :S
 
Sorry what you said seemed like you were calling me incompetent for not searching it, but basically I have a custom function for exp, if VIP rate = rate * 1.5 if red skull rate = rate * 0.5 if is botterpenaltystatus rate = rate * 0.5 so basically players will have all different exp rates based on their status in game weather or not they were caught botting or have VIP, so I want my quests to give the players exp of quest * their own exp rate
 
Well, a vip do they got a storage when they are vip or how do they become vip, show me the script.
 
basically I have a custom function for exp,

if VIP rate = rate * 1.5
if red skull rate = rate * 0.5
if is botterpenaltystatus rate = rate * 0.5

so basically players will have all different exp rates based on their status in game weather or not they were caught botting or have VIP, so I want my quests to give the players exp of quest * their own exp rate

Can you share these custom functions? That way it will be easier for us to alter/extend upon it and create a function to fetch a players current exp multiplier.

The basic functions that comes with the distro allows us to fetch the exprate from config.lua, or fetch the matching exp stage from data/XML/stages.xml.

However since your using a different system to set the experience rate, we are missing the function to extract exp rate from that system. And it would be helpful if you could share it with us.

You should perhaps have mentioned that you used a custom exp stage system earlier.
 
Last edited:
Well now that you guys have got my brain working I am thinking maybe it wouldn't be a bad idea to set a storage value as the exp rate when the server determines the exp rate when they log in then have it multiply quest exp by that? What do you think is that a semi efficient way of doing it?

But I didn't want to stress any more MySQL queries in the server with those custom functions if I have it actually check those functions it will check database and add more stress to the server host and MySQL server.
 
I think you can easily fix it with something like this:

Lua:
function calibrateExpRate(cid)
	local rate = config.rateExperience
-- TODO: make legit if statements. 
	if PLAYERVIP then
		rate = rate * 1.5
	end
	if PLAYERREDSKULL then
		rate = rate * 0.5
	end
	if BOTTERPENALTY then
		rate = rate * 0.5
	end
	return rate
end


-- usage:
doPlayerAddExperience(cid, 100 * calibrateExpRate(cid))
-- change 100 with base exp.

You can figure out the accurate if statements yourself?
 
Last edited:
Solution
Yeah I think that is nice, but that will also use my custom functions actually read values from the database so I don't know if it would be more efficient to set the exp rate itself into a storage value on login?

- - - Updated - - -

I can use function like that calibrate to set storage value
 
There are many ways to do this. You will have to check out yourself which you think is more suitable for your needs and what performs best. I would avoid munching the sql server on these matters since it can be avoided.
 
thanks guys so I think what I will do is have it check on login those variables, then use something like the calibrate function you posted that will set the players exp rate and add it to the players storage for the server to retrieve in quests =d I will post script here when I'm finished if others have issue similar can use
 
Back
Top