/makeadmin Command
#1

So i've been trying all day to make a /makeadmin command and i've resulted in nothing new,
So here's my command

Код:
CMD:makeadmin(playerid, params[])
{
 	new PID, str[128], param;
	new PName[MAX_PLAYER_NAME], AName[MAX_PLAYER_NAME];
	GetPlayerName(playerid, AName, sizeof(AName));
	GetPlayerName(PID, PName, sizeof(PName));
	if(PlayerInfo[playerid][pAdminLevel] >=5) {
 	if(sscanf(params, "us[64]", PID, pAdminLevel)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /makeadmin [playerid] [Admin Level]");
 	
	if(!IsPlayerConnected(playerid))
	return SendClientMessage(playerid, COLOR_RED, "Player is not connected!");
	
	format(str, sizeof(str), "%s Has set %s 's Administrator level to %d", AName, PName, param);
	new INI:File = INI_Open(UserPath(PID));
	INI_SetTag(File,"data");
	INI_WriteInt(File,"AdminLevel", param);
	INI_Close(File);
	foreach(Player, i) {
	if(PlayerInfo[i][pAdminLevel] > 0){
	SendClientMessage(i,COLOR_YELLOW,str);}}
	}
	else
	{
	    SendClientMessage(playerid, COLOR_GREY, "You're not authorized to use that command");
	}
	return 1;
}
Now i've tried changing the %d to %s to display what level they were set too, also it doesn't set the admin level in their user file, don't know why.

If anyone can help, that would be great.
Reply
#2

pawn Код:
if(sscanf(params, "ui", PID, pAdminLevel)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /makeadmin [playerid] [Admin Level]");
Reply
#3

Quote:
Originally Posted by biker122
Посмотреть сообщение
pawn Код:
if(sscanf(params, "ui", PID, pAdminLevel)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /makeadmin [playerid] [Admin Level]");
What should that do?
Reply
#4

Okay, Cleared it today.

"u" - Either the ID or name of the player.
"i" - Just some kind of numeric(integer) value.
If you use "s" - It's meant for writing a name or a combination of letter (if i'm not wrong)
Reply
#5

pAdminLevel is an int number. Isn't "s", is "i" or "d" because it isn't a string.
Reply
#6

So ui should display the number correctly? What about updating the user file for the admin level? Cause it aint updating that either.
Reply
#7

Oh right.. Do this, before the line:
pawn Код:
new INI:File = INI_Open(UserPath(PID));
Add
pawn Код:
PlayerInfo[PID][pAdminLevel] = param;
Reply
#8

Assuming you have a registration system, do you not save the enum variables? Because you should be able to just update the variables, not actually open the file and write the value since that would prevent you from using the values you set in the same session.
Reply
#9

Quote:
Originally Posted by Mionee
Посмотреть сообщение
Assuming you have a registration system, do you not save the enum variables? Because you should be able to just update the variables, not actually open the file and write the value since that would prevent you from using the values you set in the same session.
Yes, i should just use my savechar(playerid) stock? That saves all the data.
Reply
#10

Quote:
Originally Posted by biker122
Посмотреть сообщение
Oh right.. Do this, before the line:
pawn Код:
new INI:File = INI_Open(UserPath(PID));
Add
pawn Код:
PlayerInfo[PID][pAdminLevel] = param;
Quote:
Originally Posted by biker122
Посмотреть сообщение
Okay, Cleared it today.

"u" - Either the ID or name of the player.
"i" - Just some kind of numeric(integer) value.
If you use "s" - It's meant for writing a name or a combination of letter (if i'm not wrong)
Quote:
Originally Posted by biker122
Посмотреть сообщение
pawn Код:
if(sscanf(params, "ui", PID, pAdminLevel)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /makeadmin [playerid] [Admin Level]");
Thanks, this all worked!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)