MySQL issues with /makeadmin command
#3

Quote:
Originally Posted by Threshold
Посмотреть сообщение
PHP код:
new target[24], targetid GetPlayerID(target
'target' does not yet have a value, so you're basically saying:
targetid = GetPlayerID("");

Also, using a player ID when the player is offline is useless.. what do you think targetid would be if the player was offline?
if I don't use targetid, and instead target, I get these errors when compiling.

Код:
./inc/admin.inc(68) : error 033: array must be indexed (variable "target")
./inc/admin.inc(75) : error 033: array must be indexed (variable "target")
./inc/admin.inc(78) : error 033: array must be indexed (variable "target")
Here's the current code: ( I have marked the lines that report errors )

Код:
CMD:makeadmin(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] < 4)
	{
		SCM(playerid,COLOR_ERROR,"ERROR: You do not have the required access to execute this command.");
		SCM(playerid,COLOR_INFO,"INFO: You need admin level 4 or above to use this command.");
	}
	else
	{
		new target[24], value, str[128], query[128];
        if(sscanf(params, "s[24]i", target, value))
        {
    		format(str, sizeof(str), "INFO: /admin [full name(case sensitive)] [0-%i]",MAX_ADMIN_LEVEL);
        	SCM(playerid, COLOR_INFO, str);
        }
		if(value < 0 || value > MAX_ADMIN_LEVEL)
		{
			format(str, sizeof(str), "ERROR: You can only use a value between 0 and %i.",MAX_ADMIN_LEVEL);	
			SCM(playerid, COLOR_ERROR, str);
    	}
    	
		new targetid = GetPlayerID(target);

        if( targetid == playerid )
		    return SCM(playerid, COLOR_ERROR, "ERROR: You can not use this command on yourself.");

        if(IsPlayerConnected(targetid))
        {
            PlayerInfo[targetid][pAdmin] = value;

            mysql_format(ourConnection, query, sizeof(query),"UPDATE `accounts` SET `admin` = %i WHERE `acc_name` = %e",PlayerInfo[targetid][pAdmin], PlayerInfo[targetid][pAccName]);
    		mysql_tquery(ourConnection, query);

            format(str,sizeof(str),"SERVER: You have set {FFFFFF}%s(%i){ADD8E6} their admin level to {FFFFFF}%i{ADD8E6}.",ReturnName(targetid), targetid, value);
            SCM(playerid, COLOR_LIGHTBLUE, str);

            format(str,sizeof(str),"SERVER: Your admin level was set to {FFFFFF}%i{ADD8E6} by {FFFFFF}%s(%i){ADD8E6}.",value, ReturnName(playerid), playerid);
            SCM(targetid, COLOR_LIGHTBLUE,str);
        }
        else
        {
        	new rows, fields;
        	mysql_format(ourConnection, query, sizeof(query), "SELECT * FROM accounts WHERE acc_name = '%e'",PlayerInfo[target][pAccName]);
			mysql_tquery(ourConnection, query);
			cache_get_data(rows, fields, ourConnection);

    		if(!rows)
    			return SendClientMessage(playerid, COLOR_ERROR, "ERROR: That account does not exist.");

    		PlayerInfo[target][pAdmin] = value;
            PlayerInfo[playerid][pAdminRankMsg] = true; // sends the player a message when they login informing them that their admin rank was adjusted.

           	mysql_format(ourConnection, query, sizeof(query),"UPDATE `accounts` SET `admin` = %i WHERE `acc_name` = %e",PlayerInfo[target][pAdmin], PlayerInfo[target][pAccName]);
    		mysql_tquery(ourConnection, query);

    		format(str, sizeof(str), "SERVER: You have set {FFFFFF}%s{ADD8E6} their admin level to {FFFFFF}%i{A7A7A7}.",target, value);
            SCM(playerid, COLOR_LIGHTBLUE, str);
        }
    }
    return 1;
}
Anyone, please help.
Reply


Messages In This Thread
MySQL issues with /makeadmin command - by Stefhan - 26.12.2018, 00:29
Re: MySQL issues with /makeadmin command - by Threshold - 26.12.2018, 01:16
Re: MySQL issues with /makeadmin command - by Stefhan - 26.12.2018, 20:10

Forum Jump:


Users browsing this thread: 2 Guest(s)