Admin script problems
#1

I have this admin script below, and the problem is, my login script works fine, it saves everything, but when I try to use my commands it says unknown command, which I told it to do if I'm not an admin, but I made sure I had it set up that I was an admin,I just cant get it to work, namely the setrank command, but the others don't work either, essentially all moaning that I aren't an admin, I log onto RCON, and it's fine, which is one of the things that I put on there, so that works, but the admin bit doesn't.


Код:
//ZCMD Commands
CMD:setrank(playerid, params[])
{
	if(!IsPlayerAdmin(playerid) || pInfo[playerid][Adminlevel] < 1336) return 0;
	new alevel;
	new name[MAX_PLAYER_NAME];
	new pname[MAX_PLAYER_NAME];
	new str[128];
	new ID;
	if(sscanf(params,"ui",ID,alevel)) return SendClientMessage(playerid, RED, "USAGE: /setrank [playerid / partofname] [Level 1 - 5]");
	if(ID == INVALID_PLAYER_ID) return SendClientMessage(playerid, RED, "Player is not connected!");
	if(alevel > 5) return SendClientMessage(playerid, RED, "Available Admin Levels: 1 - 5!");
	if(alevel == 0)
	{
	    if(pInfo[ID][Adminlevel] == 0) return SendClientMessage(playerid, RED, "ERROR: That person is already a normal player!");
	    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
	    GetPlayerName(ID,pname,MAX_PLAYER_NAME);
	    format(str, sizeof(str),"%s(%s) has demoted you to a regular player!",name,playerid);
	    SendClientMessage(ID, WHITE, str);
	    format(str, sizeof(str),"You have demoted %s(%s) to a regular player!",pname,ID);
	    SendClientMessage(playerid, WHITE, str);
		pInfo[ID][Adminlevel] = 0;
	}
	if(alevel == 1)
	{
	    if(pInfo[ID][Adminlevel] == 1) return SendClientMessage(playerid, RED, "ERROR: That person is already a Junior Moderator!");
	    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
	    GetPlayerName(ID,pname,MAX_PLAYER_NAME);
	    format(str, sizeof(str),"%s(%s) has premoted you to a Junior Moderator!",name,playerid);
	    SendClientMessage(ID, WHITE, str);
	    format(str, sizeof(str),"You have promoted %s(%s) to a Junior Moderator!",pname,ID);
	    SendClientMessage(playerid, WHITE, str);
		pInfo[ID][Adminlevel] = 1;
	}
	if(alevel == 2)
	{
	    if(pInfo[ID][Adminlevel] == 2) return SendClientMessage(playerid, RED, "ERROR: That person is already a Moderator!");
	    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
	    GetPlayerName(ID,pname,MAX_PLAYER_NAME);
	    format(str, sizeof(str),"%s(%s) has premoted you to a Moderator!",name,playerid);
	    SendClientMessage(ID, WHITE, str);
	    format(str, sizeof(str),"You have promoted %s(%s) to a Moderator!",pname,ID);
	    SendClientMessage(playerid, WHITE, str);
		pInfo[ID][Adminlevel] = 2;
	}
	if(alevel == 3)
	{
	    if(pInfo[ID][Adminlevel] == 3) return SendClientMessage(playerid, RED, "ERROR: That person is already a Super Moderator!");
	    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
	    GetPlayerName(ID,pname,MAX_PLAYER_NAME);
	    format(str, sizeof(str),"%s(%s) has premoted you to a Super Moderator!",name,playerid);
	    SendClientMessage(ID, WHITE, str);
	    format(str, sizeof(str),"You have promoted %s(%s) to a Super Moderator!",pname,ID);
	    SendClientMessage(playerid, WHITE, str);
		pInfo[ID][Adminlevel] = 3;
	}
	if(alevel == 4)
	{
	    if(pInfo[ID][Adminlevel] == 2) return SendClientMessage(playerid, RED, "ERROR: That person is already an Admin!");
	    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
	    GetPlayerName(ID,pname,MAX_PLAYER_NAME);
	    format(str, sizeof(str),"%s(%s) has premoted you to an Admin!",name,playerid);
	    SendClientMessage(ID, WHITE, str);
	    format(str, sizeof(str),"You have promoted %s(%s) to an Admin!",pname,ID);
	    SendClientMessage(playerid, WHITE, str);
		pInfo[ID][Adminlevel] = 4;
	}
	if(alevel == 5)
	{
	    if(pInfo[ID][Adminlevel] == 2) return SendClientMessage(playerid, RED, "ERROR: That person is already Head Admin!");
	    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
	    GetPlayerName(ID,pname,MAX_PLAYER_NAME);
	    format(str, sizeof(str),"%s(%s) has premoted you to Head Admin!",name, playerid);
	    SendClientMessage(ID, WHITE, str);
	    format(str, sizeof(str),"You have promoted %s(%s) to Head Admin!",pname, ID);
	    SendClientMessage(playerid, WHITE, str);
		pInfo[ID][Adminlevel] = 5;
	}
	return 1;
}

CMD:healall(playerid, params[])
{
	if(!IsPlayerAdmin(playerid) || pInfo[playerid][Adminlevel] < 1) return 0;
	for(new i=0; i<MAX_PLAYERS; i++)
	{
	    if(IsPlayerConnected(i))
		{
		    new str[51], name[MAX_PLAYER_NAME];
		    GetPlayerName(playerid,name,sizeof(name));
		    format(str,sizeof(str),"Admin %s(%s) has healed everyone!",name,playerid);
		    SendClientMessageToAll(WHITE, str);
		    SetPlayerHealth(i, 100);
		}
	}
	return 1;
}

CMD:kick(playerid, params[])
{
	new id, reason[128];
	if(!IsPlayerAdmin(playerid) || pInfo[playerid][Adminlevel] < 1) return 0;
	else if(sscanf(params, "us(No Reason)[128]", id, reason))SendClientMessage(playerid, RED, "Usage: /kick [id/name][reason]");
	else if (id==INVALID_PLAYER_ID)SendClientMessage(playerid,RED,"Player is not connected!");
	else
	{
	    new Name[MAX_PLAYER_NAME], KickMessage[128];
	    new Name2[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, Name, sizeof(Name));
	    GetPlayerName(id, Name2, sizeof(Name2));
		format(KickMessage, sizeof(KickMessage), "%s(%d) has kicked player %s(%d). Reason: %s", Name, playerid, Name2, id, reason);
	    SendClientMessageToAll(WHITE, KickMessage);
	    Kick(id);
	}
	return 1;
}

CMD:ban(playerid, params[])
{
	new id, reason[128];
	if(!IsPlayerAdmin(playerid) || pInfo[playerid][Adminlevel] < 1) return 0;
	else if(sscanf(params, "us(No Reason)[128]", id, reason))SendClientMessage(playerid, RED, "Usage: /ban [id/name][reason]");
	else if (id==INVALID_PLAYER_ID)SendClientMessage(playerid,RED,"Player is not connected!");
	else
	{
	    new Name[MAX_PLAYER_NAME], BanMessage[128];
	    new Name2[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, Name, sizeof(Name));
	    GetPlayerName(id, Name2, sizeof(Name2));
		format(BanMessage, sizeof(BanMessage), "%s(%d) has banned player %s(%d). Reason: %s", Name, playerid, Name2, id, reason);
	    SendClientMessageToAll(WHITE, BanMessage);
	    BanEx(id, reason);
	}
	return 1;
}

CMD:announce(playerid, params[])
{
	new text[128];
	if(!IsPlayerAdmin(playerid) || pInfo[playerid][Adminlevel] < 1) return 0;
	else if(sscanf(params, "s[128]", text)) SendClientMessage(playerid, RED, "Usage: /announce [text]");
	else
	{
	    new str[128];
	    format(str, sizeof(str), "%s", text);
	    GameTextForAll(str, 10000, 4);
	}
	return 1;
}
Any help really would but appreciated, I've been fine till now (my scripting abilities have enhanced a bit, I just can't figure this out)
Reply


Messages In This Thread
Admin script problems - by Zonoya - 09.06.2013, 14:42
Re: Admin script problems - by SuperViper - 09.06.2013, 15:13
Re: Admin script problems - by Zonoya - 09.06.2013, 15:18
Re : Admin script problems - by NvidiaForTheWin - 09.06.2013, 15:27
Re: Admin script problems - by Zonoya - 09.06.2013, 15:33
Re : Admin script problems - by NvidiaForTheWin - 09.06.2013, 15:42
Re: Admin script problems - by Zonoya - 09.06.2013, 15:45
Re : Admin script problems - by NvidiaForTheWin - 09.06.2013, 15:57
Re: Admin script problems - by Zonoya - 09.06.2013, 15:59
Re : Admin script problems - by NvidiaForTheWin - 09.06.2013, 16:03

Forum Jump:


Users browsing this thread: 1 Guest(s)