Last kill does not work
#1

I added this line under onplayerdeath When the player is killed sends a message to that person someone can help me fix it
Код:
if(killerid != INVALID_PLAYER_ID)
 	{
		new string[156],WeaponName[24],VictimName[MAX_PLAYER_NAME],KillerName[MAX_PLAYER_NAME];
		GetPlayerName(playerid, VictimName, sizeof (VictimName));
		GetPlayerName(killerid, KillerName, sizeof (KillerName));
  		GetWeaponName(GetPlayerWeapon(killerid), WeaponName, sizeof (WeaponName));
  		format(string, sizeof(string),"you were killed by %s with weapons %s",KillerName,WeaponName);
  		SendClientMessageEx(COLOR_YELLOW,playerid,string);
  		format(string, sizeof(string),"you killed %s with weapons %s",VictimName,WeaponName);
  		SendClientMessageEx(COLOR_YELLOW,killerid,string);
    }
Reply
#2

Quote:
Originally Posted by skiplovebra
Посмотреть сообщение
I added this line under onplayerdeath When the player is killed sends a message to that person someone can help me fix it
Код:
if(killerid != INVALID_PLAYER_ID)
 	{
		new string[156],WeaponName[24],VictimName[MAX_PLAYER_NAME],KillerName[MAX_PLAYER_NAME];
		GetPlayerName(playerid, VictimName, sizeof (VictimName));
		GetPlayerName(killerid, KillerName, sizeof (KillerName));
  		GetWeaponName(GetPlayerWeapon(killerid), WeaponName, sizeof (WeaponName));
  		format(string, sizeof(string),"you were killed by %s with weapons %s",KillerName,WeaponName);
  		SendClientMessageEx(COLOR_YELLOW,playerid,string);
  		format(string, sizeof(string),"you killed %s with weapons %s",VictimName,WeaponName);
  		SendClientMessageEx(COLOR_YELLOW,killerid,string);
    }
I'm not sure if you intentionally changed the order of arguments of SendClientMessageEx, but usually SendClientMessage should be called like this:

Код:
SendClientMessageEx(playerid, COLOR_YELLOW, string);
(color and playerid are swapped)
Reply
#3

Thanks
Reply
#4

SendClientMessageEx is in general a function in which you can format & send the message in the same line, which means you don't have to format it in a string then send it... So I suggest you to change your code into this:

PHP код:
if(killerid != INVALID_PLAYER_ID)
     {
          new 
string[156],WeaponName[24],VictimName[MAX_PLAYER_NAME],KillerName[MAX_PLAYER_NAME];
          
GetPlayerName(playeridVictimNamesizeof (VictimName));
          
GetPlayerName(killeridKillerNamesizeof (KillerName));
          
GetWeaponName(GetPlayerWeapon(killerid), WeaponNamesizeof (WeaponName));
          
format(stringsizeof(string),"you were killed by %s with weapons %s",KillerName,WeaponName);
          
SendClientMessageEx(COLOR_YELLOW,playerid,string);
          
format(stringsizeof(string),"you killed %s with weapons %s",VictimName,WeaponName);
          
SendClientMessageEx(COLOR_YELLOW,killerid,string);
    } 
PHP код:
if(killerid != INVALID_PLAYER_ID
    { 
        new 
WeaponName[24],VictimName[MAX_PLAYER_NAME],KillerName[MAX_PLAYER_NAME]; 
        
GetPlayerName(playeridVictimNamesizeof (VictimName)); 
        
GetPlayerName(killeridKillerNamesizeof (KillerName));
        
GetWeaponName(GetPlayerWeapon(killerid), WeaponNamesizeof (WeaponName)); 
        
SendClientMessageEx(playeridCOLOR_YELLOW"you were killed by %s with weapons %s",KillerName,WeaponName);
        
SendClientMessageEx(killeridCOLOR_YELLOW"you killed %s with weapons %s",VictimName,WeaponName);
    } 
Plus you switched playerid with the color (Syntax: "SendClientMessage(playerid, color, const message[])" ) and it's the same for SendClientMessageEx
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)