MYSQL Admin system - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MYSQL Admin system (
/showthread.php?tid=357240)
MYSQL Admin system -
vassilis - 06.07.2012
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?
Re: MYSQL Admin system -
DBan - 06.07.2012
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;
}