Quote:
Originally Posted by Backstabnoob
No idea why you're checking for is_user_connected and is_user_alive, just check if both players are player entities.
You're probably getting that error because your player_power variable doesn't have enough cells, how do you initialize it?
|
I read somewhere that this could be a way to check for it, however if a player is already checked upon executing the script then it's kind of useless indeed.
To initialize it I got the following in client_connect:
Code:
player_power[id] = 0
If a player wants to level this up he use a menu to advance this. It's been done the same way with 5 other skills.
Quote:
Originally Posted by Fr33m@n
Return values only matter if you are in Pre, Pre mean forward the takedamage call. In PRE, they allow you to modify some stuff, like blocking the incoming takedamage.
See ham_const.inc
PHP Code:
/** * Ham return types. * - * Return these from hooks to disable calling the target function. * Numbers match up with fakemeta's FMRES_* for clarity. They are interchangable. * 0 (or no return) is also interpretted as HAM_IGNORED. */ #define HAM_IGNORED 1 /**< Calls target function, returns normal value */ #define HAM_HANDLED 2 /**< Tells the module you did something, still calls target function and returns normal value */ #define HAM_OVERRIDE 3 /**< Still calls the target function, but returns whatever is set with SetHamReturn*() */ #define HAM_SUPERCEDE 4 /**< Block the target call, and use your return value (if applicable) (Set with SetHamReturn*()) */
In your case you are in pre, so i think it's better to call it like that :
PHP Code:
public fw_TakeDamage(victim, inflictor, attacker, Float:damage) { if ( is_user_connected(victim) && is_user_connected(attacker) && player_power[attacker] > 0 ) { //new Float:extradmg = 1.0 + player_power[attacker]*0.01 // skip useless variable when you can, this is the base of optimisation
SetHamParamFloat(4, damage * (1.0 + player_power[attacker]*0.01))
return HAM_HANDLED } return HAM_IGNORED }
|
I get the part that you have to be in "pre" to use the return function, however I don't quite understand how to use the pre function and recognize when this is used. Could you explain where I can see where the pre is in the script you provided?
Quote:
Originally Posted by meTaLiCroSS
Assuming that you registered that forward to "player" entities, there's no need to check if victim is a player; it would be always a player.
|
Yes I've forwarded it to a player entity, so I think it's kind of useless indeed.
Code:
RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")