SA-MP Forums Archive
MySQL Admin level - 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 level (/showthread.php?tid=608234)



MySQL Admin level - Deroxi - 29.05.2016

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


Re: MySQL Admin level - F1N4L - 29.05.2016

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;
}



Re: MySQL Admin level - Deroxi - 29.05.2016

Код:
	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


Re: MySQL Admin level - luke49 - 29.05.2016

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.


Re: MySQL Admin level - Deroxi - 30.05.2016

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]");


Re: MySQL Admin level - F1N4L - 30.05.2016

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


Re: MySQL Admin level - Deroxi - 30.05.2016

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