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

Help here

Michy

Member
Joined
May 20, 2010
Messages
105
Reaction score
6
I need your help:
I would like a "creatureevents" when the person is missing, 20 HP starts to come out an effect is possible?

Sorry my english is bad :/
 
He missed a 'do'
Lua:
function onStatsChange(cid, attacker, type, combat, value)
	for _, pid in ipairs(getCreatureSummons(cid)) do
		if(pid and isPlayer(cid) and combat ~= COMBAT_HEALING or type == STATSCHANGE_HEALTHLOSS) then
			value = 30
			if(value >= getCreatureHealth(pid)) then
				doSendMagicEffect(getThingPosition(pid), CONST_ME_STUN)
				return false
			end
		end
	end
 
	return true
end
 
Ok then, time for a change...ERASE ALL the last scripts I posted from your files, creaturescript and login.lua...then...

lowhealth.lua:
Lua:
local config = {
	playerCheck = "yes",
	summonCheck = "yes"
}

config.playerCheck = getBooleanFromString(config.playerCheck)
config.summonCheck = getBooleanFromString(config.summonCheck)

function onThink(interval, lastExecution, thinkInterval)
	if(config.playerCheck) then
		for _, pid in ipairs(getPlayersOnline()) do
			if(getCreatureHealth(pid) <= 30) then
				doSendMagicEffect(getThingPosition(pid), CONST_ME_SLEEP)
			end
		end
	end

	if(config.summonCheck) then
		for _, pid in ipairs(getPlayersOnline()) do
			for _, sid in ipairs(getCreatureSummons(pid)) do
				if(getCreatureHealth(sid) <= 30) then
					doSendMagicEffect(getThingPosition(sid), CONST_ME_STUN)
				end
			end
		end
	end
	return true
end

In globalevents.xml:
XML:
	<globalevent name="lowhealth" interval="1" script="lowhealth.lua"/>

TESTED IN MY SERVER
CREDITS: santigggg. I dunno why you said his script didn't work. I only added a config and the summon part.
 
Post the errors.

Strange, because I tested it on my server and it works. Are you sure you tried it with someone with HP 30 or less?
 
Last edited:
I would rather do it via creaturescripts and onThink()
since you don't have to loop through online players then (which is kinda idiotic in my eyes).

put this into your creaturescripts folder with the name "lowhealth.lua"
Lua:
function onThink(cid, interval)
	if isPlayer(cid) and getCreatureHealth(cid) <= 30 then
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_SLEEP)
	end
	return true
end

creaturescripts.xml:
Lua:
<event type="think" name="LowHealth" event="script" value="lowhealth.lua"/>

login.lua:
Lua:
registerCreatureEvent(cid, "LowHealth")



kind regards, Evil Hero.
 
Back
Top Bottom