SA-MP Forums Archive
Why this CMD didn't work?(+1 REP) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Why this CMD didn't work?(+1 REP) (/showthread.php?tid=334903)



Why this CMD didn't work?(+1 REP) - Andrew97 - 16.04.2012

Код:
 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!


Re: Why this CMD didn't work?(+1 REP) - sampmark05 - 16.04.2012

Код:
 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;
}



Re: Why this CMD didn't work?(+1 REP) - iggy1 - 16.04.2012

You need the macro for isnull.

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



Re: Why this CMD didn't work?(+1 REP) - Andrew97 - 16.04.2012

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


Re: Why this CMD didn't work?(+1 REP) - Andrew97 - 16.04.2012

what was the problem with mine?


Re: Why this CMD didn't work?(+1 REP) - sampmark05 - 16.04.2012

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;
	}



Re: Why this CMD didn't work?(+1 REP) - Andrew97 - 16.04.2012

OMG!!!!


Re: Why this CMD didn't work?(+1 REP) - Mark™ - 16.04.2012

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;
     
}