OnPlayerTakeDamage doesn't work?
#1

Hello,

At my OnPlayerTakeDamage I have got this:

pawn Код:
if(weaponid == 24) //deagle
            {
                if(armour > 0)
                {
                    pDamage[playerid] += 15;
                }
                else
                {
                    pDamage[playerid] += 30;
                }
            }
and below that:
pawn Код:
if(pDamage[playerid] > 0)
            {
                pDamageTimer[playerid] = 120;
                GameTextForPlayer(playerid, "~r~You've been hit!", 1500, 1);
                if(pDamage[playerid] >= 100)
                {
                    format(string, sizeof(string), "* %s falls to the ground due to the bullet injuries.", GetPlayerNameEx(playerid));
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    ApplyAnimation(playerid, "KNIFE", "KILL_Knife_Ped_Die", 4.0, 0, 1, 1, 1, 0, 1);
                }
               
               
            }
But the effect (the messages, etc) isn't triggered. Is there anything I do wrong in here?
Reply
#2

I think the problem is with the variable armor....how are you getting this? If it wasn't already fetched before the code block you posted, it will always be equal to 0.

Код:
        if(weaponid == 24) //deagle
        {
	        new Float:a;
	        GetPlayerArmour(playerid, a);

                if(a > 0.0)
                {
                    pDamage[playerid] += 15;
                }
                else
                {
                    pDamage[playerid] += 30;
                }
         }
Reply
#3

The armour is checked in a part before this code, right under OnPlayerTakeDamage.
Reply
#4

Okay now I added a "print" below OnPlayerTakeDamage to see if it's triggered or not, and that is the issue; OnPlayerTakeDamage doesn't seem to be triggered.

What's this? :P
Reply
#5

2nd page bump
Reply
#6

Is it used in any scripts/includes?
Reply
#7

Nope, only in the main gamemode.
Reply
#8

I can't see anything wrong, maybe you returned before this?if the call
Reply
#9

What do you mean?
Reply
#10

This is the whole callback:

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    new points;
    new string[128];
    new Float:armour;
    GetPlayerArmour(playerid, armour);
    if(issuerid == INVALID_PLAYER_ID)
    {
        return 1;
    }
    if(GetPVarInt(playerid, "IsInArena") == 0)
    {
        if(GetPVarInt(playerid, "EventToken") == 0)
        {
            if(weaponid == 24) //deagle
            {
                if(armour > 0)
                {
                    pDamage[playerid] += 15;
                }
                else
                {
                    pDamage[playerid] += 30;
                }
            }
            else if(weaponid == 23) //sdpistol
            {
                if(armour > 0)
                {
                    pDamage[playerid] += 5;
                }
                else
                {
                    pDamage[playerid] += 10;
                }
            }
            else if(weaponid == 29) //MP5
            {
                if(armour > 0)
                {
                    pDamage[playerid] += 10;
                }
                else
                {
                    pDamage[playerid] += 15;
                }
            }
            else if(weaponid == 30 || weaponid == 31) //M4 - AK47
            {
                if(armour > 0)
                {
                    pDamage[playerid] += 10;
                }
                else
                {
                    pDamage[playerid] += 20;
                }
            }
            else if(weaponid == 25 || weaponid == 27) //Shotgun + SPAS12
            {
                if(armour > 0)
                {
                    if(ProxDetectorS(12.0, playerid, issuerid))
                    {
                        pDamage[playerid] += 25;
                    }
                    else
                    {
                        pDamage[playerid] += 15;
                    }
                }
                else
                {
                    if(ProxDetectorS(12.0, playerid, issuerid))
                    {
                        pDamage[playerid] += 35;
                    }
                    else
                    {
                        pDamage[playerid] += 20;
                    }
                }
            }
            else if(weaponid == 34) //Sniper
            {
                if(ProxDetectorS(60.0, playerid, issuerid))
                {
                    pDamage[playerid] += 50;
                }
                else
                {
                   pDamage[playerid] += 0;
                }
            }
            else if(weaponid == 33) //Rifle
            {
                pDamage[playerid] += 15;
            }
            if(pDamage[playerid] > 0)
            {
                pDamageTimer[playerid] = 120;
                GameTextForPlayer(playerid, "~r~You've been hit!", 1500, 1);
                if(pDamage[playerid] >= 100)
                {
                    format(string, sizeof(string), "* %s falls to the ground due to the bullet injuries.", GetPlayerNameEx(playerid));
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    ApplyAnimation(playerid, "KNIFE", "KILL_Knife_Ped_Die", 4.0, 0, 1, 1, 1, 0, 1);
                }
               
               
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)