Error in compiler, when making /report command. -
Goldino - 28.01.2013
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
Re: Error in compiler, when making /report command. -
Roach_ - 28.01.2013
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;
}
Re: Error in compiler, when making /report command. -
Goldino - 28.01.2013
The stock is supposed to be "playerid" not "playername"?
Re: Error in compiler, when making /report command. -
Roach_ - 28.01.2013
Do you listen to me.. ?
Re: Error in compiler, when making /report command. -
daniboi229 - 28.01.2013
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;
}
Re: Error in compiler, when making /report command. -
Threshold - 29.01.2013
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;
}