Death message problem
#1

I have this code:

pawn Код:
new deathreason[32];
        if(reason == 0) {format(deathreason, sizeof(deathreason), "Fists");}
        if(reason == 1) {format(deathreason, sizeof(deathreason), "Brass Knuckles");}
        if(reason == 2) {format(deathreason, sizeof(deathreason), "Golf Stick");}
        if(reason == 3) {format(deathreason, sizeof(deathreason), "Nite Stick");}
        if(reason == 4) {format(deathreason, sizeof(deathreason), "Knife");}
        if(reason == 5) {format(deathreason, sizeof(deathreason), "Baseball Bat");}
        if(reason == 6) {format(deathreason, sizeof(deathreason), "Shovel");}
        if(reason == 7) {format(deathreason, sizeof(deathreason), "Pool Cue");}
        if(reason == 8) {format(deathreason, sizeof(deathreason), "Katana");}
        if(reason == 9) {format(deathreason, sizeof(deathreason), "Chainsaw");}
        if(reason == 10){format(deathreason, sizeof(deathreason), "Dildo");}
        if(reason == 11){format(deathreason, sizeof(deathreason), "Small Vibrator");}
        if(reason == 12){format(deathreason, sizeof(deathreason), "Large Vibrator");}
        if(reason == 13){format(deathreason, sizeof(deathreason), "Vibrator");}
        if(reason == 14){format(deathreason, sizeof(deathreason), "Flowers");}
        if(reason == 15){format(deathreason, sizeof(deathreason), "Cane");}
        if(reason == 16){format(deathreason, sizeof(deathreason), "Grenade");}
        if(reason == 17){format(deathreason, sizeof(deathreason), "Smoke Grenade");}
        if(reason == 18){format(deathreason, sizeof(deathreason), "Molotov Cocktail");}
        if(reason == 19){format(deathreason, sizeof(deathreason), "Vehicle Weapon");}
        if(reason == 20){format(deathreason, sizeof(deathreason), "Hydra Flare");}
        if(reason == 21){format(deathreason, sizeof(deathreason), "Jetpack");}
        if(reason == 22){format(deathreason, sizeof(deathreason), "9mm Pistol");}
        if(reason == 23){format(deathreason, sizeof(deathreason), "Silenced 9mm Pistol");}
        if(reason == 24){format(deathreason, sizeof(deathreason), "Desert Eagle");}
        if(reason == 25){format(deathreason, sizeof(deathreason), "Shotgun");}
        if(reason == 26){format(deathreason, sizeof(deathreason), "Sawnoff Shotgun");}
        if(reason == 27){format(deathreason, sizeof(deathreason), "Combat Shotgun");}
        if(reason == 28){format(deathreason, sizeof(deathreason), "Micro SMG");}
        if(reason == 29){format(deathreason, sizeof(deathreason), "MP5");}
        if(reason == 30){format(deathreason, sizeof(deathreason), "AK47");}
        if(reason == 31){format(deathreason, sizeof(deathreason), "M4");}
        if(reason == 32){format(deathreason, sizeof(deathreason), "Tec-9");}
        if(reason == 33){format(deathreason, sizeof(deathreason), "Rifle");}
        if(reason == 34){format(deathreason, sizeof(deathreason), "Sniper Rifle");}
        if(reason == 35){format(deathreason, sizeof(deathreason), "Rocket Launcherr");}
        if(reason == 36){format(deathreason, sizeof(deathreason), "Rocket Launcher");}
        if(reason == 37){format(deathreason, sizeof(deathreason), "Flamethrower");}
        if(reason == 38){format(deathreason, sizeof(deathreason), "Minigun");}
        if(reason == 39){format(deathreason, sizeof(deathreason), "Satchels");}
        if(reason == 40){format(deathreason, sizeof(deathreason), "Detonator");}
        if(reason == 41){format(deathreason, sizeof(deathreason), "Spraycan");}
        if(reason == 42){format(deathreason, sizeof(deathreason), "Fire Extinguisher");}
        if(reason == 43){format(deathreason, sizeof(deathreason), "Camera");}
        if(reason == 44){format(deathreason, sizeof(deathreason), "Nightvision Goggles");}
        if(reason == 45){format(deathreason, sizeof(deathreason), "Infrared Goggles");}
        if(reason == 46){format(deathreason, sizeof(deathreason), "Parachute");}
        if(reason == 47){format(deathreason, sizeof(deathreason), "!>>> Unknown 47 <<<!");}
        if(reason == 48){format(deathreason, sizeof(deathreason), "!>>> Unknown 48 <<<!");}
        if(reason == 49){format(deathreason, sizeof(deathreason), "Vehicle");}
        if(reason == 50){format(deathreason, sizeof(deathreason), "Helicopter Blades");}
        if(reason == 51){format(deathreason, sizeof(deathreason), "Explosion");}
        if(reason == 52){format(deathreason, sizeof(deathreason), "!>>> Unknown 52 <<<!");}
        if(reason == 53){format(deathreason, sizeof(deathreason), "Drowned");}
        if(reason == 54){format(deathreason, sizeof(deathreason), "Splat");}
        if(reason == 55){format(deathreason, sizeof(deathreason), "!>>> Unknown 55 <<<!");}
        if(reason == 255){format(deathreason, sizeof(deathreason), "Died");}
        SendDeathMessage(killerid,playerid,reason);
        GivePlayerMoney(killerid,10000);
        GivePlayerMoney(playerid,-10000);
        new string[128];
        new NamePlayerID[MAX_PLAYER_NAME];
        new NameKillerID[MAX_PLAYER_NAME];
        if( killerid != INVALID_PLAYER_ID && IsPlayerConnected(killerid))
        {
            GetPlayerName(playerid,NamePlayerID,sizeof(NamePlayerID));
            GetPlayerName(killerid,NameKillerID,sizeof(NameKillerID));
            format(string,sizeof(string),"*%s (%d) Died. Killed By: %s (%d)   -   %s",NamePlayerID,playerid,NameKillerID,killerid, deathreason);
            SendClientMessageToAll(0xAA3333AA,string);
// OTHER SHIT BELOW
But for some odd reason, death reasons number 53, 54 and 255 (Drowned, Splat & Died) don't show up When they die from drowning in the water, I want it to show grandTheftOtto (0) Drowned, which should use reason 53. When they die from jumping off a building, I want it to show grandTheftOtto (0) Died. (Splat), which would be reason 54. Finally, if they die without a player killing them, it should show grandTheftOtto (0) Died., which would be reason 255.

Like I said, those 3 reasons don't work and I don't know why, the rest do and show perfectly in my chat to everyone. If someone knows why, please let me know.
Reply
#2

first, i really suggest you to use switch-case.
and the reason for this problem could be because you haven't checked if there is a killer:
pawn Код:
if(killerid != INVALID_PLAYER_ID)
Reply
#3

If I recall correctly, I already have that in my code..

pawn Код:
if( killerid != INVALID_PLAYER_ID && IsPlayerConnected(killerid))
Did you scroll down in that box? It's at the bottom.
Reply
#4

The reason they don't show up is:
If you check the weapon IDs, they have 5 stars behind their name. (*****), which means:
Quote:
Originally Posted by SA-MP Wiki
(*****) Death icon only, used for RPG, hydra, grenade explosions in OnPlayerDeath.
So, I suggest you to remove the reasons which don't work, and replace it with something like..
pawn Код:
} else { deathreason="Unknown death reason"; }
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)