MySQL Admin level
#1

So.. I've been trying some things to retreive an Adminlevel from my MySQL Database
I got an Enum for Admin (playerdata):
Код:
enum PlayerData
{
	ID,
	Name[MAX_PLAYER_NAME],
	Password[129],
	IP[16],
	Admin,
	VIP,
	Money,
	Float:posX,
	Float:posY,
	Float:posZ,
	Float:posA
};
But how do I make a command to set someone's adminlevel (including to update it into MySQL) AND:
How do I make admincommands to see if their level is (for example) higher than 5

Thanks in Advance:
-Deroxi
Reply
#2

MySQL >= R33
Код:
CMD:setadm(playerid, params[])
{
	new TargetID, Level, MySQL_Format[300], Name[24];
	
	if(Variable[playerid][Admin] < 5) return SendClientMessage(playerid, -1, "You are not authorized to use this command!");
	
	if(sscanf(params, "ui", TargetID, Level)) return SendClientMessage(playerid, -1, "/setadm [name/id] [level]");
	
	GetPlayerName(TargetID, Name, 24);
	
	mysql_format(ConnectionDB, MySQL_Format, sizeof MySQL_Format, "UPDATE `table_name` SET `admin_column` = '%i' WHERE `player_name` = '%s'", Level, Name);
	mysql_query(ConnectionDB, MySQL_Format);
	
	return 1;
}
Reply
#3

Код:
	new TargetID, Level, MySQL_Format[300], Name[24];
	
	
	if(sscanf(params, "ui", TargetID, Level)) return SendClientMessage(playerid, -1, "/setadm [name/id] [level]");
	
	GetPlayerName(TargetID, Name, 24);
Could you maybe explain those 3 lines of code, I dont get what it is doing
Reply
#4

Quote:
Originally Posted by Deroxi
Посмотреть сообщение
Код:
	new TargetID, Level, MySQL_Format[300], Name[24];
	
	
	if(sscanf(params, "ui", TargetID, Level)) return SendClientMessage(playerid, -1, "/setadm [name/id] [level]");
	
	GetPlayerName(TargetID, Name, 24);
Could you maybe explain those 3 lines of code, I dont get what it is doing
If you don't type /setadm [player_name/ID] [level], it will show you how to use this command, otherwise - function will work further.
Reply
#5

Command is not working, I made myself admin level 6 through phpmyadmin. Executing command still gives me the SendClientMessage(playerid, -1, "/setadm [name/id] [level]");
Reply
#6

1- Set your level 6;
2- Type it (example):
/setadm 0 5
or
/setadm Username 5
Reply
#7

WHAHA, im so stupid. I forgot to add the ID. Thanks for the reminder!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)