Problem with admin CMDS
#1

Hello!

I got a problem,I want that when some admin would enter command /ban it would say You dont have appropriate administrator level to run this command.But for example i am level 1 and cmd /ban is for level 3 and when i type /ban it says Usage: /ban [ID] [REASON] ,I would like it to be when some admin under level 3 type /ban it would say You dont have appropriate administrator level to run this command.Not to show him usage.Here is my script,please edit it :

Код:
CMD:ban(playerid,params[])
{
		if(pInfo[playerid][Adminlevel] >=3 || IsPlayerAdmin(playerid))
        return SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} You don't have an appropriate administration level to use this command.");
        new targetid, R[25], string[100];//R = Reason
        new name[MAX_PLAYERS], name2[MAX_PLAYERS];
        new Query[500];
        new ip[16];
        GetPlayerIp(targetid, ip, sizeof(ip));
        GetPlayerName(targetid, name2, sizeof(name2));

        if(sscanf(params, "ds", targetid, R))
        {
            SendClientMessage(playerid, COLOR_YELLOW, "Usage:{FFFFFF} /ban [ID] [Reason]");
            return 1;
        }
        if(!IsPlayerConnected(targetid))
        {
       		SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} Player is not connected!");
			return 1;
		}
		if(pInfo[targetid][USER_LOGGED_IN] == false)
		{
	    	SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} Player has not logged in");
	    	return 1;
		}
        if(pInfo[playerid][Adminlevel] >=3 || IsPlayerAdmin(playerid))
		{
                GetPlayerName(playerid, name, sizeof(name));
                GetPlayerName(targetid, name2, sizeof(name2));
                format(string, sizeof(string), "[ADMIN]{FFFFFF} %s has been banned by %s(%d) {28f200}[reason: %s]", name2, name, playerid, R);
                SendClientMessageToAll(COLOR_ADMIN, string);
                pInfo[targetid][Banned] = 1;
                format(string, sizeof(string), "banip %s", ip);
                SendRconCommand(string);
                SendRconCommand("reloadbans");
                
                format(Query, sizeof(Query), "UPDATE users SET banned = %d WHERE username = '%s'",
												pInfo[targetid][Banned],
												targetid);
        		db_query(DatabaseAcc, Query);
        		Kicked(targetid, 500);

    	}
    	else
		{
		    return SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} You don't have an appropriate administration level to use this command.");
		}
		return 1;
}
Reply
#2

- Not tested.

Код:
CMD:ban(playerid,params[])
{
        new targetid, R[25], string[100];//R = Reason
        new name[MAX_PLAYERS], name2[MAX_PLAYERS];
        new Query[500];
        new ip[16];
		if(pInfo[playerid][Adminlevel] < 3 || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} You don't have an appropriate administration level to use this command.");
        if(sscanf(params, "ds", targetid, R)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage:{FFFFFF} /ban [ID] [Reason]");
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} Player is not connected!");
        if(pInfo[targetid][USER_LOGGED_IN] == false) return SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} Player has not logged in");

        GetPlayerIp(targetid, ip, sizeof(ip));
        GetPlayerName(targetid, name2, sizeof(name2));
        GetPlayerName(playerid, name, sizeof(name));
        GetPlayerName(targetid, name2, sizeof(name2));
        format(string, sizeof(string), "[ADMIN]{FFFFFF} %s has been banned by %s(%d) {28f200}[reason: %s]", name2, name, playerid, R);
        SendClientMessageToAll(COLOR_ADMIN, string);
        pInfo[targetid][Banned] = 1;
        format(string, sizeof(string), "banip %s", ip);
        SendRconCommand(string);
        SendRconCommand("reloadbans");
		format(Query, sizeof(Query), "UPDATE users SET banned = %d WHERE username = '%s'",pInfo[targetid][Banned],targetid);
		db_query(DatabaseAcc, Query);
		Kicked(targetid, 500);
		return 1;
}
Reply
#3

Correction:
pawn Код:
CMD:ban(playerid,params[])
{
    if(pInfo[playerid][Adminlevel] < 3 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} You don't have an appropriate administration level to use this command.");
    new targetid, reason[25];
    if(sscanf(params, "ds[25]", targetid, reason)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: {FFFFFF}/ban [ID] [Reason]");
    if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} Player is not connected!");
    if(pInfo[targetid][USER_LOGGED_IN] == false) return SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} Player has not logged in.");
    new ip[16], string[100], Query[500], name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME];
    GetPlayerIp(targetid, ip, sizeof(ip));
    GetPlayerName(targetid, name2, sizeof(name2));
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "[ADMIN]{FFFFFF} %s(%d) has been banned by %s(%d) {28f200}[reason: %s]", name2, targetid, name, playerid, reason);
    SendClientMessageToAll(COLOR_ADMIN, string);
    pInfo[targetid][Banned] = 1;
    format(string, sizeof(string), "banip %s", ip);
    SendRconCommand(string);
    SendRconCommand("reloadbans");
    format(Query, sizeof(Query), "UPDATE users SET banned = %d WHERE username = '%s'",pInfo[targetid][Banned],targetid);
    db_query(DatabaseAcc, Query);
    Kicked(targetid, 500);
    return 1;
}
Reply
#4

BenzoAMG

What did you added/removed/corrected so I can fix other commands like /jail
Reply
#5

I fixed some of your array sizes so you weren't using data when it wasn't needed. Like creating variables like Query[500] before you'd even done your admin checks. Meaning you're creating variables that will never be used, and resulting in unnecessary data usage.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)