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

exp per hit

Lua:
function onStatsChange(cid, attacker, type, combat, value)
 
	if isPlayer(attacker) and isPlayer(cid) then
		if getPlayerIp(cid) ~= getPlayerIp(attacker) then
			if type == STATSCHANGE_HEALTHLOSS then
				doPlayerAddExperience(attacker, value)
				doPlayerSendTextMessage(attacker, MESSAGE_STATUS_DEFAULT, "You gained " .. value .. " experience points.")
			end
		end
	end
	return true
end

Yea, but what about monsters :p
 
Yea, but what about monsters :p
Lua:
function onStatsChange(cid, attacker, type, combat, value)
 
local d = false
	if isPlayer(attacker) and isPlayer(cid) then
		if getPlayerIp(cid) ~= getPlayerIp(attacker) then
			d = true
		end
	end
	if isMonster(cid) and isPlayer(attacker) then
		d = true
	end
	if d then
		if type == STATSCHANGE_HEALTHLOSS then
			doPlayerAddExperience(attacker, value)
			doPlayerSendTextMessage(attacker, MESSAGE_STATUS_DEFAULT, "You gained " .. value .. " experience points.")
		end
	end
	return true
end

:p?
 
Code:
if isMonster(cid) and isPlayer(attacker) then

That's all you had to change...the original poster wants it for monsters.
 
Lua:
function onStatsChange(cid, attacker, type, combat, value)
 
local d = false
	if isPlayer(attacker) and isPlayer(cid) then
		if getPlayerIp(cid) ~= getPlayerIp(attacker) then
			d = true
		end
	end
	if isMonster(cid) and isPlayer(attacker) then
		d = true
	end
	if d then
		if type == STATSCHANGE_HEALTHLOSS then
			doPlayerAddExperience(attacker, value)
			doPlayerSendTextMessage(attacker, MESSAGE_STATUS_DEFAULT, "You gained " .. value .. " experience points.")
		end
	end
	return true
end

:p?

No, what I meant was: "How to get it to execute for every monster"? :p It won't be executed for monsters right now.
also
Lua:
function onStatsChange(cid, attacker, type, combat, value)
	if type == STATSCHANGE_HEALTHLOSS and isPlayer(attacker) and ((isPlayer(cid) and getPlayerIp(cid) ~= getPlayerIp(attacker)) or isMonster(cid)) then
		doPlayerAddExperience(attacker, value)
		doPlayerSendTextMessage(attacker, MESSAGE_STATUS_DEFAULT, "You gained " .. value .. " experience points.")
	end
	return true
end
 
No, what I meant was: "How to get it to execute for every monster"? :p It won't be executed for monsters right now.
also
Lua:
function onStatsChange(cid, attacker, type, combat, value)
	if type == STATSCHANGE_HEALTHLOSS and isPlayer(attacker) and ((isPlayer(cid) and getPlayerIp(cid) ~= getPlayerIp(attacker)) or isMonster(cid)) then
		doPlayerAddExperience(attacker, value)
		doPlayerSendTextMessage(attacker, MESSAGE_STATUS_DEFAULT, "You gained " .. value .. " experience points.")
	end
	return true
end

ohh.. then declare the event in every monster's file?
 
So , am i am right ?
creaturescripts.xml
Code:
	<event type="login" name="hitexp_register" event="script" value="hitexp.lua"/>
	<event type="statschange" name="Hitexp" event="script" value="hitexp.lua"/>

hitexp.lua
Code:
function onStatsChange(cid, attacker, type, combat, value)
	if type == STATSCHANGE_HEALTHLOSS and isPlayer(attacker) and ((isPlayer(cid) and getPlayerIp(cid) ~= getPlayerIp(attacker)) or isMonster(cid)) then
		doPlayerAddExperience(attacker, value)
		doPlayerSendTextMessage(attacker, MESSAGE_STATUS_DEFAULT, "You gained " .. value .. " experience points.")
	end
	return true
end
 
Last edited:
Back
Top