help me with command /report -
Hugoca - 01.12.2012
Hi.Today i have problem with /report command.When i use it i get the message Nick has report Nick.Reason:
pawn Код:
if(strcmp(cmd, "/report", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /report [Playerid] [text]");
return 1;
}
new para1;
new text;
para1 = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
text = strval(tmp);
if(IsPlayerConnected(para1))
{
if(para1 != INVALID_PLAYER_ID)
{
GetPlayerName(para1, giveplayer, sizeof(giveplayer));
format(string, sizeof(string), "Your report has been send to all online admins");
SendClientMessage(para1, COLOR_LIGHTBLUE, string);
if(PlayerInfo[playerid][pAdmin] >= 1)
{
format(string, sizeof(string), "%s has report %s.Reason:%s",giveplayer,PlayerName(playerid),text);
SendClientMessage(para1, COLOR_LIGHTBLUE, string);
}
}
}
}
return 1;
}
Re: help me with command /report -
Alcatraz Gaming - 01.12.2012
Explain elaborately. Code is alright, what problem do you have?
Re: help me with command /report -
Hugoca - 01.12.2012
When player use it admins get the message "Nick has report Nick.Reason:"
Re: help me with command /report -
[MM]RoXoR[FS] - 01.12.2012
I would SERIOUSLY recommend to use SSCANF and ZCMD/YCMD
pawn Код:
CMD:report(playerid,params[])
{
new id,reason[50];
if(sscanf(params,"us[50]",id,reason)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /report [Playerid] [text]");
if(id==INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"Invalid ID used");
new iName[MAX_PLAYER_NAME],tName[MAX_PLAYER_NAME],str[120];
GetPlayerName(playerid,iName,sizeof(iName));
GetPlayerName(id,tName,sizeof(tName));
format(str,sizeof(str),"%s[%d] has reported %s[%d] for %s",iName,playerid,tName,id,reason);
for(new i=0;i<MAX_PLAYERS;++i)
{
if(IsPlayerConnected(i) && PlayerInfo[i][pAdmin] >=1)
SendClientMessage(i,COLOR_LIGHTBLUE,str);
}
SendClientMessage(playerid,COLOR_LIGHTBLUE,"Your report has been send to all online admins");
return 1;
}
Re: help me with command /report -
Hugoca - 01.12.2012
i'm using strcmp for all my commands.Now i need report
Re: help me with command /report -
[MM]RoXoR[FS] - 01.12.2012
The problem with your code is here :
It should be string.
Also make sure
Код:
stock PlayerName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
return name;
}
Solution
pawn Код:
if(strcmp(cmd, "/report", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /report [Playerid] [text]");
return 1;
}
new para1;
new text[50];
para1 = ReturnUser(tmp);
text = strtok(cmdtext, idx);
if(IsPlayerConnected(para1))
{
if(para1 != INVALID_PLAYER_ID)
{
format(string, sizeof(string), "Your report has been send to all online admins");
SendClientMessage(para1, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "%s has report %s.Reason:%s",PlayerName(para1),PlayerName(playerid),text);
for(new i =0;i<MAX_PLAYERS;++i)
if(PlayerInfo[i][pAdmin] >= 1 && IsPlayerConnected(i))
{
SendClientMessage(i, COLOR_LIGHTBLUE, string);
}
}
}
}
return 1;
}
Re: help me with command /report -
Hugoca - 01.12.2012
it's works now.Thanks