Death message problem
#1

Why i can't see death message when player do sucide or jump from sky...

Код:
    if(reason == 50)
    {
    new Name[MAX_PLAYER_NAME], Message[128];
    GetPlayerName(killerid, Name, sizeof(Name));
    format(Message, sizeof(Message), "%s(%d) has been killed for heli blade kill.", Name, killerid);
    SendClientMessageToAll(red,Message);
    SetPlayerHealth(killerid,0);
    }

    SendDeathMessage(killerid, playerid, reason);
    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), "Cop 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");}
    if(reason == 23){format(deathreason, sizeof(deathreason), "Silenced 9mm");}
    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), "Backpack Bomb");}
    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");}
    
    format(gString, 100, "You have been killed by %s!", PlayerName(killerid));
    SendClientMessage(playerid, red, gString);
    SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
    F_GivePlayerMoney(killerid,500);
    pInfo[playerid][Spawned]    = 0;
    pInfo[playerid][Deaths]++;
	if(IsPlayerConnected(killerid) && killerid != INVALID_PLAYER_ID)
	{
	pInfo[killerid][Kills]++;
	}
 	if( killerid != INVALID_PLAYER_ID ) // if killer is valid player
    {
    TogglePlayerSpectating( playerid, 1 ); // toggle the spectate to enabled for playerid
    PlayerSpectatePlayer( playerid, killerid ); // spectate the killer
    SetTimerEx( "OnPlayerStopSpectate", 10000, false, "i", playerid ); // set a timer that in 10 seconds it will stop spectating
    }

	return 1;
}
Reply
#2

This is not your answer but.. holy fuck that's a lot of if statements, you don't evern need deathreason.. mate, look through your code it's just a big mess atm.
Reply
#3

Because when someone dies from a fall or suicides, killerid is invalid_player_id, and your condition (if) states to send message if killerid is != invalid_player_id.


PS: learn to use switch case.
Reply
#4

What's the point of these if's if there's GetWeaponName?
And as iLearner said it's better to use a switch there and instead of formatting you could simply do
Код:
deathreason = "reason";
And just so you know you don't need brackets if you only got one function after the if statement, this will work as well:
Код:
if (...) format(...);
Reply
#5

Try this.
Код:
new weapName[][] =
{
	"Fists", "Brass Knuckles", "Golf Club", "Nightstick", "Knife", "Baseball Bat", "Shovel", "Pool Cue",
	"Katana", "Chainsaw", "Double-ended Dildo", "Dildo", "Vibrator", "Silver Vibrator", "Flowers", "Cane",
	"Grenade", "Tear Gas", "Molotov Cocktail", "", "", "", "9mm", "Silenced 9mm", "Desert Eagle", "Shotgun",
	"Sawn-off Shotgun", "Combat Shotgun", "Micro Uzi", "MP5", "AK-47", "M4", "Tec9", "Country Rifle", "Sniper Rifle",
	"RPG", "HS Rocket", "Flame Thrower", "Minigun", "Satchel Charge", "Detonator", "Spraycan", "Fire Extinguisher",
	"Camera", "Night Vis. ******s", "Thermal Goggles", "Parachute"
};

public OnPlayerDeath(playerid, killerid, reason)
{
    pInfo[playerid][Spawned] = 0;

	SendClientMessage(playerid, red, "You died!");
    
 	if (killerid != INVALID_PLAYER_ID)
    {
        new PlayerName[24];
        GetPlayerName(killerid, PlayerName, sizeof(PlayerName));
		format(gString, sizeof(gString), "You have been killed by %s(%d) with %s!", PlayerName, killerid, weapName[reason]);
		SendClientMessage(playerid, red, gString);

    	TogglePlayerSpectating(playerid, 1);
    	PlayerSpectatePlayer(playerid, killerid);
    	SetTimerEx("OnPlayerStopSpectate", 10000, false, "i", playerid);

		pInfo[playerid][Deaths]++;
    	pInfo[killerid][Kills]++;
    	
	    SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
   		F_GivePlayerMoney(killerid, 500);
    	
		SendDeathMessage(killerid, playerid, reason);
	}
	else
	{
		SendDeathMessage(INVALID_PLAYER_ID, playerid, reason);
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)