05.07.2018, 21:39
You don't really need to use sscanf for this, you can simply check to see if the params are empty or not.
For example:
Although rather than sending the message to everyone, I would recommend sending it in a proximity.
SendClientMessageToAll will send this /me to everyone on the server, if you're making a roleplay server, I wouldn't recommend that.
You can do a range check like this:
The code above will search for all the players in the range of the player typing the /me and then display the message to the players in the range.
Up to you though, however you wanna use it.
For example:
PHP код:
CMD:me(playerid, params[])
{
if(strlen(params) == 0) return SendClientMessage(playerid, 0xC4C4C4FF, "Usage: /me [action]");
new string[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s %s", name, params);
SendClientMessageToAll(COLOR_ME, string);
return 1;
}
SendClientMessageToAll will send this /me to everyone on the server, if you're making a roleplay server, I wouldn't recommend that.
You can do a range check like this:
PHP код:
CMD:me(playerid, params[])
{
if(strlen(params) == 0) return SendClientMessage(playerid, 0xC4C4C4FF, "Usage: /me [action]");
new string[128], name[MAX_PLAYER_NAME], Float: Pos[3];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
format(string, sizeof(string), "%s %s", name, params);
foreach(Player, i)
{
if(IsPlayerInRangeOfPoint(i, /*30 is a good range but you can decrease/increase*/30.0, Pos[0], Pos[1], Pos[2]))
{
SendClientMessage(i, COLOR_ME, string);
}
}
return 1;
}
Up to you though, however you wanna use it.