Page 1 of 1

Anti-camping script

Posted: Wed Feb 26, 2020 9:11 pm
by Diamondback
This is a basic anti-camping script I made which can be used as a client-side mod. Unfortunately server-side implementation of this script does not work, yet.

What it does is define a four-sided, two dimensional area (always a rectangle or a square) in any BF1942 map in which an "event" can happen after a key is pressed by an admin.

In the context of this script, the event would be the activation of a death bubble (or anything the server host desires) which is restricted to that area and would affect players which venture in the area either by mistake or voluntarily. In other words, anti-camping zones. Anti-camping areas can be of any size and can also be combined with each other to define more complex shapes.

Once the camper has entered the no camping zone(s), he or she would be punished in any way the server host desires (kicked, banned, announced to the rest of the server or killed, or any punishment method left to the imagination of the admin).

Here is the code for the script in its most basic form. I will explain each line, as well as how this script should be used. My raised_fist mod is used as an example here, it can be any mod. Please note that this script can only work as part of a client-side mod (not a map-side mod or patch). I will explain why below. To understand the script better, you can also read my Advanced CON file scripting in BF1942 guide, which can be accessed here: http://team-simple.org/forum/viewtopic.php?id=7785

Note: the script below has been tested on an Internet Linux server using Russ's fixed Linux server files.

Code: Select all

console.useRelativePaths 0
include mods/raised_fist/Settings/Profile/profile.con
console.useRelativePaths 1

Var v_locator = c_test
Var v_pos2
Var v_xcoord
Var v_zcoord
Var v_xcoord2
Var v_xcoord3
Var v_zcoord2
Var v_zcoord3

player.vehicle -> v_locator
object.active v_locator
object.absolutePosition -> v_pos2
Utils.getV3X v_pos2 -> v_xcoord
Utils.getV3Z v_pos2 -> v_zcoord
Utils.expr v_xcoord >= 1700 -> v_xcoord2
Utils.expr v_xcoord <= 1800 -> v_xcoord3
Utils.expr v_zcoord >= 1700 -> v_zcoord2
Utils.expr v_zcoord <= 1800 -> v_zcoord3

 
 if v_xcoord2

    if v_xcoord3

       if v_zcoord2

          if v_zcoord3

          game.sayAll "You are in the secret area" 

          else

          game.sayAll "You are not in the secret area" 

          endIf

       else

       game.sayAll "You are not in the secret area"

       endIf

          

    

    else 

    game.sayAll "You are not in the secret area" 
      
    endIf

         

 else
 
 game.sayAll "You are not in the secret area"

 endIf

Code: Select all

include mods/raised_fist/Settings/Profile/profile.con
Here I created a file called "profile.con" located in the directory next to the "include" command. In that profile.con file I defined a constant, with the Const prefix, which I called "c_test".
That c_test constant holds the name of a camping player or known trouble maker on the server, for which I want to verify if he or she is in the camping area(s) on the current map. I am currently trying to automate this so that defining a constant for a camping player is not necessary (the player.name command might work for this). Something important to know here is that the c_test constant can only work for players which do not have spaces in their nicknames. I am trying to find a fix for this currently.

Below the include command, I defined a bunch of variables to hold the values of a) the name of the problematic player, which is assumed to be camping (v_locator); b) the live coordinates of that player on the map (v_pos2) and c) the coordinates of my four sided anti camping area (v_xcoord; v_ycoord; v_xcoord2; v_ycoord2; v_xcoord3; v_ycoord3). The third code chunk, right below the variable definitions, assigns the appropriate console commands to the variables; it is not necessary to understand what these commands do 100% for now, just that they have been assigned to the correct variables.

Next, the body of the script, wrapped in if-else-endif conditional statements. There is one "main" if-else conditional statement in which three identical conditional statements are nested. These verify if the problematic player is in an area of the map where the X and Z coordinates are more than 1700 and less than 1800 BF units. If a player finds himself or herself within the X/Z coordinates (and thus inside the camping area), a client sayAll server message will appear notifying the rest of the server and the admin that this player is in the camping zone.

Alternatively, if that player happens not to be in that camping area (his position in X/Z coordinates does not correspond with the camping area), a sayAll message notifying the rest of the server that he or she is not in the camping area will appear. Of course, this is a very basic implementation of the anti-camping system; admins may write any commands they wish inside the first conditional statement ("You are in the secret area"), and on the press of a button the problematic player will be punished accordingly.

This script can be customized heavily as much as one wishes. A few limitations however are 1) having to write the name manually of a problematic player 2) always having to monitor where a player is on the map and 3) no server side implementation.

If you plan on using this script in your mod, I simply ask that you give me proper credits. After that, the script is yours, and you may customize it as much as you wish.