Help with report cmd...
#1

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..
pawn Код:
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?
Reply
#2

Quote:
Originally Posted by Azzeto
Посмотреть сообщение
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..
pawn Код:
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)?

PHP код:
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(playeridCOLOR_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;

Reply
#3

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;
Reply
#4

pawn Код:
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 :@
Reply
#5

Quote:
Originally Posted by TheMaddox
Посмотреть сообщение
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?
Reply
#6

Posted to early.. Still same error x.x using sscanf 1
Reply
#7

pawn Код:
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;
}
Reply
#8

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

pawn Код:
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!
Reply
#9

pawn Код:
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"
Reply
#10

@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]");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)