Rewriting player_hurt dmg_health

Hello everyone,

I'm trying to adjust a throwing knife mod ( so that if a player has some throwing knives left and they knife someone then it will deal the amount of damage a throwing knife usually would rather than the usual amount. This is because players often complain that they are trying to throw a throwing knife (which does 57hp damage) when they are in close quarters combat, but since they are too close to the victim it performs a standard left click knife attack (17hp damage) instead.

I went ahead and added this to OnPluginStart, just like the other hooks:


HookEvent("player_hurt", EventPlayerHurt, EventHookMode_Pre);

and have written this action:


public Action:EventPlayerHurt(Handle:event,const String:name[],bool:dontBroadcast) { // Checking for left click knifings that should be throwing knives instead

    if (GetConVarBool(g_CVarEnable)) {

        decl String:checkWeapon[32];

        GetEventString(event, "weapon", checkWeapon, sizeof(checkWeapon));

        if (!StrEqual(checkWeapon, "knife")){

            return Plugin_Continue;


        new client = GetClientOfUserId(GetEventInt(event, "userid"));

        if (!IsFakeClient(client) && StrEqual(checkWeapon, "knife") && (g_iKnives[client] > 0)) {

            LogMessage("Knife health should be adjusted to %d", StringToInt(g_sDamage));

            SetEventInt(event, "dmg_health", StringToInt(g_sDamage));

            LogMessage("Knife health actually adjusted to %d", GetEventInt(event, "dmg_health"));


        return Plugin_Changed;


    return Plugin_Continue;


I *thought* that this would hook the player_hurt event before it was actually fired, check to make sure that it is a knife being used, change the damage the knife is applying, and then fire the weapon. I added the LogMessage()s to debug and it spits out the correct information:


L 10/21/2011 - 18:51:42: [cssthrowingknives.smx] Knife health should be adjusted to 61

L 10/21/2011 - 18:51:42: [cssthrowingknives.smx] Knife health actually adjusted to 61

I'm not really sure why this isn't working, unless it is changing the notification after the fact even though I am Pre-Hooking.

Any ideas?

Once I get the damage adjustment working correctly then I will subtract a knife from the player as if he had actually thrown a knife.

Orignal From: Rewriting player_hurt dmg_health

No comments

Not a single link is allowed to submit in comment :o