16.06.2013, 20:09
There's no reason to check if a player is logged in on each command as you can do it with one of ZCMD's callbacks. Furthermore, you're dealing with a single string- there's no reason to use sscanf here.
You can't do it in two lines, but it's close enough! And remember, the amount of lines in a script really don't mean a damn thing.
Try searching BEFORE posting next time, please.
You can't do it in two lines, but it's close enough! And remember, the amount of lines in a script really don't mean a damn thing.
pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
if(!IsPlayerLoggedIn(playerid))
{
SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
return 0;
}
return 1;
}
CMD:me(playerid, params[])
{
if(AntiAdv(playerid, params[]))
return 1;
if(strlen(params) < 3) // if the "action" in the /me command was less than 3 characters in length, the command won't process
return 1;
new
string[144];
format(string, sizeof(string), "* %s %s", RPN(playerid), params);
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
return 1;
}
CMD:do(playerid, params[])
{
if(AntiAdv(playerid, params[]))
return 1;
if(strlen(params) < 3) // if the "description" in the /do command was less than 3 characters in length, the command won't process
return 1;
new
string[144];
format(string, sizeof(string), "* %s (( %s ))", params, RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
return 1;
}