Sending a message to all while using /kill. -
Darnell - 09.08.2011
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;
}
Re: Sending a message to all while using /kill. -
Chrillzen - 09.08.2011
Код:
// 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.
Re: Sending a message to all while using /kill. -
Grim_ - 09.08.2011
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 ^
Re: Sending a message to all while using /kill. -
Darnell - 09.08.2011
On top ? I didn't understood, why not in the end ?
Re: Sending a message to all while using /kill. -
grand.Theft.Otto - 09.08.2011
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
Re: Sending a message to all while using /kill. -
HyperZ - 09.08.2011
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.
Re: Sending a message to all while using /kill. -
Grim_ - 09.08.2011
I love the necessity of posting the same thing 3 times to get the point through?
Re: Sending a message to all while using /kill. -
Darnell - 09.08.2011
Thanks everybody

.