Another /report bug..
#1

Same problem in this code, how can I get it so at the place the playername/id should be I cannot enter anything else, and if the player is not online it gives a message its not online?

Код:
	if(strcmp(cmd, "/report", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        if(JustReported[playerid] == 1)
	        {
	            SendClientMessage(playerid, COLOR_GREY, "Wait 20 seconds after sending a next /report ! ");
	            return 1;
	        }
			GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
	        GetPlayerName(playerid, sendername, sizeof(sendername));
			new length = strlen(cmdtext);
			while ((idx < length) && (cmdtext[idx] <= ' '))
			{
				idx++;
			}
			new giveplayerid;
			giveplayerid = ReturnUser(tmp);
			if(IsPlayerNPC(giveplayerid)) return 1;
			new offset = idx;
			new result[128];
			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: /report [player] [reason]");
				return 1;
			}
			if(PlayerInfo[playerid][pReportMuted] == 1)
			{
			    return SendClientMessage(playerid, COLOR_RED, "You are muted from sending any /reports!");
			}
			JustReported[playerid] = 1;
			SetTimerEx("ReportReset", 20000, false, "i", playerid);
			format(string, sizeof(string), "%s reporting %s: %s", RemoveUnderScore(playerid), RPN(giveplayerid), (result));
			ABroadCast(COLOR_RED, string, 1);
			SendClientMessage(playerid, COLOR_YELLOW, "Your report was succesfully sent.");
			Reported[playerid] = 1;
		}
	    return 1;
	}
Reply
#2

strcmp is so old school.. You should consider working with zcmd.
pawn Код:
CMD:report(playerid, params[])
{
    new iPlayer, reason[124];
    if(sscanf(params, "us[128]", iPlayer, reason)) return SendClientMessage(playerid, -1 ,"/report [id/nick] [reason]");
    if(iPlayer == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1 ,"Player not connected"); // "if player not connected"
    if(PlayerInfo[playerid][pReportMuted]) return SendClientMessage(playerid, COLOR_RED, "You are muted from sending any /reports!");
    JustReported[playerid] = 1;
    SetTimerEx("ReportReset", 20000, false, "i", playerid);
    format(string, sizeof(string), "%s reporting %s: %s", RemoveUnderScore(playerid), RPN(iPlayer), (result));
    ABroadCast(COLOR_RED, string, 1);
    SendClientMessage(playerid, COLOR_YELLOW, "Your report was succesfully sent.");
    Reported[playerid] = 1;
    return 1;
}
Reply
#3

Quote:
Originally Posted by Loot
Посмотреть сообщение
strcmp is so old school.. You should consider working with zcmd.
pawn Код:
CMD:report(playerid, params[])
{
    new iPlayer, reason[124];
    if(sscanf(params, "us[128]", iPlayer, reason)) return SendClientMessage(playerid, -1 ,"/report [id/nick] [reason]");
    if(iPlayer == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1 ,"Player not connected"); // "if player not connected"
    if(PlayerInfo[playerid][pReportMuted]) return SendClientMessage(playerid, COLOR_RED, "You are muted from sending any /reports!");
    JustReported[playerid] = 1;
    SetTimerEx("ReportReset", 20000, false, "i", playerid);
    format(string, sizeof(string), "%s reporting %s: %s", RemoveUnderScore(playerid), RPN(iPlayer), (result));
    ABroadCast(COLOR_RED, string, 1);
    SendClientMessage(playerid, COLOR_YELLOW, "Your report was succesfully sent.");
    Reported[playerid] = 1;
    return 1;
}
idk whether that code works but u made an error in that, like typo
pawn Код:
CMD:report(playerid, params[])
{
    new iPlayer, reason[124];
    if(sscanf(params, "us[128]", iPlayer, reason)) return SendClientMessage(playerid, -1 ,"/report [id/nick] [reason]");
    if(iPlayer == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1 ,"Player not connected"); // "if player not connected"
    if(PlayerInfo[playerid][pReportMuted] == 1) return SendClientMessage(playerid, COLOR_RED, "You are muted from sending any /reports!");
    JustReported[playerid] = 1;
    SetTimerEx("ReportReset", 20000, false, "i", playerid);
    format(string, sizeof(string), "%s reporting %s: %s", RemoveUnderScore(playerid), RPN(iPlayer), (result));
    ABroadCast(COLOR_RED, string, 1);
    SendClientMessage(playerid, COLOR_YELLOW, "Your report was succesfully sent.");
    Reported[playerid] = 1;
    return 1;
}
u just did
pawn Код:
PlayerInfo[playerid][pReportMuted]
Which Should Be
PlayerInfo[playerid][pReportMuted] == 1
This forum requires that you wait 240 seconds between posts. Please try again in 12 seconds.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)