SendDeathMessageEx
#1

Hello, I'm facing some problems with the Deathmessages. When every a player kills someone it sends the message that the player has suicided while a player has killed him ( This happens 75% of the times ). It seems like it doesn't detect the killer.

SendDeathMessageEx
PHP код:
SendDeathMessageEx(playeridkilleridreason)
{
    new 
string[128], killername[MAX_PLAYER_NAME], deathreason[24], modelid;
    if (
reason != INVALID_REASON && !IsPlayerNPC(killerid))
    {
        
modelid killerid != INVALID_PLAYER_ID GetPlayerState(killerid) == PLAYER_STATE_DRIVER GetVehicleModel(GetPlayerVehicleID(killerid)) : 0;
        if (
reason == 31)
        {
            switch (
modelid)
            {
                case 
447deathreason "Sparrow Machine Gun";
                case 
464deathreason "RC Baron Machine Gun";
                case 
476deathreason "Rustler Machine Gun";
                default: 
deathreason "M4";
            }
        }
        else if (
reason == 37)
        {
            
deathreason "Fire";
        }
        else if (
reason == 38)
        {
            switch (
modelid)
            {
                case 
425deathreason "Hunter Machine Gun";
                default: 
deathreason "Minigun";
            }
        }
        else if (
reason == 50)
        {
            switch (
modelid)
            {
                case 
417425447465469487488497501548563deathreason "Helicopter";
                default:
                {
                    
deathreason "Collision";
                    
reason 49;
                }
            }
        }
        else if (
reason == 51)
        {
            switch (
modelid)
            {
                case 
425deathreason "Hunter Missile";
                case 
432deathreason "Rhino Turret";
                case 
520deathreason "Hydra Missile";
                default: 
deathreason "Explosion";
            }
        }
        else
        {
            
format(deathreason24"%s"WeaponName[reason]);
        }
        if (
killerid != INVALID_PLAYER_ID)
        {
               
GetPlayerName(killeridkillernameMAX_PLAYER_NAME);
            
format(string128"* %s has been killed by %s (%s)."GetName(playerid), killernamedeathreason);
        }
        else 
format(string128"* %s has died (%s)."GetName(playerid), deathreason);
    }
    else
    {
        
format(string128"* %s has died (%s)."GetName(playerid), WeaponName[sizeof(WeaponName)-1]);
    }
    
SendClientMessageToAll(COLOR_WHITEstring);
    
SendDeathMessage(killeridplayeridreason);

Also, I have some hits that my skinhit system would be causing this so here take a look 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;

Thanks to anyone who helps!
Reply
#2

PHP код:
SendDeathMessageEx(playeridkilleridreason)
{
    new 
string[128], playername[MAX_PLAYER_NAME], killername[MAX_PLAYER_NAME], weaponn[24], modelid;
    
GetPlayerName(playeridplayernameMAX_PLAYER_NAME);
    if (
reason != INVALID_REASON && !IsPlayerNPC(killerid)) {
        
modelid killerid != INVALID_PLAYER_ID GetPlayerState(killerid) == PLAYER_STATE_DRIVER GetVehicleModel(GetPlayerVehicleID(killerid)) : 0;
        if (
reason == 31) {
            switch (
modelid) {
                case 
447weaponn "Sparrow Machine Gun";
                case 
464weaponn "RC Baron Machine Gun";
                case 
476weaponn "Rustler Machine Gun";
                default: 
weaponn "M4";
            }
        }
        else if (
reason == 37) {
            
weaponn "Fire";
        }
        else if (
reason == 38) {
            switch (
modelid) {
                case 
425weaponn "Hunter Machine Gun";
                default: 
weaponn "Minigun";
            }
        }
        else if (
reason == 50) {
            switch (
modelid) {
                case 
417425447465469487488497501548563weaponn "Helicopter";
                default: {
                    
weaponn "Collision";
                    
reason 49;
                }
            }
        }
        else if (
reason == 51) {
            switch (
modelid) {
                case 
425weaponn "Hunter Missile";
                case 
432weaponn "Rhino Turret";
                case 
520weaponn "Hydra Missile";
                default: 
weaponn "Explosion";
            }
        }
        else {
            
format(weaponn24"%s"WeaponName[reason]);
        }
        if (
killerid != INVALID_PLAYER_ID) {
            
GetPlayerName(killeridkillernameMAX_PLAYER_NAME);
            
format(string128"* %s[%d] has been killed by %s[%d] (%s)."playername,playeridkillername,killeridweaponn);
        }
        else 
format(string128"* %s[%d] has died (%s)."playername,playerid,  weaponn);
    }
    else {
        
format(string128"* %s[%d] has died (%s)."playername,playeridWeaponName[sizeof(WeaponName)-1]);
    }
    
SendClientMessageToAll2(COLOR_WHITEstring);
    
SendDeathMessage(killeridplayeridreason);

try this
Reply
#3

not working. anyone else?
Reply
#4

Why use "skin hit system"? It would not be easier to update for 0.3z(or above)?

https://sampwiki.blast.hk/wiki/Server.cfg#Lag_compensation

...

However, the following code is the cause of suicide deaths, your code is setting player health to 0:

pawn Код:
if(armour < amount)
            {
                new Float:health; GetPlayerHealth(damagedid, health);
                new Float:value = amount-armour;
                SetPlayerArmour(damagedid,0);
                SetPlayerHealth(damagedid,health-value);
                lasthit[damagedid] = playerid;
                return 1;
            }
Reply
#5

Anyway how I can fix this?
Maybe getting the name of the player who has done damage and when the player dies it gives the name of the player that has done the damage?
Reply
#6

Sorry for double posting but I just noticed that this only happens with id 0. if someone kills id 0 it gives the message that the player has suicided. I hope this will help out more
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)