SA-MP Forums Archive
How to make cmd:makeadmin - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to make cmd:makeadmin (/showthread.php?tid=273364)



How to make cmd:makeadmin - kingchandio - 01.08.2011

how to make ranks and cmd:makeadmin for my gm that will set admin in pAdminLevel
pAdminLevel = "Basic Moderator";

pAdminLevel = "Moderator";

pAdminLevel = AdmRank = "Admin";

pAdminLevel = AdmRank = "Owner";


Re: How to make cmd:makeadmin - Jafet_Macario - 01.08.2011

Ok, not sure what you looking for but here is the /makeadmin command:
Код:
if(strcmp(cmd, "/makeadmin", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /makeadmin [playerid/PartOfName] [level(1-3)]");
				return 1;
			}
			new para1;
			new level;
			para1 = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			level = strval(tmp);
			if (PlayerInfo[playerid][pAdmin] >= 3)
			{
			    if(IsPlayerConnected(para1))
			    {
			        if(para1 != INVALID_PLAYER_ID)
			        {
						GetPlayerName(para1, giveplayer, sizeof(giveplayer));
						GetPlayerName(playerid, sendername, sizeof(sendername));
						PlayerInfo[para1][pAdmin] = level;
						printf("AdmCmd: %s has promoted %s to a level %d admin.", sendername, giveplayer, level);
						format(string, sizeof(string), "   You have been promoted to a level %d admin by %s", level, sendername);
						SendClientMessage(para1, COLOR_LIGHTBLUE, string);
						format(string, sizeof(string), "   You have promoted %s to a level %d admin.", giveplayer,level);
						SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
					}
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "   you are not authorized to use that command!");
			}
		}
		return 1;
	}
Make sure you put under enum pInfo this:
Код:
pAdmin,
, then under public OnPlayerConnect put this:
Код:
PlayerInfo[playerid][pAdmin] = 0;
Under public OnPlayerRegister put this code:
Код:
format(var, 32, "AdminLevel=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);
Under public OnPlayerUpdateEx put this code:
Код:
format(var, 32, "AdminLevel=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);
Under public OnPlayerConnect put this code:
Код:
if( strcmp( key , "AdminLevel" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pAdmin] = strval( val ); }
Now I think you got like a /admins command that show the admins online, you can add there like:
Код:
if(PlayerInfo[playerid][pAdmin] == 1)
{
        GetPlayerName(playerid, sendername,  sizeof(sendername));
	format(string, 256, "Moderator: %s", sendername);
        SendClientMessage(playerid, random(0xFFFFFFFF), string);
}
This will show in /admins list level 1 administrators like: Moderator, you can change it in whatever you want.
Hope I helped you.


Re: How to make cmd:makeadmin - Onyx - 01.08.2011

Which gamemode you use?


Re: How to make cmd:makeadmin - System64 - 01.08.2011

pawn Код:
YCMD:makeadmin(playerid, params[], help)
{
    #pragma unused help
    new id, lvl;
    if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] >= 3)
    {
        if(sscanf(params, "ui", id, lvl)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /makeadmin [ID] [Level]");
        else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_WHITE, "Invalid ID");
        else
        PlayerInfo[id][pAdminLevel] = lvl;
    }
    return 1;
}



Re: How to make cmd:makeadmin - Onyx - 01.08.2011

How do you all know or he have a save system, lol?


Re: How to make cmd:makeadmin - kingchandio - 02.08.2011

I have saving system,,, i want cmd system Like
CMD:makeadmin
{
}
and that saves level in my pAdminLevel enum