Player Suicide Command & Message[NEED HELP ++REP]
#1

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;
}
Reply
#2

Use SendClientMessageToAll.
Reply
#3

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!
Reply
#4

Try this

https://sampwiki.blast.hk/wiki/GetPlayerName
Reply
#5

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
Reply
#6

try this
PHP код:
if(!strcmp("/kill"cmdtexttrue))
{
   new 
str[40], name[MAX_PLAYER_NAME];
   
GetPlayerName(playeridname sizeof(name));
   
SetPlayerHealth(playerid0);
   
format(strsizeof(str), "%s (ID:%d) Suicide!",nameplayerid);
   
SendClientMessageToAll(-1str);
   return 
1;

late
Reply
#7

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.
Reply
#8

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...
Reply
#9

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)