Error in compiler, when making /report command.
#1

Hey guys, I just finished making a Report command for my server. Here is the command:

Код:
CMD:report(playerid, params[])
{
   new player1, str[150], reason[66];
   if(sscanf(params,"ds[66]", player1, reason)) return SendClientMessage(playerid, 0x009DFFFF,"USAGE:{FFFFFF} /report [ID] [Reason]");
   if(IsPlayerConnected(player1))
   {
	  format(str, sizeof(str),"--|New Report|-- %s has reported. Reason: %s", PlayerName(playerid), PlayerName(player1), reason);
	  MessageToAdmins(0x006AFFFF, str);
	  SendClientMessage(playerid, 0x0080FFFF,"Your report has been sent to all online Admins. Please be patient!");
   }
   else return SendClientMessage(playerid, 0xFF0000FF, "ERROR:{FFFFFF} This player is not connected");
   return 1;
}
And I get these errors:

Код:
C:\DOCUME~1\DANNY~1.YOU\MYDOCU~1\CNRSER~1\GAMEMO~1\Testing.pwn(714) : error 017: undefined symbol "playerid"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Please help! Thanks
Reply
#2

Your PlayerName function should be like that:
pawn Код:
stock PlayerName(playerid)
{
    new Name[MAX_PLAYER_NAME + 1];
    GetPlayerName(playerid, Name, MAX_PLAYER_NAME + 1);
    return Name;
}
The command:
pawn Код:
CMD:report(playerid, params[])
{
    new player1, str[150], reason[66];
    if(sscanf(params,"us[66]", player1, reason)) return SendClientMessage(playerid, 0x009DFFFF,"USAGE:{FFFFFF} /report [ID] [Reason]");
    if(IsPlayerConnected(player1))
    {
        format(str, sizeof(str),"--|New Report|-- %s has reported. Reason: %s", PlayerName(playerid), PlayerName(player1), reason);
        MessageToAdmins(0x006AFFFF, str);
        SendClientMessage(playerid, 0x0080FFFF,"Your report has been sent to all online Admins. Please be patient!");
    }
    else return SendClientMessage(playerid, 0xFF0000FF, "ERROR:{FFFFFF} This player is not connected");
    return 1;
}
Reply
#3

The stock is supposed to be "playerid" not "playername"?
Reply
#4

Do you listen to me.. ?
Reply
#5

This should work, i removed your use of the PlayerName(); function from the command as i cannot see how that is coded and to get it to work while testing it was easier to do this method. anyway here is the command

pawn Код:
CMD:report(playerid, params[])
{
    new player1, str[150], reason[66], pName[30], p1Name[30];
    GetPlayerName(playerid,pName,30);
    GetPlayerName(player1,p1Name,30);
    if(sscanf(params,"us[66]", player1, reason)) return SendClientMessage(playerid, 0x009DFFFF,"USAGE:{FFFFFF} /report [ID] [Reason]");
    if(IsPlayerConnected(player1)) return SendClientMessage(playerid, 0xFF0000FF, "ERROR:{FFFFFF} This player is not connected");
    format(str, sizeof(str),"--|New Report|-- %s has reported. Reason: %s", pName, p1Name, reason);
    MessageToAdmins(0x006AFFFF, str);
    SendClientMessage(playerid, 0x0080FFFF,"Your report has been sent to all online Admins. Please be patient!");
    return 1;
}
Reply
#6

Wouldn't work... because you are using the variable 'player1' before it has been used in the sscanf function. Therefore it would return a value of 0 by default, and would end up getting ID 0's name instead.

pawn Код:
CMD:report(playerid, params[])
{
    new player1, str[150], reason[66];
    if(sscanf(params,"us[66]", player1, reason)) return SendClientMessage(playerid, 0x009DFFFF,"USAGE:{FFFFFF} /report [ID] [Reason]");
    if(IsPlayerConnected(player1)) return SendClientMessage(playerid, 0xFF0000FF, "ERROR:{FFFFFF} This player is not connected");
    new pName[24], p1Name[24];
    GetPlayerName(playerid,pName,24);
    GetPlayerName(player1,p1Name,24);
    format(str, sizeof(str),"--|New Report|-- %s has reported %s | Reason: %s", pName, p1Name, reason);
    MessageToAdmins(0x006AFFFF, str);
    SendClientMessage(playerid, 0x0080FFFF,"Your report has been sent to all online Admins. Please be patient!");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)