[Tutorial] Admin Script (y_ini,sscanf,zcmd)
#17

I hate it when someone does a tutorial and doesn't fully test it. First of all, your admin command /promote does not save.

Code:
CMD:promote(playerid,params[])
{
        new id,level;
	if(IsPlayerAdmin(playerid)) //this will check if the player is logged into RCON
	{
	    if(sscanf(params,"ud",id,level) return //add the sendclientmessage usage: /promote name/id level or something "u" checks the if the player wrote a id or name "d" checks what level you wrote
		else
		{
	        if(level > 5) return //if the player writes a level thats over 5 he will get a error, write the error here
			else
			{
	        	new INI:File = INI_Open(UserPath(id));//this is the example used in Kush's tut link above, make it fit in your system, note that i've changed the UserPath(playerid) to UserPath(id) to promote the chosen player not yourself
	        	INI_WriteInt(File,"Admin",level); // writes the admin level in the ini file and makes the player admin.
	        	INI_Close(File); //closes the ini file
			}
		}
	}
	else
	{
	    //send a message that the player is not logged in as RCON
	}
}
needs to be changed to


Code:
CMD:promote(playerid,params[])
{
        new id,level;
	if(IsPlayerAdmin(playerid)) //this will check if the player is logged into RCON
	{
	    if(sscanf(params,"ud",id,level) return //add the sendclientmessage usage: /promote name/id level or something "u" checks the if the player wrote a id or name "d" checks what level you wrote
		else
		{
	        if(level > 5) return //if the player writes a level thats over 5 he will get a error, write the error here
			else
			{
	        	    PlayerInfo[id][pAdmin] = level;
			}
		}
	}
	else
	{
	    //send a message that the player is not logged in as RCON
	}
}
otherwise it doesn't save. Kush's system already has a save thing for when you disconnect, so there's no need to open or close the file, you just change the variable and it saves when the player disconnects.

In the kick/ban command, there are no timers, so the player getting kicked/banned won't receive the text on his screen. He will only get: Server closed the connection, so add timers. Also for the ban command, you need to redefine the parameters when the player registers/logins because the pBanned won't save.


Sorry for bumping a really old thread, but yeah It's in the useful tutorials sections and the tutorials need to be maintained regularly
Reply


Messages In This Thread
Admin Script (y_ini,sscanf,zcmd) - by HDFord - 04.06.2012, 13:45
Re: Admin Script (y_ini,sscanf,zcmd) - by Spookie98 - 04.06.2012, 14:47
Re: Admin Script (y_ini,sscanf,zcmd) - by mickos - 04.06.2012, 14:53
Re: Admin Script (y_ini,sscanf,zcmd) - by Firo - 04.06.2012, 15:13
Re: Admin Script (y_ini,sscanf,zcmd) - by InfinityCOD - 04.06.2012, 15:17
Re: Admin Script (y_ini,sscanf,zcmd) - by HDFord - 04.06.2012, 16:15
Re: Admin Script (y_ini,sscanf,zcmd) - by [DX]Aru12345 - 17.03.2013, 06:15
Re: Admin Script (y_ini,sscanf,zcmd) - by Ryan_Bowe - 17.03.2013, 14:58
Re: Admin Script (y_ini,sscanf,zcmd) - by lean1337 - 18.03.2013, 15:52
Re: Admin Script (y_ini,sscanf,zcmd) - by Scrillex - 18.03.2013, 16:16
Re: Admin Script (y_ini,sscanf,zcmd) - by Strummer - 16.07.2014, 22:47
Re: Admin Script (y_ini,sscanf,zcmd) - by Jack_Leslie - 16.07.2014, 23:58
Re: Admin Script (y_ini,sscanf,zcmd) - by Strummer - 17.07.2014, 00:01
Re: Admin Script (y_ini,sscanf,zcmd) - by Jack_Leslie - 17.07.2014, 00:11
Re: Admin Script (y_ini,sscanf,zcmd) - by Strummer - 17.07.2014, 00:15
Re: Admin Script (y_ini,sscanf,zcmd) - by canadianclass - 23.09.2014, 16:29
Re: Admin Script (y_ini,sscanf,zcmd) - by Sibuscus - 13.03.2017, 20:50

Forum Jump:


Users browsing this thread: 1 Guest(s)