CMD:setlevel(playerid, params[]) { if(!IsPlayerAdmin(playerid)) return true; new mysql_query[128]; if(sscanf(params,"dd", params[0], params[1])) return SendClientMessage(playerid, COLOR_YELLOW, "use: /setlevel [account id] [level]"); if(IsPlayerConnected(GetPlayerID(params[0]))) { PlayerInfo[params[0]][pAdminLevel] = params[1]; } else if(!IsPlayerConnected(GetPlayerID(params[0]))) { format(mysql_query, sizeof(mysql_query), "UPDATE `accounts` SET `pAdmin` = '%d' WHERE `id` = '%d'",params[1], params[0]); mysql_function_query(connects, mysql_query, false, "", ""); } SendClientMessage(playerid, COLOR_YELLOW, "bla-bla-bla"); return true; }
stock GetPlayerID(string[]) { foreach(Player,i) { if(IsPlayerConnected(i) == 1) { if(strcmp(PlayerInfo[i][pNickName], string, true, strlen(string)) == 0) { return i; } } } return INVALID_PLAYER_ID; }
any errors?
and I'm not sure this kind of using "params" will work, try using sscanf |
CMD:setlevel(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return true;
new mysql_query[128], lookupid, level;
if(sscanf(params,"ui",lookupid ,level)) return SendClientMessage(playerid, COLOR_YELLOW, "use: /setlevel [PlayerName/ID] [level]");
if(!IsPlayerConnected(GetPlayerID(lookupid))) return SendClientMessage(playerid, -1, "that player is not connected");
PlayerInfo[lookupid][pAdminLevel] = level;
format(mysql_query, sizeof(mysql_query), "UPDATE `accounts` SET `pAdmin` = '%d' WHERE `id` = '%d'",level, GetPlayerID(lookupid));
mysql_function_query(connects, mysql_query, false, "", "");
return true;
}