Ban won't work?
#1

Hello.
I just made my ban command and it won't work..


Код:
CMD:ban(playerid, params[])
{
	if(IsPlayerAdmin(playerid))
	{
	 	new PID; //define the playerid we wanna ban
	 	new reason[64]; //the reason, put into a string
	  	new str[128]; //a new message string max 128
	  	new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
	  	GetPlayerName(playerid, Adminname, sizeof(Adminname));
	  	GetPlayerName(PID, Playername, sizeof(Playername));
	  	if(sscanf(params, "us[64]", PID, reason)) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /ban [playerid] [reason]");
		if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, COLOR_ERROR, "[ERROR] The player is not connected!");
		format(str, sizeof(str), "[BAN] '%s' has been banned by administrator '%s'. Reason: %s ", Playername, Adminname, reason);
	 	SendClientMessageToAll(COLOR_ACHIEVEMENT, str);
		Ban(PID);
 	}else{
		SendClientMessage(playerid, COLOR_ERROR, "[ERROR] Only admins can use this command. Use /help.");
	}
	return 1;
}
If I use /ban 1 goaway it will display me the USAGE thing...
What's wrong?

Thank you.
Reply
#2

Try this(easy to edit):
pawn Код:
CMD:ban(playerid, params[])
{
    if(PlayerInfo[playerid][pAdminDuty] == 0) return SendClientMessage(playerid, -1, "You must be on Admin Duty to use this Command!");
    if (PlayerInfo[playerid][pAdmin] >= 2)
    {
        new string[128], giveplayerid, reason[64];
        if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /ban [playerid] [reason]");

        if(IsPlayerConnected(giveplayerid))
        {
            if(PlayerInfo[giveplayerid][pAdmin] > PlayerInfo[playerid][pAdmin])
            {
                format(string, sizeof(string), "AdmCmd: %s has been auto-banned, reason: Trying to /ban a higher admin.", GetPlayerNameEx(playerid));
                ABroadCast(COLOR_YELLOW,string,2);
                PlayerInfo[playerid][pBanned] = 1;
                new ip[32];
                GetPlayerIp(playerid,ip,sizeof(ip));
                AddBan(ip);
                Kick(playerid);
                return 1;
            }
            else
            {
                new year, month,day;
                getdate(year, month, day);
                new playerip[32];
                GetPlayerIp(giveplayerid, playerip, sizeof(playerip));
                format(string, sizeof(string), "AdmCmd: %s(IP:%s) was banned by %s, reason: %s (%d-%d-%d)", GetPlayerNameEx(giveplayerid), playerip, GetPlayerNameEx(playerid), reason,month,day,year);
                Log("logs/ban.log", string);
                format(string, sizeof(string), "AdmCmd: %s was banned by %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
                SendClientMessageToAllEx(COLOR_LIGHTRED, string);
                PlayerInfo[giveplayerid][pBanned] = 1;
                format(PlayerInfo[giveplayerid][pFlag], 128, "");
                new ip[32];
                GetPlayerIp(giveplayerid,ip,sizeof(ip));
                AddBan(ip);
                Kick(giveplayerid);
                return 1;
            }

        }
    }
    else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
    return 1;
}
Reply
#3

Thank you for basically pasting me totally something else....

I still need help to fix the command, I hope you guys can fix it
Thank you
Reply
#4

You know you can just replace it...but if you don't want, no need.
Reply
#5

You put this line:
pawn Код:
GetPlayerName(PID, Playername, sizeof(Playername));
before the sscanf line when the variable isn't initialized yet. You need to put it after it.
Reply
#6

It is broadcasting that they are banned, But yet it's not going a effect of the ban, I saw it before but I lost it, you have a bug in your script mate.
Reply
#7

Quote:
Originally Posted by SiRbEaSt
Посмотреть сообщение
Try this(easy to edit):
pawn Код:
CMD:ban(playerid, params[])
{
    if(PlayerInfo[playerid][pAdminDuty] == 0) return SendClientMessage(playerid, -1, "You must be on Admin Duty to use this Command!");
    if (PlayerInfo[playerid][pAdmin] >= 2)
    {
        new string[128], giveplayerid, reason[64];
        if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /ban [playerid] [reason]");

        if(IsPlayerConnected(giveplayerid))
        {
            if(PlayerInfo[giveplayerid][pAdmin] > PlayerInfo[playerid][pAdmin])
            {
                format(string, sizeof(string), "AdmCmd: %s has been auto-banned, reason: Trying to /ban a higher admin.", GetPlayerNameEx(playerid));
                ABroadCast(COLOR_YELLOW,string,2);
                PlayerInfo[playerid][pBanned] = 1;
                new ip[32];
                GetPlayerIp(playerid,ip,sizeof(ip));
                AddBan(ip);
                Kick(playerid);
                return 1;
            }
            else
            {
                new year, month,day;
                getdate(year, month, day);
                new playerip[32];
                GetPlayerIp(giveplayerid, playerip, sizeof(playerip));
                format(string, sizeof(string), "AdmCmd: %s(IP:%s) was banned by %s, reason: %s (%d-%d-%d)", GetPlayerNameEx(giveplayerid), playerip, GetPlayerNameEx(playerid), reason,month,day,year);
                Log("logs/ban.log", string);
                format(string, sizeof(string), "AdmCmd: %s was banned by %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
                SendClientMessageToAllEx(COLOR_LIGHTRED, string);
                PlayerInfo[giveplayerid][pBanned] = 1;
                format(PlayerInfo[giveplayerid][pFlag], 128, "");
                new ip[32];
                GetPlayerIp(giveplayerid,ip,sizeof(ip));
                AddBan(ip);
                Kick(giveplayerid);
                return 1;
            }

        }
    }
    else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
    return 1;
}
Nice copy and paste from the NG*P gamemode mate.
Reply
#8

Tried everything, still won't work? I just can't figure out what's wrong...
Here is the script again if you need it:

Код:
CMD:ban(playerid, params[])
{
	if(IsPlayerAdmin(playerid))
	{
	    new PID;
	 	new reason[64]; //the reason, put into a string
	  	new str[128]; //a new message string max 128
	  	new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
	  	GetPlayerName(playerid, Adminname, sizeof(Adminname));
	  	GetPlayerName(PID, Playername, sizeof(Playername));
	  	if(sscanf(params, "us[64]", PID, reason)) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /ban [id] [reason]");
		if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, COLOR_ERROR, "[ERROR] The player is not connected!");
		format(str, sizeof(str), "[BAN] '%s' has been banned by admin '%s'. Reason: %s ", Playername, Adminname, reason);
	 	SendClientMessageToAll(COLOR_ACHIEVEMENT, str);
		Ban(PID);
 	}else{
		SendClientMessage(playerid, COLOR_ERROR, "[ERROR] Only admins can use this command. Use /help.");
	}
	return 1;
}
Reply
#9

This should work if you are RCON Admin.
pawn Код:
CMD:ban(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ERROR, "[ERROR] Only admins can use this command. Use /help.");
    new PID; //define the playerid we wanna ban
    new reason[64]; //the reason, put into a string
    if(sscanf(params, "us[64]", PID, reason)) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /ban [playerid] [reason]");
    if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, COLOR_ERROR, "[ERROR] The player is not connected!");
    new str[128]; //a new message string max 128
    new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Adminname, sizeof(Adminname));
    GetPlayerName(PID, Playername, sizeof(Playername));
    format(str, sizeof(str), "[BAN] '%s' has been banned by administrator '%s'. Reason: %s ", Playername, Adminname, reason);
    SendClientMessageToAll(COLOR_ACHIEVEMENT, str);
    Ban(PID);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)