Need help with closereport.
#1

Alright, so. I want to make it so when an admin types /cr [playerid] it will ony close the report.
But if he types /cr [playerid] [reason] it will close the report + it would send a message with the reason to the player.
Here is what I have.
Код:
CMD:cr(playerid, params[])
{
	if(pInfo[playerid][AdminLevel] > 0)
	{
		new otherid, aName[MAX_PLAYER_NAME], string[256], othername[MAX_PLAYER_NAME], string2[256], string3[256];
		GetPlayerName(playerid, aName, sizeof(aName));
		GetPlayerName(otherid, othername, sizeof(othername));
		if(sscanf(params, "r", otherid)) return SendClientMessage(playerid, COLOR_GREY, "Usage: {FFFFFF}/cr [playerid/name] + [reason]");
		{
			if(otherid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY, "That player is not connected."); 
			if(pInfo[otherid][HasReport] == 0) return SendClientMessage(playerid, COLOR_GREY, "That player does not have any reports available."); 
			format(string, sizeof(string), "* Admin %s has closed the report from %s [%d, level %d]: %s", aName, othername, otherid, pInfo[otherid][Level], pInfo[otherid][Report]);
			submitToHelpersAndAdmins(string, COLOR_HOTORANGE);
			format(string2, sizeof(string2), "> Admin %s: %s", aName, params);
			submitToHelpersAndAdmins(string, COLOR_YELLOW);
			SendClientMessage(playerid, -1, "Your report has been closed.");
			pInfo[otherid][HasReport] = 0;
			pInfo[otherid][ReportAccepted] = 0;
		}
		if(sscanf(params, "rs", otherid, params)) return SendClientMessage(playerid, COLOR_GREY, "Usage: {FFFFFF}/cr [playerid/name] + [reason]");
		{
			format(string2, sizeof(string2), "> Admin %s: %s", aName, params);
			submitToHelpersAndAdmins(string2, COLOR_YELLOW);
			format(string3, sizeof(string3), "Admin %s: %s", aName, params);
			SendClientMessage(otherid, -1, string3);
			SendClientMessage(playerid, -1, "Your report has been closed.");
			pInfo[otherid][HasReport] = 0;
			pInfo[otherid][ReportAccepted] = 0;
		}
	}
	else return SendClientMessage(playerid, -1, NotAdmin);
	return 1;
	
}
For some reason it doesn't work.
Reply
#2

Why are you using 'r' in sccanf to get player's id?
Try this:
PHP код:
CMD:cr(playeridparams[])
{
    if(
pInfo[playerid][AdminLevel] > 0)
    {
        new 
otheridaName[MAX_PLAYER_NAME], string[256], othername[MAX_PLAYER_NAME], string2[256], string3[256];
        
GetPlayerName(playeridaNamesizeof(aName));
        
GetPlayerName(otheridothernamesizeof(othername));
        if(
sscanf(params"u"otherid)) return SendClientMessage(playeridCOLOR_GREY"Usage: {FFFFFF}/cr [playerid/name] + [reason]");
        {
            if(
otherid == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_GREY"That player is not connected."); 
            if(
pInfo[otherid][HasReport] == 0) return SendClientMessage(playeridCOLOR_GREY"That player does not have any reports available."); 
            
format(stringsizeof(string), "* Admin %s has closed the report from %s [%d, level %d]: %s"aNameothernameotheridpInfo[otherid][Level], pInfo[otherid][Report]);
            
submitToHelpersAndAdmins(stringCOLOR_HOTORANGE);
            
format(string2sizeof(string2), "> Admin %s: %s"aNameparams);
            
submitToHelpersAndAdmins(stringCOLOR_YELLOW);
            
SendClientMessage(playerid, -1"Your report has been closed.");
            
pInfo[otherid][HasReport] = 0;
            
pInfo[otherid][ReportAccepted] = 0;
        }
        if(
sscanf(params"rs"otheridparams)) return SendClientMessage(playeridCOLOR_GREY"Usage: {FFFFFF}/cr [playerid/name] + [reason]");
        {
            
format(string2sizeof(string2), "> Admin %s: %s"aNameparams);
            
submitToHelpersAndAdmins(string2COLOR_YELLOW);
            
format(string3sizeof(string3), "Admin %s: %s"aNameparams);
            
SendClientMessage(otherid, -1string3);
            
SendClientMessage(playerid, -1"Your report has been closed.");
            
pInfo[otherid][HasReport] = 0;
            
pInfo[otherid][ReportAccepted] = 0;
        }
    }
    else return 
SendClientMessage(playerid, -1NotAdmin);
    return 
1;
    
}
If 
didn't work, explain me whats wrong with it. 
Reply
#3

Make a new string called "reason" for example, and use "rs" only, then check if reason string is empty, if it is, it means only player id/name was entered.
Reply
#4

Quote:
Originally Posted by ikey07
Посмотреть сообщение
Make a new string called "reason" for example, and use "rs" only, then check if reason string is empty, if it is, it means only player id/name was entered.
Could you give an example please?
Reply
#5

don't use more strings you can do it with 1 string try this

PHP код:
CMD:cr(playeridparams[])
{
    if(
pInfo[playerid][AdminLevel] > 0)
    {
        new 
otheridaName[MAX_PLAYER_NAME], string[256], othername[MAX_PLAYER_NAME], reason[256];
        
GetPlayerName(playeridaNamesizeof(aName));
        
GetPlayerName(otheridothernamesizeof(othername));
        if(
sscanf(params"u"otherid)) return SendClientMessage(playeridCOLOR_GREY"Usage: {FFFFFF}/cr [playerid/name] + [reason]");
        if(
otherid == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_GREY"That player is not connected.");
        if(
pInfo[otherid][HasReport] == 0) return SendClientMessage(playeridCOLOR_GREY"That player does not have any reports available.");
        if (
sscanf(params"us"otheridreason))
        {
            
            
format(stringsizeof(string), "* Admin %s has closed the report from %s [%d, level %d]: %s"aNameothernameotheridpInfo[otherid][Level], pInfo[otherid][Report]);
            
submitToHelpersAndAdmins(stringCOLOR_HOTORANGE);
            
format(stringsizeof(string), "> Admin %s: %s"aNameparams);
            
submitToHelpersAndAdmins(stringCOLOR_YELLOW);
            
SendClientMessage(playerid, -1"Your report has been closed.");
            
        }
        else
        {
            
format(stringsizeof(string), "> Admin %s: %s"aNameparams);
            
submitToHelpersAndAdmins(stringCOLOR_YELLOW);
            
format(stringsizeof(string), "Admin %s: %s"aNameparams);
            
SendClientMessage(otherid, -1string);
            
SendClientMessage(playerid, -1"Your report has been closed.");
        }
        
pInfo[otherid][HasReport] = 0;
        
pInfo[otherid][ReportAccepted] = 0;
    }
    else return 
SendClientMessage(playerid0xFF0000FF"Error: You are not authorized to use this command!");
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)