26.12.2018, 00:29
So I have this command, which is ment to set someone's admin level. ( offline or online ) However, it doesn't work. It keeps telling me "That account does not exist." when I try to give someone an admin level in game.. I think it has something to do with the fact that everything is targetid. But if I change it to target, it will tell me "error 035: argument type mismatch (argument 1)" Anyone can help me with the solution?
Код:
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], targetid = GetPlayerID(target), value, str[128], query[128];
if(sscanf(params, "s[24]i", target, value))
return SCM(playerid, COLOR_INFO, "INFO: /admin [full name(case sensitive)] [0-4]");
if(value < 0 || value > MAX_ADMIN_LEVEL)
return SCM(playerid, COLOR_ERROR, "ERROR: You can only use a value between 0 and 4.");
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'",ReturnName(targetid));
mysql_tquery(ourConnection, query);
cache_get_data(rows, fields, ourConnection);
if(!rows)
return SendClientMessage(playerid, COLOR_ERROR, "ERROR: That account does not exist.");
PlayerInfo[targetid][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[targetid][pAdmin], ReturnName(targetid));
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;
}


