Bool problem?
#1

Hello everyone, I've tried scripting something, but seems like it doesn't work as expected.
I was wondering why, as it compiles fine?

So, this is the code:
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
    if(deagledm[playerid] == 1)
    {
        if(issuerid != INVALID_PLAYER_ID && weaponid == 24 && bodypart == 9)
        {
            SetPlayerHealth(playerid, 0);
            SendClientMessage(playerid, COLOR_FIREBRICK, "** A bullet came straight into your head, you was killed by a headshot. **");
        }
        if(issuerid != INVALID_PLAYER_ID && weaponid == 24 && bodypart == 3)
        {
            SetPlayerHealth(playerid, 149);
        }
        if(issuerid != INVALID_PLAYER_ID && weaponid == 24 && bodypart == 4)
        {
            SetPlayerHealth(playerid, 149);
        }
        if(issuerid != INVALID_PLAYER_ID && weaponid == 24 && bodypart == 5)
        {
            SetPlayerHealth(playerid, 149);
        }
        if(issuerid != INVALID_PLAYER_ID && weaponid == 24 && bodypart == 6)
        {
            SetPlayerHealth(playerid, 149);
        }
        if(issuerid != INVALID_PLAYER_ID && weaponid == 24 && bodypart == 7)
        {
            SetPlayerHealth(playerid, 149);
        }
        if(issuerid != INVALID_PLAYER_ID && weaponid == 24 && bodypart == 8)
        {
            SetPlayerHealth(playerid, 149);
        }
       
    }
    else return 0;
    return 1;
}
But it keeps taking the players health down, and eventually kills him after 3 bullets?
Why does it happen, and how do I fix that? Thanks in advance!
Reply
#2

Anyone can help me out here?
Reply
#3

Can you show where the deagledm is given its value? Cause that could be your problem, it isn't being given a value.
Reply
#4

Weird. See if this works:
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    if(issuerid == INVALID_PLAYER_ID) return 1;
    if(deagledm[playerid])
    {
        if(weaponid == 24)
        {
            switch(bodypart)
            {
                case 9:
                {
                    SetPlayerHealth(playerid, 0.0);
                    SendClientMessage(playerid, COLOR_FIREBRICK, "** A bullet went straight into your head, you were killed by a headshot. **");
                }
                case 3 .. 8: SetPlayerHealth(playerid, 149.0);
            }
        }
    }
    return 1;
}
Quote:
Originally Posted by SA-MP Wiki
Return Values:
1 - Allows this callback to be called in other scripts.
0 - Callback will not be called in other scripts.
It is always called first in gamemodes so returning 0 there blocks filterscripts from seeing it
Make sure you put this in your gamemode if possible.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)