SA-MP Forums Archive
Admin script problems - 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: Admin script problems (/showthread.php?tid=442925)



Admin script problems - Zonoya - 09.06.2013

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)


Re: Admin script problems - SuperViper - 09.06.2013

Don't quote me on this but I'm almost certain that you must have ZCMD included in your gamemode to use it in a filterscript.


Re: Admin script problems - Zonoya - 09.06.2013

it aint part of a FS, it's part of my GM, which does have ZCMD included


Re : Admin script problems - NvidiaForTheWin - 09.06.2013

i would suggest first to send a message if not admin in place of returning 0 just to be sure the command itself work.

also i didnt worked with admin thingy yet on my GM im creating , but i thought IsPlayerAdmin was for RCON , which i think doesnt have level. am i wrong ?

just trying to help you the best as i can


Re: Admin script problems - Zonoya - 09.06.2013

yeah your right, IsPlayerAdmin is for RCON, the pInfo[playerid][Adminlevel] is for my admin system, I'll try the message now

EDIT: Just tested with a message if you aren't an admin, it showed up, even when I am one,my point remains...


Re : Admin script problems - NvidiaForTheWin - 09.06.2013

if you got the message that is sent if you are not admin , then it is because you are not admin.
you still get unknown command ?


Re: Admin script problems - Zonoya - 09.06.2013

EDIT: Didn't work..., I know for a fact I'm an admin, for some reason though, it won't recognize it, wanna see my entire GM? I was only showing a snippet of it


Re : Admin script problems - NvidiaForTheWin - 09.06.2013

i don't need the full code because the rest isnt concerned here.
have you tried BEFORE and AFTER loggin as rcon ?

by the way just noticed in your format's that you are formating string and integer ( id and playerid )
you put twice %s but integer is %i

change all your format code

from
Код:
format(str, sizeof(str),"%s(%s) has demoted you to a regular player!",name,playerid);
to
Код:
format(str, sizeof(str),"%s(%i) has demoted you to a regular player!",name,playerid);
name = string
playerid & id = integer
%s = string
%i = integer


Re: Admin script problems - Zonoya - 09.06.2013

I got the message, but I think it's not calling from the file to check my admin rank correctly. And yeah, I only just realized that myself, I doubt it'll change anything though


Re : Admin script problems - NvidiaForTheWin - 09.06.2013

try removing the rank check code to see what happens now.
if everything work fine then you know your problem is reading the file or parsing its data.