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

A function to check the player hit

JNLP

Hail Odin!
Joined
Aug 4, 2008
Messages
54
Reaction score
0
Location
Brazil
Hello again guys! Here I am with another request :D. This time I was thinking about a function to chek the player hit .

Exemple:

The player needs to hit 500+ in a determined monster to continue the quest.

Can someone do it?
 
LUA:
onStatsChange(cid, attacker, type, combat, value)

with "value" param you can check the hit of players, example:

LUA:
if value => 500 then

you need to register this creature event to the specific creature
 
In 0.4 you could use damage param in the onKill creaturescript, otherwise you need to store the total damage with onStatsChange.
 
I will try use damage param, if I can't, will try the way you said, Exedion. By now, thanks all.

Edit:

I tried the damage param, but appears the error:

No valid type for creature event.onKill

Here is the script:

PHP:
function onKill(cid, target, damage)

if isPlayer(cid) == TRUE then
	if getCreatureName(cid) == dragon then
                if damage >= 3000 then
		if getPlayerStorageValue(cid,4569 ) == -1 then
			setPlayerStorageValue(cid, 4569) == 1
		end
	  end
     end
 end
return TRUE
end
 
Last edited:
LUA:
local storage = 4569
local monster = "Demon"
function onStatsChange(cid, attacker, type, combat, value)
	if getCreatureName(cid):lower == monster then
		if isPlayer(attacker) and isMonster(cid) then
			if type == STATSCHANGE_HEALTHLOSS then
				if value >= 500 then
					if getCreatureStorage(attacker, storage) < 0 then
						setPlayerStorageValue(attacker, storage, 1)
					end
				end
			end
		end
	end
 
	return true
end
 
Last edited:
I'm not having that problem anymore, now the problem is:

[15/02/2011 10:09:11] [Error - CreatureEvent::configureEvent] No valid type for creature event.onStatsChange
[15/02/2011 10:09:11] [Warning - BaseEvents::loadFromXml] Cannot configure an event

Tag creturescripts.xml:

[15/02/2011 10:09:11] [Error - CreatureEvent::configureEvent] No valid type for creature event.onStatsChange
[15/02/2011 10:09:11] [Warning - BaseEvents::loadFromXml] Cannot configure an event

LUA:
<event type="onStatsChange" name="demon" event="script" value="demon.lua"/>

This tag it's wrong, not?

(I'm using the JDB script.)
 
Last edited:
Thanks, Cyko, but still having error on script:

[16/02/2011 21:47:13] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/Nidhogg.lua)
[16/02/2011 21:47:13] data/creaturescripts/scripts/Nidhogg.lua:4: function arguments expected near '=='
[16/02/2011 21:47:13] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/Nidhogg.lua:4: function arguments expected near '=='
 
500 in total or in 1 hit?
LUA:
function onStatsChange(cid, attacker, type, combat, value)
	if type == STATSCHANGE_HEALTHLOSS and value >= 500 and isPlayer(attacker) then
		doCreatureSetStorage(attacker, 4569, 1)
	end
	return true
end
 
Anyway, I registered and again didn't work and no sign of errors ;S

There's no other way to do it?
 
Last edited:
Back
Top