DeathMessage doesn't show
#1

Hello i have a problem. As a pro scripter i can't really solve this problem. I have for sure a little problem but either i can't see it or i'm now too old ^^

If my friend kills me, we get clientmessage and deathmessage for all. It works fine.
But if i kill myself it doesn't show. DeathMessage and this Client Message.


pawn Код:
if(IsSpawned[killerid] == false && killerid != INVALID_PLAYER_ID)
{
    UnfairDeath[playerid] = true;
    HideDeathMessage[playerid] = true;
}

if(UnfairDeath[playerid] == false)
{
        // This works
    if(killerid != INVALID_PLAYER_ID)
    {
        if(IsOnDuty[killerid] == false)
        {
            SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
            Kills[killerid]++;
            Deaths[playerid]++;
            Cash[killerid] += 2000;
            new weapname[28];
            GetWeaponName(reason, weapname, sizeof(weapname));
            printf("%s (%d) Killed By %s (%d) - %s", GetName(playerid), playerid, GetName(killerid), killerid, weapname);
            format(string, sizeof(string), "%s (%d) Died. Killed By %s (%d) - %s", GetName(playerid), playerid, GetName(killerid), killerid, weapname);
            for(new i = 0; i < MAX_SLOT; i++)
            {
                if(IsPlayerConnected(i) && ShowDeathMessage[i] == true)
                {
                    SendClientMessage(i, COLOR_BROWN, string);
                }
            }
        }
        if(IsOnDuty[killerid] == true)
        {
            UnfairDeath[playerid] = true;
            HideDeathMessage[playerid] = true;
            printf("Admin %s (%d) has killed %s (%d) unfairly.", GetName(killerid), killerid, GetName(playerid), playerid);
        }
    }
    // For sure here's a problem
    if(killerid == INVALID_PLAYER_ID)
    {
        Deaths[playerid]++;
        new weapname[28];
        GetWeaponName(reason, weapname, sizeof(weapname));
        printf("%s (%d) Killed By %s (%d) - %s", GetName(playerid), playerid, GetName(killerid), killerid, weapname);
        format(string, sizeof(string), "%s (%d) Died. (%s)", GetName(playerid), playerid, weapname);
        for(new i = 0; i < MAX_SLOT; i++)
        {
            if(IsPlayerConnected(i) && ShowDeathMessage[i] == true)
            {
                SendClientMessage(i, COLOR_BROWN, string);
            }
        }
    }
}
// And this shows only if my friend kills me. either it doesn't work
if(HideDeathMessage[playerid] == false)
{
    SendDeathMessage(killerid, playerid, reason);
}
HideDeathMessage[playerid] = false;
Reply
#2

It is obvious that the if structures do not allow the code to be executed. Take a better look on them.
ShowDeathMessage[i] == true
HideDeathMessage[playerid] == false)
Reply
#3

For one there is no point of doing this if(killerid == INVALID_PLAYER_ID) might as well just be else but you should post your whole callback routine it seems convoluted from what is shown the rest will paint the whole picture.
Reply
#4

The wiki page says:
Quote:

You do not need to check whether killerid is INVALID_PLAYER_ID before using it in SendDeathMessage. INVALID_PLAYER_ID is a valid killerid ID parameter in that function.

Also, the code was a little bit messy and I really had some issues on reading it properly.
I tried to improve it.

I am not sure if it works because I haven't tested it, so let me know:

pawn Код:
if(IsSpawned[killerid] == false || IsOnDuty[killerid] == true && killerid != INVALID_PLAYER_ID) // If the killer is NOT spawned OR if the killer is ON admin duty AND the killer exists.
    UnfairDeath[playerid] = true;

if(IsOnDuty[killerid] == true && killerid != INVALID_PLAYER_ID) // If the killer is ON admin duty AND the killer exists.
    printf("Admin %s (%d) has killed %s (%d) unfairly.", GetName(killerid), killerid, GetName(playerid), playerid);
   
if(UnfairDeath[playerid] == false) // If the death is FAIR.
{
    if(killerid != INVALID_PLAYER_ID) // If the killer is VALID.
    {
        SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
        Kills[killerid]++;
        Cash[killerid] += 2000;
        new weapname[28];
        GetWeaponName(reason, weapname, sizeof(weapname));
        printf("%s (%d) Killed By %s (%d) - %s", GetName(playerid), playerid, GetName(killerid), killerid, weapname);
        format(string, sizeof(string), "%s (%d) Died. Killed By %s (%d) - %s", GetName(playerid), playerid, GetName(killerid), killerid, weapname);
           
        for(new i = 0; i < MAX_SLOT; i++)
            if(IsPlayerConnected(i) && ShowDeathMessage[i] == true)
                SendClientMessage(i, COLOR_BROWN, string);
    }
    else // If the killer is NOT VALID.
    {
        new weapname[28];
        GetWeaponName(reason, weapname, sizeof(weapname));
        printf("%s (%d) Killed By %s (%d) - %s", GetName(playerid), playerid, GetName(killerid), killerid, weapname);
        format(string, sizeof(string), "%s (%d) Died. (%s)", GetName(playerid), playerid, weapname);
       
        for(new i = 0; i < MAX_SLOT; i++)
            if(IsPlayerConnected(i) && ShowDeathMessage[i] == true)
                SendClientMessage(i, COLOR_BROWN, string);
    }
   
    Deaths[playerid]++;
    SendDeathMessage(killerid, playerid, reason);
}
Reply
#5

Still doesn't work thanks btw. But i don't see any problem on the script. Maybe we have another script problem that crashs my server.
Reply
#6

Bump. Still doesn't work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)