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 9: Line 9:
== 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 )  
        if ( !text )  
{
        {
MessagePlayer( "[Syntax] - /ban <Nick/ID> <Reason>", player );
            MessagePlayer( "[Syntax] - /ban <Nick/ID> <Reason>", player );
}
        }
else  
        else  
{
        {
local plr = FindPlayer( GetTok( text, " ", 1 ) );
        local params = split( text, " " ), plr = FindPlayer( params[0] ), reason = params[1];  
if ( !plr )
        Message( "[#EE82EE]** Admin " + player.Name + " Banned " + plr.Name + " Reason: " + reason );
{
        MessagePlayer( " You have been banned. Reason: " + reason + " by: " + player.Name , plr );
MessagePlayer( "[Error] - Unknown Player..", player );
        BanPlayer( plr );
}
        }
else
    }
{
    return 1;
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>
</source>

Revision as of 16:20, 21 September 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 params = split( text, " " ), plr = FindPlayer( params[0] ), reason = params[1]; 
         Message( "[#EE82EE]** Admin " + player.Name + " Banned " + plr.Name + " Reason: " + reason );
         MessagePlayer( " You have been banned. Reason: " + reason + " by: " + player.Name , plr );
         BanPlayer( plr );
        }
    }
    return 1;
}

Notes

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

Related Functions