Help With Set admin level
#1

Код:
CMD:setlevel(playerid,params[]) {
		if(PlayerInfo[playerid][Level] >= 5 || IsPlayerAdmin(playerid)) {
		    new tmp[256], tmp2[256], Index;		tmp = strtok(params,Index), tmp2 = strtok(params,Index);
		    if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /setlevel [playerid] [level]");
	    	new player1, level, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
			player1 = strval(tmp);
			if(isnull(tmp2)) return SendClientMessage(playerid, red, "USAGE: /setlevel [playerid] [level]");
			level = strval(tmp2);

			if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
				if(PlayerInfo[player1][LoggedIn] == 1) {
					if(level > ServerInfo[MaxAdminLevel] ) return SendClientMessage(playerid,red,"ERROR: Incorrect Level");
					if(level == PlayerInfo[player1][Level]) return SendClientMessage(playerid,red,"ERROR: Player is already this level");
	       			CMDMessageToAdmins(playerid,"SETLEVEL");
					GetPlayerName(player1, playername, sizeof(playername));	GetPlayerName(playerid, adminname, sizeof(adminname));
			       	new year,month,day;   getdate(year, month, day); new hour,minute,second; gettime(hour,minute,second);

					if(level > 0) format(string,sizeof(string),"Administrator %s has set you to Administrator Status [level %d]",adminname, level);
					else format(string,sizeof(string),"Administrator %s has set you to Player Status [level %d]",adminname, level);
					SendClientMessage(player1,blue,string);

					if(level > PlayerInfo[player1][Level]) GameTextForPlayer(player1,"~g~Promoted", 2000, 3);
					else GameTextForPlayer(player1,"~r~Demoted", 2000, 3);

					format(string,sizeof(string),"You have made %s Level %d on %d/%d/%d at %d:%d:%d", playername, level, day, month, year, hour, minute, second); SendClientMessage(playerid,blue,string);
					format(string,sizeof(string),"Administrator %s has made %s Level %d on %d/%d/%d at %d:%d:%d",adminname, playername, level, day, month, year, hour, minute, second);
					SaveToFile("AdminLog",string);
					dUserSetINT(PlayerName2(player1)).("level",(level));
					PlayerInfo[player1][Level] = level;
					return PlayerPlaySound(player1,1057,0.0,0.0,0.0);
				} else return SendClientMessage(playerid,red,"ERROR: Player must be registered and logged in to be admin");
			} else return SendClientMessage(playerid, red, "Player is not connected");
		} else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
I Am Having A Problem What When I Type
Код:
/setlevel 0 6
It Says Incorrect Level Please Help Me
Reply
#2

PHP код:
if(level ServerInfo[MaxAdminLevel] ) return SendClientMessage(playerid,red,"ERROR: Incorrect Level"); 
Find MaxAdminLevel in your script and change the value of it to your max admin level.
or just change it to:

PHP код:
if(level /*Max admin level in your server*/) return SendClientMessage(playerid,red,"ERROR: Incorrect Level"); 
Reply
#3

you could use it as well
Quote:

if(level > ServerInfo[MaxAdminLevel] ) return SendClientMessage(playerid,red,"ERROR: Incorrect Level");
#define MaxAdminLevel 5

Reply
#4

Quote:
Originally Posted by Speedpro
Посмотреть сообщение
you could use it as well
Код:
#define MaxAdminLevel 5
No, that wouldn't work.
He could do that, but this way:

Код:
#define MaxAdminLevel 5
if (level > MaxAdminLevel)
But the reason yours doesn't work, is because ServerInfo is an enum, and MaxAdminLevel is a part of it (an index)
Reply
#5

OMa37 Like This i Can Do
Quote:

MaxAdminLevel[6],

Reply
#6

Why do you want to create the variable so much!?Just do what Oma37 said!
Reply
#7

Quote:
Originally Posted by Stinged
Посмотреть сообщение
No, that wouldn't work.
He could do that, but this way:

Код:
#define MaxAdminLevel 5
if (level > MaxAdminLevel)
But the reason yours doesn't work, is because ServerInfo is an enum, and MaxAdminLevel is a part of it (an index)
I put it adapts well to the, I will not
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)