SA-MP Forums Archive
/makeadmin Command - 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: /makeadmin Command (/showthread.php?tid=526457)



/makeadmin Command - Cole_William - 17.07.2014

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.


Re: /makeadmin Command - biker122 - 17.07.2014

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



Re: /makeadmin Command - Cole_William - 17.07.2014

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?


Re: /makeadmin Command - biker122 - 17.07.2014

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)


Respuesta: /makeadmin Command - Kemula - 17.07.2014

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


Re: /makeadmin Command - Cole_William - 17.07.2014

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


Re: /makeadmin Command - biker122 - 17.07.2014

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



Re: /makeadmin Command - Dignity - 17.07.2014

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.


Re: /makeadmin Command - Cole_William - 17.07.2014

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.


Re: /makeadmin Command - Cole_William - 17.07.2014

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!!