MYSQL Admin system
#1

Hey guys so i have successfully made a mysql database with [HIC]TheKiller's tutorial
The database contains:
Username,password-hashed-,money,score,ip
I want to make a small admin system with some commands
So should i use enum like
pawn Код:
enum PlayerInfo
{  
      Username,
      password,
      score,
      money,
      IP,
      AdminLevel
 }
If yes could someone give me an example of /setlevel cmd using mysql ?
Is there other way i could make it?
Reply
#2

Yes, that is the correct way to use it.
Also, make sure you create a variable:
pawn Код:
// Under enum
new PlayerData[MAX_PLAYERS][PlayerInfo];
Here is an example of a setlevel command.

pawn Код:
CMD:setlevel(playerid, params[])
{
    if(PlayerData[playerid][AdminLevel] == 3)
    {
        new id, level, idname[MAX_PLAYER_NAME], query[200];
        if(sscanf(params, "ui", id, level)) return SendClientMessage(playerid, CWHITE, "Invalid syntax. Valid: /setlevel [name/id] [level]");
        else if(!IsPlayerConnected(id) || id == playerid) return SendClientMessage(playerid, CRED, "Invalid ID/Name");
        GetPlayerName(id, idname, sizeof(idname));
        format(query, sizeof(query), "UPDATE playerdata SET `adminlevel` = '%d' WHERE `user` = '%s'", level, idname);
        mysql_query(query);
        SendClientMessage(playerid, CGREEN, "Successfull account level edit");
        PlayerData[playerid][AdminLevel] = level;
    }
    else return SendClientMessage(playerid, CRED, "You're not allowed to use that command");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)