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
 
(5 intermediate revisions by 4 users not shown)
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) {
        {
      local params = split(text, " ");
      if ( !text ) MessagePlayer( "[Syntax] - /" + cmd + " <Nick/ID> <Reason>", player );
      local plr = FindPlayer(params[0]);
else {
      if (plr != null) {
  local plr = FindPlayer( GetTok( text, " ", 1 ) );
        if (params.len() >= 2) {
    if ( !plr ) MessagePlayer( "[Error] - Unknown Player..", player );
          local reason = params[1];
    else {
        } else {
            local reason = GetTok( text, " ", 2 NumTok( text, " " ) );
          reason = "None";
            local ip = plr.IP;
        }
            local sub = split( ip, "." );
        Message("[#EE82EE]** Admin " + player.Name + " Banned " + plr.Name + " Reason: " + reason);
            if ( reason == null ) reason = "None";
        MessagePlayer("You have been banned by: " + player.Name + ". Reason: " + reason, plr);
            ( "INSERT INTO SubBans ( Name, IP, Admin, Reason ) VALUES ( '" + plr.Name + "', '" + sub[0].tofloat() + "." + sub[1].tofloat() + "', '" + player.Name + "', '" + reason + "' )" );
        BanIP(plr.IP);
            Message( "[#EE82EE]** Admin " + player.Name + " Banned " + plr.Name + " Reason: " + reason );
        return 1;
    BanPlayer( plr );
      } else {
    }
        MessagePlayer("[Error] - Player " + params[0] + " not found!", player);
    }
        return 1;
      }
    }
    MessagePlayer("[Syntax] - /ban <Nick/ID> <Reason>", player);
   }
   }
}
  return 1;
}
</source>
 
=== Notes ===
Call [[onPlayerCommand]] were used in this example. More info about them in the corresponding pages.


== Related Functions ==
== Related Functions ==
{{Scripting/Squirrel/Functions/Administrative_Functions}}
{{Scripting/Squirrel/Functions/Administrative_Functions}}
[[Category:Scripting/Squirrel/Functions/Administrative_Functions]]

Latest revision as of 06:06, 2 May 2019

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

Notes

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

Related Functions