PDA

View Full Version : Player Suicide Command & Message[NEED HELP ++REP]


Chausar
31/03/2015, 07:22 AM
help me with this. if i typed /kill i want the message appear to all player's left screen Example: Player 1 suicide ! so..what we need to put?

public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp("/kill", cmdtext, true))
{
SetPlayerHealth(playerid, 0);
return 1;
}
return 0;
}

CalvinC
31/03/2015, 07:41 AM
Use SendClientMessageToAll (http://wiki.sa-mp.com/wiki/SendClientMessageToAll).

Chausar
31/03/2015, 07:58 AM
I know that. the problem now is how can i make the playername appear there..example is my name is Chausar and when i type /kill the message appear Chausar (0) Suicide!

ChuckyBabe
31/03/2015, 08:13 AM
Try this :)

http://wiki.sa-mp.com/wiki/GetPlayerName

JaydenJason
31/03/2015, 08:20 AM
help me with this. if i typed /kill i want the message appear to all player's left screen Example: Player 1 suicide ! so..what we need to put?

public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp("/kill", cmdtext, true))
{
SetPlayerHealth(playerid, 0);
return 1;
}
return 0;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp("/kill", cmdtext, true))
{
new name[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, name, sizeof(name))
SetPlayerHealth(playerid, 0);
format(string, sizeof(string), "%s (%s) has committed {FF0000}suicide{FFFFFF}!", name, playerid);
SendClientMessageToAll(0xC4C4C4FF, string);
return 1;
}
return 0;
}

http://wiki.sa-mp.com/wiki/GetPlayerName

JeaSon
31/03/2015, 08:22 AM
try this
if(!strcmp("/kill", cmdtext, true))
{
new str[40], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name , sizeof(name));
SetPlayerHealth(playerid, 0);
format(str, sizeof(str), "%s (ID:%d) Suicide!",name, playerid);
SendClientMessageToAll(-1, str);
return 1;
}

late :(

CalvinC
31/03/2015, 08:26 AM
Use GetPlayerName and fomat the message, then send it.
new Name[MAX_PLAYER_NAME], string[20 + MAX_PLAYER_NAME];
// Declares 2 arrays, "Name" and "string"

GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
// Stores the players name in the "Name" array as a string

format(string, siezeof(string), "%s has killed himself.", Name);
// Formats "string" to contain the message above, where %s will be "Name"

SendClientMessageToAll(-1, string);
// Sends the message "string" contains
http://wiki.sa-mp.com/wiki/GetPlayerName
http://wiki.sa-mp.com/wiki/Format

EDIT: @JaydenJason (http://forum.sa-mp.com/member.php?u=244873), playerid is an integer, not a string.

Chausar
31/03/2015, 09:42 AM
JaydenJason,

i got two error:

D:\Barang2\samp_server\gamemodes\TESTING.pwn(95) : error 001: expected token: ";", but found "-identifier-"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


1 Error.


I'm noob at scripting...

CalvinC
31/03/2015, 09:56 AM
Place a semicolon at the GetPlayerName, since it's a function.
And make sure you used an integer instead of a string as i said above for the playerid.