Scripting/Squirrel/Functions/BanIP

From Vice City Multiplayer
Revision as of 16:25, 25 April 2016 by Pun1sh3r (talk | contribs)
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing

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;
}

Notes

Call onPlayerCommand were used in this example. More info about them in the corresponding pages.

Related Functions