SA-MP Forums Archive
/ban help - 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: /ban help (/showthread.php?tid=568686)



/ban help - nicholasramdhan - 24.03.2015

Okay so.. I have this command. In game, when I do /ban itself, it shows me the usage. but then when I do /ban with the player Id and reason EX: /ban 1 faggot, it says Unknown Command. So can someone please help me because I don't' know what else to do really. Here's the code for my /ban and /systemban, because I tried both and they both do the same thing.

Код:
CMD:ban(playerid, params[])
{
	if(!IsLoggedEx(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You must login before using any commands.");
	if(PlayerInfo[playerid][pAdmin] >= 1 || IsPlayerAdmin(playerid))
	{
		new giveplayerid, reason, log[250];
		if(!sscanf(params, "us[250]", giveplayerid, reason))
		{
			if(PlayerInfo[playerid][pAdmin] < PlayerInfo[giveplayerid][pAdmin]) return SendClientMessage(playerid, COLOR_GREY, "Player has a higher admin level than you.");
		    if(!IsPlayerConnected(giveplayerid))
		    {
		        SendClientMessage(playerid, COLOR_WHITE, "That player is not connected.");
			}
			else
			{
			    new string[256];
       			format(string, sizeof(string), "System: %s has been banned by %s. Reason: %s.", PlayerName(giveplayerid),PlayerName(playerid), reason);
		        SendClientMessageToAll(COLOR_ORANGE, string);
				format(log, sizeof(log), "BAN: %s was banned by %s. Reason: %s.", PlayerName(giveplayerid),PlayerName(playerid), reason);
				Log("Logs/Ban.log", log);
		        PlayerInfo[giveplayerid][pBanned] = 1;
		        AddBan(GetPlayerIpEx(giveplayerid));
			}
  }
		else
		{
			SendClientMessage(playerid, COLOR_WHITE, "USAGE: /Ban [Player ID] [Reason]");
		}
	}
	return 1;
}
CMD:systemban(playerid, params[])
{
	if(!IsLoggedEx(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You must login before using any commands.");
	if(PlayerInfo[playerid][pAdmin] >= 1 || IsPlayerAdmin(playerid))
	{
		new giveplayerid, reason, log[128];
		if(!sscanf(params, "us[128]", giveplayerid, reason))
		{
		    if(!IsPlayerConnected(giveplayerid))
		    {
		        SendClientMessage(playerid, COLOR_WHITE, "That player is not connected.");
			}
			else
			{
			    new string[256];
       			format(string, sizeof(string), "System: %s has been Auto-Banned by the System. Reason: %s.", PlayerName(giveplayerid), reason);
		        SendClientMessageToAll(COLOR_BRIGHTRED, string);
				format(log, sizeof(log), "SYSTEM-BAN: %s was System-Banned by %s. Reason: %s.", PlayerName(giveplayerid),PlayerName(playerid), reason);
				Log("Logs/Ban.log", log);
		        PlayerInfo[giveplayerid][pBanned] = 1;
		        AddBan(GetPlayerIpEx(giveplayerid));
			}
  }
		else
		{
			SendClientMessage(playerid, COLOR_WHITE, "USAGE: /SystemBan [Player ID] [Reason]");
		}
	}
	return 1;
}



Re: /ban help - X337 - 24.03.2015

Try this :
Код:
CMD:ban(playerid, params[])
{
	if(!IsLoggedEx(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You must login before using any commands.");
	if(PlayerInfo[playerid][pAdmin] >= 1 || IsPlayerAdmin(playerid))
	{
		new giveplayerid, reason[250], log[250];
		if(!sscanf(params, "us[250]", giveplayerid, reason))
		{
		    if(!IsPlayerConnected(giveplayerid))
		    {
		        SendClientMessage(playerid, COLOR_WHITE, "That player is not connected.");
			}
			else
			{
				if(PlayerInfo[playerid][pAdmin] < PlayerInfo[giveplayerid][pAdmin]) return SendClientMessage(playerid, COLOR_GREY, "Player has a higher admin level than you.");
			    new string[256];
       			format(string, sizeof(string), "System: %s has been banned by %s. Reason: %s.", PlayerName(giveplayerid),PlayerName(playerid), reason);
		        SendClientMessageToAll(COLOR_ORANGE, string);
				format(log, sizeof(log), "BAN: %s was banned by %s. Reason: %s.", PlayerName(giveplayerid),PlayerName(playerid), reason);
				Log("Logs/Ban.log", log);
		        PlayerInfo[giveplayerid][pBanned] = 1;
		        AddBan(GetPlayerIpEx(giveplayerid));
			}
  		}
		else
		{
			SendClientMessage(playerid, COLOR_WHITE, "USAGE: /Ban [Player ID] [Reason]");
		}
	}
	return 1;
}



Re: /ban help - JeaSon - 24.03.2015

it is becoz you defined reason as a veriable not a string

pawn Код:
CMD:ban(playerid, params[])
{
    if(!IsLoggedEx(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You must login before using any commands.");
    if(PlayerInfo[playerid][pAdmin] >= 1 || IsPlayerAdmin(playerid))
    {
        new giveplayerid, reason[64], log[250];
        if(!sscanf(params, "us[64]", giveplayerid, reason))
        {
            if(PlayerInfo[playerid][pAdmin] < PlayerInfo[giveplayerid][pAdmin]) return SendClientMessage(playerid, COLOR_GREY, "Player has a higher admin level than you.");
            if(!IsPlayerConnected(giveplayerid))
            {
                SendClientMessage(playerid, COLOR_WHITE, "That player is not connected.");
                }
            else
            {
                new string[256];
                format(string, sizeof(string), "System: %s has been banned by %s. Reason: %s.", PlayerName(giveplayerid),PlayerName(playerid), reason);
                    SendClientMessageToAll(COLOR_ORANGE, string);
                format(log, sizeof(log), "BAN: %s was banned by %s. Reason: %s.", PlayerName(giveplayerid),PlayerName(playerid), reason);
                Log("Logs/Ban.log", log);
                    PlayerInfo[giveplayerid][pBanned] = 1;
                    AddBan(GetPlayerIpEx(giveplayerid));
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /Ban [Player ID] [Reason]");
        }
    }
    return 1;
}
CMD:systemban(playerid, params[])
{
    if(!IsLoggedEx(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You must login before using any commands.");
    if(PlayerInfo[playerid][pAdmin] >= 1 || IsPlayerAdmin(playerid))
    {
        new giveplayerid, reason[64], log[128];
        if(!sscanf(params, "us[64]", giveplayerid, reason))
        {
            if(!IsPlayerConnected(giveplayerid))
            {
                SendClientMessage(playerid, COLOR_WHITE, "That player is not connected.");
            }
            else
            {
                new string[256];
                format(string, sizeof(string), "System: %s has been Auto-Banned by the System. Reason: %s.", PlayerName(giveplayerid), reason);
                SendClientMessageToAll(COLOR_BRIGHTRED, string);
                format(log, sizeof(log), "SYSTEM-BAN: %s was System-Banned by %s. Reason: %s.", PlayerName(giveplayerid),PlayerName(playerid), reason);
                Log("Logs/Ban.log", log);
                PlayerInfo[giveplayerid][pBanned] = 1;
                AddBan(GetPlayerIpEx(giveplayerid));
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /SystemBan [Player ID] [Reason]");
        }
    }
    return 1;
}



Re: /ban help - nicholasramdhan - 24.03.2015

Can't really test it... Can't ban my own IP lol.. but i tried it on myself it shuts down my server. It works I believe so. Anyway, is there a way it can show the player the reason before they lose connection?


Re: /ban help - JeaSon - 24.03.2015

just send message to giveplayerid like this
pawn Код:
new string[64]
      format(string, sizeof(string), "Admin %s (ID:%d) has banned you  for: %s",PlayerName(playerid), playerid, reason);
      SendClientMessage(giveplayerid, -1, string);



Re: /ban help - Sew_Sumi - 24.03.2015

Quote:
Originally Posted by nicholasramdhan
Посмотреть сообщение
Anyway, is there a way it can show the player the reason before they lose connection?
Timer of a second before the ban does it...


https://sampforum.blast.hk/showthread.php?tid=540505


****** would produce most of the answers you are seeking in here, and for everything else there's the Pawn handbook.