Why this CMD didn't work?(+1 REP)
#1

Код:
 if (strcmp("/me", cmdtext, true) == 0)
{
      if(!cmdtext[3])return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]");
      new str[128];
      GetPlayerName(playerid, str, sizeof(str));
      format(str, sizeof(str), "* %s %s", str, cmdtext[4]);
      SendClientMessageToAll(0xFFFF00AA, str);
      return 1;
}

NO errors!
Reply
#2

Код:
 if (strcmp("/me",params, true) == 0)
{
      if(isnull(params)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /me [action]");
      new string[128];
      GetPlayerName(playerid, string, sizeof(string));
      format(string, sizeof(string), "%s %s", GetPlayerNameEx(playerid), params);
      SendClientMessageToAllEx(0xFFFF00AA, string);
      return 1;
}
Reply
#3

You need the macro for isnull.

Taken from zcmd:
pawn Код:
#define isnull(%1) \
    ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
Reply
#4

I didn't Understand the Format Line what is it?
Reply
#5

what was the problem with mine?
Reply
#6

or use this
Код:
 	if(strcmp(cmd, "/me", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        if(gPlayerLogged[playerid] == 0)
	        {
	            SendClientMessage(playerid, COLOR_GREY, "   You havent logged in yet !");
	            return 1;
	        }
			GetPlayerName(playerid, sendername, sizeof(sendername));
			new length = strlen(cmdtext);
			while ((idx < length) && (cmdtext[idx] <= ' '))
			{
				idx++;
			}
			new offset = idx;
			new result[96];
			while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
			{
				result[idx - offset] = cmdtext[idx];
				idx++;
			}
			result[idx - offset] = EOS;
			if(!strlen(result))
			{
				SendClientMessage(playerid, COLOR_WHITE, "USAGE: /me [action]");
				return 1;
			}
			if(PlayerInfo[playerid][pMask] == 1) format(string, sizeof(string), "* Stranger %s", result);
			else format(string, sizeof(string), "* %s %s", sendername, result);
			ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
		}
		return 1;
	}
Reply
#7

OMG!!!!
Reply
#8

Much shorter and faster with zcmd...

pawn Код:
CMD:me(playerid, params[])
{
    new string[128];
    new pname[128];
    GetPlayerName(playerid, pname, sizeof(pname));
    if(!strlen(params))
    {
       SendClientMessage(playerid, Player, "Usage: /me (text)");
       return 1;
    }
      format(string, sizeof(string), "ME %s(%d): %s", pname, playerid, params);
      SendClientMessageToAll(Player, string);
      return 1;
     
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)