Report system...
#1

When I use /readreport it just gives me
Quote:

Reported nothing for: nothing
Nothing is that it doesn't tells me anything. I got absolute no errors. But this is the code of /report and /read report:
/report:
Код:
	else if(strcmp(cmd, "/report", true) == 0) {
	new tmp[256], tmp2[256];
	tmp = strtok(cmdtext, idx), tmp2 = strtok(cmdtext, idx);
	if(!strlen(tmp2)) SendClientMessage(playerid, COLOR_RED, "USAGE: /report [ID] [Reason]");
	else if(!IsPlayerConnected(strval(tmp))) SendClientMessage(playerid, COLOR_RED, "Invalid ID");
	else {
	PlayerInfo[playerid][activereport] = 1, PlayerInfo[playerid][reporttext] = strval(tmp2), PlayerInfo[playerid][reportname] = strval(tmp);
	new name[256], name2[256];
	GetPlayerName(playerid, name, 256);
	GetPlayerName(playerid, name2, 256);
	printf("Player %s has just reported %s", name, name2);
	new string[256];
	format(string, 256, "Player %s has just reported %s", name, name2);
	SendClientMessage(playerid, COLOR_DARKGREEN, string);
	}
	return 1;
	}
/readreport:
Код:
    else if(strcmp(cmd, "/readreport", true) == 0)
    {
	   new tmp[256];
	   tmp = strtok(cmdtext, idx);
	   if(PlayerInfo[playerid][Level] == 1) return 1;
	   else if(!strlen(tmp)) SendClientMessage(playerid, COLOR_RED, "USAGE: /readreport [playerid]");
	   else if(!IsPlayerConnected(strval(tmp))) SendClientMessage(playerid, COLOR_RED, "Invalid player ID");
	   else
	   {
		  new string[256], string2[256], name[256], name2[256], reportname2, reporttext2;
		  GetPlayerName(playerid, name, sizeof(name)), GetPlayerName(strval(tmp), name2, sizeof(name2));
		  format(string, sizeof(string), "%s is checking your report", name);
		  SendClientMessage(strval(tmp), COLOR_GREEN, string);
		  reportname2 = PlayerInfo[playerid][reportname];
		  reporttext2 = PlayerInfo[playerid][reporttext];
		  format(string2, sizeof(string2), "Reported %s for: %s", reportname2, reporttext2);
		  SendClientMessage(playerid, COLOR_GREEN, string2);
	   }
	   return 1;
    }
Reply
#2

You should remove strval(), because they are strings.
Reply
#3

You're saving your strings (reportname+reporttext) as integers and trying to read them as strings.


Quote:
Originally Posted by armyoftwo
Посмотреть сообщение
pawn Код:
else if(strcmp(cmd, "/report", true) == 0) {
    new tmp[256], tmp2[256];
    tmp = strtok(cmdtext, idx), tmp2 = strtok(cmdtext, idx);
    if(!strlen(tmp2)) SendClientMessage(playerid, COLOR_RED, "USAGE: /report [ID] [Reason]");
    else if(!IsPlayerConnected(strval(tmp))) SendClientMessage(playerid, COLOR_RED, "Invalid ID");
    else {

    new name[256], name2[256];
    GetPlayerName(playerid, name, 256); //<-----
    GetPlayerName(playerid, name2, 256); //<-----
    printf("Player %s has just reported %s", name, name2);
    new string[256];
    format(string, 256, "Player %s has just reported %s", name, name2);
    SendClientMessage(playerid, COLOR_DARKGREEN, string);
    }
    return 1;
    }
Try this.
name and name2 will be 'playerid'
Reply
#4

Quote:
Originally Posted by SilentHuntR
Посмотреть сообщение
You're saving your strings (reportname+reporttext) as integers and trying to read them as strings.




name and name2 will be 'playerid'
I was editing the code, i messed something up.
Reply
#5

Quote:
Originally Posted by SilentHuntR
Посмотреть сообщение
You're saving your strings (reportname+reporttext) as integers and trying to read them as strings.
I removed them and just added them to simple "tmp" instead of "strval(tmp)" but then I receive this:
Код:
C:\Users\Waleed Malik\Desktop\samp03csvr_win32_1\gamemodes\dss.pwn(619) : error 006: must be assigned to an array
C:\Users\Waleed Malik\Desktop\samp03csvr_win32_1\gamemodes\dss.pwn(619) : error 006: must be assigned to an array
Please help how to solve this.
Quote:
Originally Posted by SilentHuntR
Посмотреть сообщение
name and name2 will be 'playerid'
No, I added strval(tmp) because that will be the name of the person we are reporting.
Reply
#6

test
Reply
#7

Post all your code here.

With [pawn] [/pawn}
Reply
#8

pawn Код:
else if(strcmp(cmd, "/report", true) == 0) {
    new tmp[256], tmp2[256];
    tmp = strtok(cmdtext, idx), tmp2 = strtok(cmdtext, idx);
    if(!strlen(tmp2)) SendClientMessage(playerid, COLOR_RED, "USAGE: /report [ID] [Reason]");
    else if(!IsPlayerConnected(strval(tmp))) SendClientMessage(playerid, COLOR_RED, "Invalid ID");
    else {
    new name[256], name2[256];
    GetPlayerName(playerid, name, 256);
    GetPlayerName(playerid, name2, 256);
    PlayerInfo[playerid][activereport] = 1, PlayerInfo[playerid][reporttext] = tmp2, PlayerInfo[playerid][reportname] = name2;
    printf("Player %s has just reported %s", name, name2);
    new string[256];
    format(string, 256, "Player %s has just reported %s", name, name2);
    SendClientMessage(playerid, COLOR_DARKGREEN, string);
    }
    return 1;
    }
Код:
C:\Users\Waleed Malik\Desktop\samp03csvr_win32_1\gamemodes\dss.pwn(579) : error 006: must be assigned to an array
C:\Users\Waleed Malik\Desktop\samp03csvr_win32_1\gamemodes\dss.pwn(579) : error 006: must be assigned to an array
Reply
#9

shouldnt that
pawn Код:
new name[256], name2[256];
Be like
pawn Код:
new name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME]
Reply
#10

Reason for that is beacause you will not find a player's name in sa-mp with 256 characters. Thea max is 32. Hence MAX_PLAYER_NAME is 32 characters. So to use 256 you have wasted 224 bytes.
Reply
#11

Thank you for telling me that, also this:
pawn Код:
PlayerInfo[playerid][activereport] = 1, PlayerInfo[playerid][reporttext] = tmp2, PlayerInfo[playerid][reportname] = name2;
This gives me some errors,
Quote:

C:\Users\Waleed Malik\Desktop\samp03csvr_win32_1\gamemodes\dss.pwn (594) : error 006: must be assigned to an array
C:\Users\Waleed Malik\Desktop\samp03csvr_win32_1\gamemodes\dss.pwn (594) : error 006: must be assigned to an array

These both errors are about the pawn code. Please tell me how to fix them.
Reply
#12

Quote:
Originally Posted by sabreman
Посмотреть сообщение
Thank you for telling me that, also this:
pawn Код:
PlayerInfo[playerid][activereport] = 1, PlayerInfo[playerid][reporttext] = tmp2, PlayerInfo[playerid][reportname] = name2;
This gives me some errors,

These both errors are about the pawn code. Please tell me how to fix them.
you must use format().

pawn Код:
PlayerInfo[playerid][activereport] = 1, format(PlayerInfo[playerid][reporttext], sizeof(PlayerInfo[playerid][reporttext]), "%s", tmp2), format(PlayerInfo[playerid][reportname], sizeof(PlayerInfo[playerid][reportname]), "%s", name2);
Reply
#13

Don't use else if for strcmp commands.
Reply
#14

Can anyone fix these code and give me a fixed and working code for me:
pawn Код:
else if(strcmp(cmd, "/report", true) == 0) {
    new tmp[256], tmp2[256];
    tmp = strtok(cmdtext, idx), tmp2 = strtok(cmdtext, idx);
    if(!strlen(tmp2)) SendClientMessage(playerid, COLOR_RED, "USAGE: /report [ID] [Reason]");
    else if(!IsPlayerConnected(strval(tmp))) SendClientMessage(playerid, COLOR_RED, "Invalid ID");
    else {
    new name[256], name2[256], report1[256], report2[32];
    GetPlayerName(playerid, name, 256);
    GetPlayerName(strval(tmp), name2, 256);
    format(report1, 256, "%s", tmp2);
    format(report2, 32, "%s", name2);
    PlayerInfo[playerid][activereport] = 1, PlayerInfo[playerid][reporttext] = report1, PlayerInfo[playerid][reportname] = report2;
    printf("Player %s has just reported %s", name, name2);
    new string[256];
    new i;
    for(i = 0; i < MAX_PLAYERS; i++)
    {
       if(PlayerInfo[i][Level] != 1)
       {
          format(string, 256, "Player %s has just reported %s", name, name2);
          SendClientMessage(playerid, COLOR_DARKGREEN, string);
       }
       else if(IsPlayerAdmin(i))
       {
          format(string, 256, "Player %s has just reported %s", name, name2);
          SendClientMessage(playerid, COLOR_DARKGREEN, string);
       }
    }
    }
    return 1;
    }
Reply
#15

I am sorry but please give me the working code
Reply
#16

Help me please
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)