Scripting/Squirrel/Functions/BanIP: Difference between revisions

From Vice City Multiplayer
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing
No edit summary
Line 2: Line 2:


== Syntax ==
== Syntax ==
 
<pre>BanIP(ip)</pre>
<pre>BanIP( ip )</pre>


== Arguments ==
== Arguments ==
* ''string'' '''ip''' - This is the IP address to be banned
* ''string'' '''ip''' - This is the IP address to be banned


== Example ==
== Example ==
<source lang=squirrel>
<source lang=squirrel>
function onPlayerCommand( player, cmd, text )
function onPlayerCommand( player, cmd, text )
{
{
if ( cmd == "ban" )
if ( cmd == "ban" )
        {
{
      if ( !text ) MessagePlayer( "[Syntax] - /" + cmd + " <Nick/ID> <Reason>", player );
if ( !text )  
else {
{
  local plr = FindPlayer( GetTok( text, " ", 1 ) );
MessagePlayer( "[Syntax] - /ban <Nick/ID> <Reason>", player );
    if ( !plr ) MessagePlayer( "[Error] - Unknown Player..", player );
}
    else {
else  
            local reason = GetTok( text, " ", 2 NumTok( text, " " ) );
{
            local ip = plr.IP;
local plr = FindPlayer( GetTok( text, " ", 1 ) );
            local sub = split( ip, "." );
if ( !plr )
            if ( reason == null ) reason = "None";
{
            ( "INSERT INTO SubBans ( Name, IP, Admin, Reason ) VALUES ( '" + plr.Name + "', '" + sub[0].tofloat() + "." + sub[1].tofloat() + "', '" + player.Name + "', '" + reason + "' )" );
MessagePlayer( "[Error] - Unknown Player..", player );
            Message( "[#EE82EE]** Admin " + player.Name + " Banned " + plr.Name + " Reason: " + reason );
}
    BanPlayer( plr );
else  
    }
{
    }
local reason = GetTok( text, " ", 2 NumTok( text, " " ) );
  }
local ip = plr.IP;
}
local sub = split( ip, "." );
if ( reason == null ) reason = "None";
Message( "[#EE82EE]** Admin " + player.Name + " Banned " + plr.Name + " Reason: " + reason );
BanPlayer( plr );
}
}
}
return 1;
}
</source>


== Related Functions ==
== Related Functions ==
{{Scripting/Squirrel/Functions/Administrative_Functions}}
{{Scripting/Squirrel/Functions/Administrative_Functions}}

Revision as of 17:46, 23 April 2016

This function will ban an IP from the server.

Syntax

BanIP(ip)

Arguments

  • string ip - This is the IP address to be banned

Example

function onPlayerCommand( player, cmd, text )
{
	if ( cmd == "ban" )
	{
		if ( !text ) 
		{
			MessagePlayer( "[Syntax] - /ban <Nick/ID> <Reason>", player );
		}
		else 
		{
			local plr = FindPlayer( GetTok( text, " ", 1 ) );
			if ( !plr )
			{
				MessagePlayer( "[Error] - Unknown Player..", player );
			}
			else 
			{
				local reason = GetTok( text, " ", 2 NumTok( text, " " ) );
				local ip = plr.IP;
				local sub = split( ip, "." );
				if ( reason == null ) reason = "None";
				Message( "[#EE82EE]** Admin " + player.Name + " Banned " + plr.Name + " Reason: " + reason );
				BanPlayer( plr );
			}
		}
	}
	return 1;
}

Related Functions