PDA

View Full Version : Help with report cmd...


Azzeto
11/10/2011, 10:00 AM
I posted earlier and I needed help to send a message to admins, Iv figured that out but now I get this wierd error me and my friend cant figure out..
CMD:report(playerid,params[]){
new string[128],id,reason;
if(sscanf(params,"us",id,reason)) return SendClientMessage(playerid,COLOR_GRAY,"SYNTAX: /report [id] [reason]");
else if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_GRAY, "ERROR: Player is not connected!");
format(string,sizeof(string),"%s has reported %s: %s",GetName(playerid),GetName(id),reason);
SendToAdmins(COLOR_YELLOW,string);
return 1;
}

When I go ingame and do /report 0 test it says Player not connected
But If I Type
/report 0 t it works.. any one know why?

Kush
11/10/2011, 10:03 AM
I posted earlier and I needed help to send a message to admins, Iv figured that out but now I get this wierd error me and my friend cant figure out..
CMD:report(playerid,params[]){
new string[128],id,reason;
if(sscanf(params,"us",id,reason)) return SendClientMessage(playerid,COLOR_GRAY,"SYNTAX: /report [id] [reason]");
else if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_GRAY, "ERROR: Player is not connected!");
format(string,sizeof(string),"%s has reported %s: %s",GetName(playerid),GetName(id),reason);
SendToAdmins(COLOR_YELLOW,string);
return 1;
}

When I go ingame and do /report 0 test it says Player not connected
But If I Type
/report 0 t it works.. any one know why?

Maybe because you haven't specified a length for the string(reason)?

CMD:report(playerid,params[]){
new string[128],id,reason;
if(sscanf(params,"us[128]",id,reason)) return SendClientMessage(playerid,COLOR_GRAY,"SYNTAX: /report [id] [reason]");
else if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_GRAY, "ERROR: Player is not connected!");
format(string,sizeof(string),"%s has reported %s: %s",GetName(playerid),GetName(id),reason);
SendToAdmins(COLOR_YELLOW,string);
return 1;
}

TheMaddox
11/10/2011, 10:03 AM
Test this one?


CMD:report(playerid, params[])
}
if(isnull(params)) return SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /report [text]");

JustReported[playerid]=25;
SendReportToQue(playerid, params);
SendClientMessageEx(playerid, COLOR_YELLOW, "Your report message was sent to the Admins.");
return 1;

Wesley221
11/10/2011, 10:04 AM
if(sscanf(params,"us[128]",id,reason)) return SendClientMessage(playerid,COLOR_GRAY,"SYNTAX: /report [id] [reason]");
You need to asign the size of the string in the sscanf line aswell
Edit
Ninjas were faster :@

Kush
11/10/2011, 10:05 AM
Test this one?


CMD:report(playerid, params[])
}
if(isnull(params)) return SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /report [text]");

JustReported[playerid]=25;
SendReportToQue(playerid, params);
SendClientMessageEx(playerid, COLOR_YELLOW, "Your report message was sent to the Admins.");
return 1;

What's the point of copying this from something or someone else?

Azzeto
11/10/2011, 10:08 AM
Posted to early.. Still same error x.x using sscanf 1

Jafet_Macario
11/10/2011, 11:56 AM
CMD:report(playerid,params[])
{
new string[128], id, reason[35];
if(sscanf(params,"us[35]",id,reason)) return SendClientMessage(playerid,COLOR_GRAY,"SYNTAX: /report [id] [reason]");
if(id == INVALID_PLAYER_ID)) return SendClientMessage(playerid, COLOR_GRAY, "ERROR: Player is not connected!");
format(string,sizeof(string),"%s has reported %s: %s",GetName(playerid),GetName(id),reason);
SendToAdmins(COLOR_YELLOW,string);
return 1;
}

GAMER_PS2
26/10/2011, 01:36 PM
your Reason function code is not in string this is the reason why the <reason> part of the /report command are not working. here is the new one the reason is renew with string



CMD:report(playerid,params[])
{
new string[128],id,reason[128];
new reportername[MAX_PLAYER_NAME],hackername[MAX_PLAYER_NAME];
GetPlayerName(playerid,reportername,sizeof(string) );
GetPlayerName(id,hackername,sizeof(string));
if(sscanf(params,"us",id,reason)) return SendClientMessage(playerid,COLOR_RED,"ERROR: /report <Playername/id> <Reason>");
else if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected!");
format(string,sizeof(string),"REPORT: %s has reported %s <Reason: %s>",reportername,hackername,reason);
MessageToAdmins(COLOR_YELLOW,string);
return 1;
}


Have Fun! :D

i514x
26/10/2011, 01:42 PM
CMD:report(playerid,params[]){
new string[128],id;
if(sscanf(params,"us",id,string)) return SendClientMessage(playerid,COLOR_GRAY,"SYNTAX: /report [id] [reason]");
else if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_GRAY, "ERROR: Player is not connected!");
format(string,sizeof(string),"%s has reported %s: %s",GetName(playerid),GetName(id),string);
SendToAdmins(COLOR_YELLOW,string);
return 1;
}

best solution, no need to create a variable "reason"

SmiT
26/10/2011, 02:19 PM
@i514x_

if ( sscanf( params,"us", id, string ) ) return SendClientMessage(playerid,COLOR_GRAY,"SYNTAX: /report [id] [reason]");

Should be:

if ( sscanf( params,"us[128]", id, string ) ) return SendClientMessage(playerid,COLOR_GRAY,"SYNTAX: /report [id] [reason]");