Death messages doesn't send for id 0
#1

Hey, So I have this weird bug where if someone kills id 0 it won't show it in the deathlog and the kills and deaths won't increase but when the player relogs with the same id it gets fixed somehow. The server doesn't detect if id 0 has been killed it shows as if he suicided but when he relogs it gets fixed.

OnPlayerDeath
PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
       new 
string[128], killername[MAX_PLAYER_NAME];
       
GetPlayerName(lasthit[playerid], killernameMAX_PLAYER_NAME);
    if(
killstreak[playerid] >= 3)
    {
     
format(string,sizeof(string), "~ %s has ended %s's killstreak"killernameGetName(playerid));
     
SendClientMessageToAll(COLOR_ORANGEstring);
     
SetPlayerColor(playeridCOLOR_WHITE);
    }
    
killstreak[playerid] = 0;
    
HandleKS(killerid);
    
ResetPlayerWeapons(playerid);
    
GameTextForPlayer(playerid,"~r~~h~WASTED",8000,1);
    if(
PlayerInfo[killerid][pDonator] == 1)
    {
        
GivePlayerCash(killerid200);
    }
    else {
        
GivePlayerCash(killerid100);
    }
    
SetPlayerScore(killeridGetPlayerScore(killerid) + 1);
    
GivePlayerCash(killerid100);
    
PlayerInfo[killerid][pKills]++;
    
PlayerInfo[playerid][pDeaths]++;
    
SaveAccountStats(playerid);
       if(
lasthit[playerid] == INVALID_PLAYER_ID)
    {
        
SendDeathMessage(INVALID_PLAYER_IDplayeridreason);
        return 
1;
    }
    if(
lasthit[playerid] != INVALID_PLAYER_ID)
     {
        
format(stringsizeof(string), "* %s[%d] has been killed by %s."GetName(playerid),playeridkillername);
         
SendDeathMessage(lasthit[playerid],playerid,GetPlayerWeapon(lasthit[playerid]));
         
SendClientMessageToAll(COLOR_WHITEstring);
         return 
1;
     }
     
lasthit[playerid] = INVALID_PLAYER_ID;
    return 
1;

Also I guess this is caused by the skinhit system.

PHP код:
public OnPlayerGiveDamage(playeriddamagedidFloatamountweaponid)
{
    if(
damagedid != INVALID_PLAYER_ID)
    {
        new 
Float:armourGetPlayerArmour(damagedid,armour);
        if(
armour 1)
        {
            new 
Float:healthGetPlayerHealth(damagedidhealth);
            
SetPlayerHealth(damagedid,health-amount);
            
lasthit[damagedid] = playerid;
            return 
1;
        }
        if(
armour 0)
        {
            if(
armour amount)
            {
                new 
Float:healthGetPlayerHealth(damagedidhealth);
                new 
Float:value amount-armour;
                
SetPlayerArmour(damagedid,0);
                
SetPlayerHealth(damagedid,health-value);
                
lasthit[damagedid] = playerid;
                return 
1;
            }
            if(
armour amount)
            {
                
SetPlayerArmour(damagedid,armour-amount);
                
lasthit[damagedid] = playerid;
                return 
1;
            }
            return 
1;
        }
        return 
1;
    }
    return 
1;

Also I know I made this topic before but this isn't the same topic I fixed most of the stuff myself from the old topic but I can't fix this. This just seems weird.
Reply
#2

This is awfully wrong you see, why do this:
PHP код:
if(lasthit[playerid] == INVALID_PLAYER_ID

When you can do this:
PHP код:
if(killerid != INVALID_PLAYER_ID)



It's the exact same thing, your last hit can not be accurate at all.

Change those "lasthit" checks to killerid checks for validity.
Reply
#3

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
It's the exact same thing, your last hit can not be accurate at all.
When I seen this thread, and your response, posted earlier, I held back from posting because I wasn't sure.

There's something they're attempting to do with all this. Maybe they're inverting something unintentionally? Checking something, instead of setting something?


Maybe they're supposed to be setting lasthurt as they died, and it should be invalid, but it's come about as a check, and hasn't glitched enough to be noticed until this point?


-Edit- Nope, they've got that in there too...
Reply
#4

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
This is awfully wrong you see, why do this:
PHP код:
if(lasthit[playerid] == INVALID_PLAYER_ID

When you can do this:
PHP код:
if(killerid != INVALID_PLAYER_ID)



It's the exact same thing, your last hit can not be accurate at all.

Change those "lasthit" checks to killerid checks for validity.
Sometimes my code sets the health to 0 resulting in the player suiciding but it also sets a variable that checks the player who has performed the last shot and so sends the death message with the last shot variable. I'm so confused. What should I do?
Reply
#5

Quote:
Originally Posted by Exhibit
Посмотреть сообщение
Sometimes my code sets the health to 0 resulting in the player suiciding but it also sets a variable that checks the player who has performed the last shot and so sends the death message with the last shot variable. I'm so confused. What should I do?
What's the other areas (Callbacks and functions), that you are using that lasthit array?

Where are you setting their health to 0 to make them die like that?
Reply
#6

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
What's the other areas (Callbacks and functions), that you are using that lasthit array?

Where are you setting their health to 0 to make them die like that?
These are the only callbacks that are using the array.

PHP код:
public OnPlayerGiveDamage(playeriddamagedidFloatamountweaponid

    if(
damagedid != INVALID_PLAYER_ID
    { 
        new 
Float:armourGetPlayerArmour(damagedid,armour); 
        if(
armour 1
        { 
            new 
Float:healthGetPlayerHealth(damagedidhealth); 
            
SetPlayerHealth(damagedid,health-amount); 
            
lasthit[damagedid] = playerid
            return 
1
        } 
        if(
armour 0
        { 
            if(
armour amount
            { 
                new 
Float:healthGetPlayerHealth(damagedidhealth); 
                new 
Float:value amount-armour
                
SetPlayerArmour(damagedid,0); 
                
SetPlayerHealth(damagedid,health-value); 
                
lasthit[damagedid] = playerid
                return 
1
            } 
            if(
armour amount
            { 
                
SetPlayerArmour(damagedid,armour-amount); 
                
lasthit[damagedid] = playerid
                return 
1
            } 
            return 
1
        } 
        return 
1
    } 
    return 
1

Reply
#7

You don't get it buddy, spare yourself the torture, replace all of the if(lasthit[ != invalid_player_id) with killerid like if(killerid != INVALID_PLAYER_ID)

this is never going to be accurate (because of the kill shot) and moreover WHY ARE U DOING IT IN THE FIRST PLACE you know? cuz the last hit is already caught by the system and stored in the killerid param in the OnPlayerDeath callback so why why why?
Reply
#8

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
You don't get it buddy, spare yourself the torture, replace all of the if(lasthit[ != invalid_player_id) with killerid like if(killerid != INVALID_PLAYER_ID)

this is never going to be accurate (because of the kill shot) and moreover WHY ARE U DOING IT IN THE FIRST PLACE you know? cuz the last hit is already caught by the system and stored in the killerid param in the OnPlayerDeath callback so why why why?
doesn't work still the same.
Reply
#9

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
this is never going to be accurate (because of the kill shot) and moreover WHY ARE U DOING IT IN THE FIRST PLACE you know? cuz the last hit is already caught by the system and stored in the killerid param in the OnPlayerDeath callback so why why why?
Are you sure?

If a player gets shot by a player, then jumps off something and dies, then killerid will be invalid, but lasthit won't...
Reply
#10

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Are you sure?

If a player gets shot by a player, then jumps off something and dies, then killerid will be invalid, but lasthit won't...
Wtf? why would you do that lol! look at his code, he's sending death message WITH THE LAST HIT ID (he assumed it was the killer) so it is the same thing!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)