Player Suicide Command & Message[NEED HELP ++REP] -
Chausar - 31.03.2015
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;
}
Re: Player Suicide Command & Message[NEED HELP ++REP] -
CalvinC - 31.03.2015
Use
SendClientMessageToAll.
Re: Player Suicide Command & Message[NEED HELP ++REP] -
Chausar - 31.03.2015
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!
Re: Player Suicide Command & Message[NEED HELP ++REP] -
ChuckyBabe - 31.03.2015
Try this
https://sampwiki.blast.hk/wiki/GetPlayerName
Re: Player Suicide Command & Message[NEED HELP ++REP] -
JaydenJason - 31.03.2015
Quote:
Originally Posted by Chausar
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;
}
|
pawn Код:
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;
}
https://sampwiki.blast.hk/wiki/GetPlayerName
Re: Player Suicide Command & Message[NEED HELP ++REP] -
JeaSon - 31.03.2015
try this
PHP код:
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
Re: Player Suicide Command & Message[NEED HELP ++REP] -
CalvinC - 31.03.2015
Use GetPlayerName and fomat the message, then send it.
pawn Код:
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
https://sampwiki.blast.hk/wiki/GetPlayerName
https://sampwiki.blast.hk/wiki/Format
EDIT: @JaydenJason, playerid is an integer, not a string.
Re: Player Suicide Command & Message[NEED HELP ++REP] -
Chausar - 31.03.2015
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 © 1997-2006, ITB CompuPhase
1 Error.
I'm noob at scripting...
Re: Player Suicide Command & Message[NEED HELP ++REP] -
CalvinC - 31.03.2015
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.