SA-MP Forums Archive
help killerid message - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: help killerid message (/showthread.php?tid=384538)



help killerid message - Wonderweiss - 12.10.2012

can you guys help me when a player kills other player
to display a message
something like this but i got a error


Код:
SendClientMessage(killerid, COLOR_YELLOW, "Congratulations you killed %s !"); (playerid);
the error:

Код:
C:\Users\Bojan\Desktop\LVDM\gamemodes\lvdm.pwn(311) : warning 215: expression has no effect



Re: help killerid message - CentyPoo - 12.10.2012

pawn Код:
SendClientMessage(killerid, COLOR_YELLOW, "Congratulations you killed %s !", playerid);
Your (playerid) was in the wrong place, when you use %s, %d for example, just place the vars after the string with a comma.

EDIT: playerid isn't a string either, if you wanted names it'd be;
pawn Код:
new pName[MAX_PLAYER_NAME], string[128];
pName = GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(string, sizeof(string), "Congratulations you killed %s !", pName);
SendClientMessage(killerid, COLOR_YELLOW, string);
EDIT again: Thanks for the post below, forgot about format.


Re: help killerid message - Wonderweiss - 12.10.2012

i get this error now
Код:
C:\Users\Bojan\Desktop\LVDM\gamemodes\lvdm.pwn(311) : warning 202: number of arguments does not match definition



Re: help killerid message - [HK]Ryder[AN] - 12.10.2012

wrong code you got there bro.
Use this
Код:
new string[100];
format(string, sizeof(string), "Congratulations you killed %s !", playerid);
SendClientMessage(killerid, COLOR_YELLOW, string);



Re: help killerid message - Wonderweiss - 12.10.2012

@[HK]Ryder[AN] it dosnt work.. no message show


Re: help killerid message - [HK]Ryder[AN] - 12.10.2012

Where did you paste it?Show some code around it.


Re: help killerid message - Wonderweiss - 12.10.2012

here is the whole thing

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new playercash;
	if(killerid == INVALID_PLAYER_ID) {
        SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);
        ResetPlayerMoney(playerid);
        	new string[100];
	format(string, sizeof(string), "Congratulations you killed %s !", playerid);
	SendClientMessage(killerid, COLOR_YELLOW, string);
	} else {
	    	SendDeathMessage(killerid,playerid,reason);
			SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
			playercash = GetPlayerMoney(playerid);
			if (playercash > 0)  {
				GivePlayerMoney(killerid, playercash);
				ResetPlayerMoney(playerid);
			}
			else
			{
			}
     	}
 	return 1;
}



Re: help killerid message - [HK]Ryder[AN] - 12.10.2012

Change this whole thing to
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new playercash;
	if(killerid == INVALID_PLAYER_ID) {
        SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);
        ResetPlayerMoney(playerid);
        	new string[100], pname[MAX_PLAYER_NAME+1];
        GetPlayerName(playerid, pname, sizeof(pname));
	format(string, sizeof(string), "Congratulations you killed %s !", pname);
	SendClientMessage(killerid, -1, string);
	} else {
	    	SendDeathMessage(killerid,playerid,reason);
			SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
			playercash = GetPlayerMoney(playerid);
			if (playercash > 0)  {
				GivePlayerMoney(killerid, playercash);
				ResetPlayerMoney(playerid);
			}
			else
			{
			}
     	}
 	return 1;
}



Re: help killerid message - Wonderweiss - 12.10.2012

it still dosnt work


Re: help killerid message - Emmet_ - 12.10.2012

Lot of mistakes in that code lol

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new playercash;
    if (killerid != INVALID_PLAYER_ID)
    {
        SendDeathMessage(killerid, playerid, reason);
        new string[64], pname[MAX_PLAYER_NAME+1];
        GetPlayerName(playerid, pname, sizeof(pname));
    format(string, sizeof(string), "Congratulations you killed %s !", pname);
    SendClientMessage(killerid, -1, string);
   
    SendDeathMessage(killerid,playerid,reason);
    SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
    playercash = GetPlayerMoney(playerid);
    if (playercash > 0)  
        {
        GivePlayerMoney(killerid, playercash);
        ResetPlayerMoney(playerid);
        }
    }
    else
    {
        ResetPlayerMoney(playerid);
    }
    return 1;
}