Sending a message to all while using /kill.
#1

I'd like to make the command /kill, and when you do it, you die and everybody in the upper left screen see :
" Playername has suicided ! "
That's what I did so far :
pawn Код:
COMMAND:kill( playerid, params[ ] )
{
    SetPlayerHealth(0)
    SendClientMessageToAll(0xDEEE20FF, string);
   
   return 1;
}
Reply
#2

Код:
// Ontop of your script.

new GlobalMessageString[100];


COMMAND:kill( playerid, params[ ] )
{
    SetPlayerHealth(0)
    format(GlobalMessageString, sizeof(GlobalMessageString), "%s has killed himself.", GetName(playerid), playerid);
	SendClientMessage(playerid, COLOR_WHITE, GlobalMessageString);
   return 1;
}
+Rep if it worked, please.
Reply
#3

Look up the GetPlayerName function. You'll also need to create a separate variable to store the string you'd like to pass to the SendClientMessageToAll function. We'll use the format function to format the string with our desired input.
pawn Код:
new name[ MAX_PLAYER_NAME ];
new string[ 50 ];
GetPlayerName( playerid, name, MAX_PLAYER_NAME );
format( string, sizeof( string ), "%s suicided!", name );
SendClientMessageToAll( 0xDEEE20FF, string );
I highly suggest you look up some more documentation on the basics of Pawn, such as creating variables, how to handle/access them, and how to use them. It'd also be nice to look through all the functions that SA:MP provides, via the Wiki.

EDIT: ^ Don't give reputation to beggers ^
Reply
#4

On top ? I didn't understood, why not in the end ?
Reply
#5

Desperate much chrillz ? Also, you forgot to format the GetPlayerName function ..

Darnell, add this above SetPlayerHealth:

pawn Код:
new name[24] // 24 = max characters in a samp name
GetPlayerName(playerid,name,24);
Replace GetName in Chrillz's line with name
Reply
#6

Quote:
Originally Posted by Darnell
Посмотреть сообщение
On top ? I didn't understood, why not in the end ?
Remove this from ur script:
pawn Код:
COMMAND:kill( playerid, params[ ] )
{
    SetPlayerHealth(0)
    SendClientMessageToAll(0xDEEE20FF, string);
   
   return 1;
}
And add this one:
pawn Код:
COMMAND:kill( playerid, params[ ] )
{
    SetPlayerHealth(playerid,0.0);
    new name[ MAX_PLAYER_NAME ], string[ 50 ];
    GetPlayerName( playerid, name, MAX_PLAYER_NAME );
    format( string, sizeof( string ), "%s suicided!", name );
    SendClientMessageToAll( 0xDEEE20FF, string );
    return 1;
}
Quote:
Originally Posted by Grim_
Посмотреть сообщение
EDIT: ^ Don't give reputation to beggers ^
+1.
Reply
#7

I love the necessity of posting the same thing 3 times to get the point through?
Reply
#8

Thanks everybody .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)