SA-MP Forums Archive
[HELP] Everyone can use Admin cmds... - 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: [HELP] Everyone can use Admin cmds... (/showthread.php?tid=87985)



[HELP] Everyone can use Admin cmds... - FreddeN - 23.07.2009

The title says it all...

Here is one of my admin commands that normal players can use:

Код:
if(strcmp(cmd, "/kick", true) == 0)
	{
    if(PlayerInfo[playerid][pAdmin] < 1337)
  	tmp = strtok(cmdtext, idx);
		if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /kick [playerid/PartOfName] [reason]");
		giveplayerid = ReturnUser(tmp);
		if(giveplayerid == playerid) return SendClientMessage(playerid, COLOR_RED, "You can't kick yourself!");
	  if(PlayerInfo[playerid][pAdmin] < PlayerInfo[giveplayerid][pAdmin]) return SendClientMessage(playerid, COLOR_RED, "You can't Kick a higher level Admin!");
	  if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "Invalid Player ID.");
	  GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
		GetPlayerName(playerid, sendername, sizeof(sendername));
		new length = strlen(cmdtext);
		while ((idx < length) && (cmdtext[idx] <= ' '))
		{
			idx++;
		}
		new offset = idx;
		new result[64];
		while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
		{
			result[idx - offset] = cmdtext[idx];
			idx++;
		}
		result[idx - offset] = EOS;
		if(!strlen(result)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /kick [playerid/PartOfName] [reason]");
		new year, month,day;
		getdate(year, month, day);
		format(string, sizeof(string), "\"%s\" was kicked by Admin \"%s\". Reason: (%s)", giveplayer, sendername, (result));
		SendClientMessageToAll(COLOR_RED, string);
		Kick(giveplayerid);
		return 1;
	}
Thanks


Re: [HELP] Everyone can use Admin cmds... - Weirdosport - 23.07.2009

PlayerInfo[playerid][pAdmin] < 1337

Surely if the player has a level lower than that they're not an admin?