• 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 Experience when killing someone with script

oh hai thar

New Member
Joined
Apr 24, 2011
Messages
56
Reaction score
3
Some years ago, I tried to make a firefield-on-rightclick script, and I got help with it.
Now , Im wondering if its possible to add experience after player is dead?

This is script (veryfunny):
Code:
function onUse(cid, item, fromPos, item2, toPos)
targetzplayer = getTopCreature(fromPos)
 
local area1 = {
{0, 0, 0}, 
{0, 1, 0}, 
{0, 0, 0}, 
}
doAreaCombatHealth(0,COMBAT_FIREDAMAGE, fromPos, area1,-(getPlayerLevel(cid)*10),-(getPlayerLevel(cid)*14),15)
if(getCreatureHealth(targetzplayer) < 1) then
	doPlayerAddExperience(cid, 5)
end
return TRUE
end
 
If I understand right, I'll completely ignore your posted script.
You may use the config.lua and set
Lua:
rateExperienceFromPlayers = 0
and set
Lua:
minLevelThresholdForKilledPlayer = 0.9
	maxLevelThresholdForKilledPlayer = 0

OR

If you want a script that works everytime no matter what level the killed person is you may use Znote's one..
Lua:
~ -- Quickly written by Znote.
function onKill(cid, target, lastHit)
	local percent = 5 -- you get 5% experience from enemys total exp
 
	if isPlayer(target) then -- If you killed a player and not a monster:
		local xp = getPlayerExperience(target) -- fetch enemy experience
		local calc = ((xp/100) * percent) -- calculate 1% of enemy experience, and multiply it with configured "percent"
		local gain = math.floor(calc) -- Make sure the value is integer (etc 230 instead of 230,123123123)
 
		doPlayerAddExperience(cid, gain) -- gives you the calculated experience
	end
	return true
end

As znote said
Edit: Script contains basic functionality. Should be easy to extend further to your liking.
Remember to put the exprate to a lower percent than what the player loses when he dies. (Also you should consider his loss with blessings).

It's a creaturescript so you should use
Lua:
 <event type="kill" name="PlayerKill" script="kill.lua"/>
for example
And I think you have to register in login.lua
 

Similar threads

Back
Top