SA-MP Forums Archive
Help! Is this report code writed right? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help! Is this report code writed right? (/showthread.php?tid=148761)



Help! Is this report code writed right? - hinto - 18.05.2010

Код:
  if(strcmp(cmd, "/report", true) == 0 || strcmp(cmd, "/re", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
	    GetPlayerName(playerid, sendername, sizeof(sendername));
			new length = strlen(cmdtext);
			while ((idx < length) && (cmdtext[idx] <= ' '))
			{
				idx++;
			}
			new offset = idx;
			new result[64];
			while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
			{
				result[idx - offset] = cmdtext[idx];
				idx++;
			}
			result[idx - offset] = EOS;
			if(!strlen(result))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /report [text]");
				return 1;
			}
			format(string, sizeof(string), "Report from [%d]%s: %s",playerid, sendername, (result));
			ABroadCast(COLOR_YELLOW,string,1);
			ReportLog(string);
			SendClientMessage(playerid, COLOR_YELLOW, "Your Report Message was sent to the Admins.");
	  }
	  return 1;
	}



Re: Help! Is this report code writed right? - luigifan9 - 18.05.2010

Quote:
Originally Posted by hinto
Код:
  if(strcmp(cmd, "/report", true) == 0 || strcmp(cmd, "/re", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
	    GetPlayerName(playerid, sendername, sizeof(sendername));
			new length = strlen(cmdtext);
			while ((idx < length) && (cmdtext[idx] <= ' '))
			{
				idx++;
			}
			new offset = idx;
			new result[64];
			while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
			{
				result[idx - offset] = cmdtext[idx];
				idx++;
			}
			result[idx - offset] = EOS;
			if(!strlen(result))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /report [text]");
				return 1;
			}
			format(string, sizeof(string), "Report from [%d]%s: %s",playerid, sendername, (result));
			ABroadCast(COLOR_YELLOW,string,1);
			ReportLog(string);
			SendClientMessage(playerid, COLOR_YELLOW, "Your Report Message was sent to the Admins.");
	  }
	  return 1;
	}
well, does it work? lol if it works then yes.


Re: Help! Is this report code writed right? - hinto - 18.05.2010

Quote:
Originally Posted by luigifan9
Quote:
Originally Posted by hinto
Код:
  if(strcmp(cmd, "/report", true) == 0 || strcmp(cmd, "/re", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
	    GetPlayerName(playerid, sendername, sizeof(sendername));
			new length = strlen(cmdtext);
			while ((idx < length) && (cmdtext[idx] <= ' '))
			{
				idx++;
			}
			new offset = idx;
			new result[64];
			while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
			{
				result[idx - offset] = cmdtext[idx];
				idx++;
			}
			result[idx - offset] = EOS;
			if(!strlen(result))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /report [text]");
				return 1;
			}
			format(string, sizeof(string), "Report from [%d]%s: %s",playerid, sendername, (result));
			ABroadCast(COLOR_YELLOW,string,1);
			ReportLog(string);
			SendClientMessage(playerid, COLOR_YELLOW, "Your Report Message was sent to the Admins.");
	  }
	  return 1;
	}
well, does it work? lol if it works then yes.
after typing /report server crash