Sven Co-op

Sven Co-op

62 ratings
Loading Angelscript plugins on your server
By Zergeant
Learn about Angelscript and how to mount Angelscript plugins on your server.
Hello, my name is Zergeant and I've been helping the Sven Coop Team out since June 2015. Today I will help you familiarize yourself with Angelscript plugins and how to autoload them on your server.

Now why would you want to autoload plugins for your server? Well if you desire to have extra functions or features for your server like admin tools or the ability for players to play random game sounds, then the easiest way would be to load an Angelscript plugin that does exactly that. Sven Coop comes bundled with Angelscript plugins ready to be used, a few of these are, and, all performing and filling their own functions.

So what is Angelscript? Angelscript is a programming language Sven Coop makes use of to give more power to map makers and server owners. With Angelscript a map maker could, for example, create new monsters, new weapons or scripts to perform map events. A server host as you already know by now, can use Angelscript to load admin tools or other features for the server. But a very important note is that there's a difference between the plugins a server owner loads and the scripts that a map maker loads, which we will be covering in the next section.
Server plugins & Map scripts
While visually identical, Angelscript files meant to be loaded as plugins for the server is loaded differently than how the game loads Angelscript files for maps. Angelscript files can be loaded in two ways, by the 'default_plugins.txt' file in your main svencoop directory or by a map's cfg file. For now we will be looking at default_plugins.txt, which tells the game what plugins should be loaded.

As you can see we already have a few entries as standard and you can also see where I added another plugin to be loaded. Loading a plugin will take a few keyvalues, there are four keyvalues available when loading a plugin.
  • "name"
  • "script"
  • "adminlevel"
  • "concommandns"
The "name" keyvalue serves to separate plugins from eachother, this is an obligatory keyvalue.
The path to the script, starting from scripts/plugins directory. Also an obligatory keyvalue.
Defines whether or not this plugin and it's functions is to be restricted to admins or server owner only. This keyvalue is optional and not necessary to include.
Flags that "adminlevel" keyvalue will accept: "ADMIN_NO" - Plugin features are available to all players. "ADMIN_YES" - Plugin features restricted to admins and server owner. "ADMIN_OWNER" - Plugin features only useable by the server owner.
Defines the console command namespace for this plugin, used by the plugin console commands. Optional and can be discluded.

Now you know how to add and load more plugins for your server! Keep in mind that lines starting with "//" will NOT be loaded.

So where do we find all these plugins? In the scripts/plugins directory you will find all Angelscript files that can be loaded as plugins, there is also a directory called scripts/maps which is where the map scripts go. What separates plugins from map scripts is that they use the method PluginInit to get initialized by default_plugins.txt, plugins need to have this method provided or they cannot be loaded. If you need to check if an Angelscript file can be loaded as a plugin, open it up in in a text-editor program, preferrably Notepad++, open the search function (Usually CTRL+F) and search for PluginInit. If you find a result the file is most likely supposed to be a plugin.

Another major note to remember if you create Angelscript plugins is that a plugin cannot define new entities. For example, you cannot load a custom weapon or monster, this can only be done by map scripts.
Commands & Usage
Sven Coop has commands to manage Angelscript files that have been loaded, there's also specific commands just for plugins.

What it does
Lists plugins currently loaded on the server
Reload a plugin from the list of plugins
Removes a plugin from the list of plugins
Reloads all plugins from the plugin list
Removes all plugins from the server

With the use of these commands we can now manage the plugins currently active on the server. Since we have specified a few plugins to be loaded in our default_plugins.txt we are now ready to venture in game and see if the plugins were successfully loaded.

The plugins have been loaded! We can now make use of the functions they provide. As an example, this guide will go through the use of PlayerManagement, as it's loaded by default and features very handy admin tools.
This plugin features all the usual admin commands, such as slap, slay and teleport. Unlike typical admin tools, this plugin has you enter the commands in chat, very handy if you don't want to bring up the menu. And don't worry, the commands won't be visible to other players.
  • admin_slap [name/steamid] [damage] [times to slap] - Slaps the player for X amount of damage and Y amount of times
  • admin_slay [name/steamid] - Kills the player
  • admin_kick [name/steamid] [minutes] - Kicks the player. Minutes are optional, otherwise uses the time defined by mp_kickbantime
  • admin_ban [name/steamid] [minutes] - Bans the player. Minutes are optional, otherwise uses the time defined by mp_bantime
  • admin_teleport [name/steamid] [X] [Y] [Z] - Teleports the player to given map coordinates
  • admin_sethealth [name/steamid] [amount] - Gives the player X amount of health
  • admin_setarmor [name/steamid] [amount] - Gives the player X amount of armor
Your server is now properly equipped with ease-of-access admin commands. Just dont forget to add all necessary steam ids to your admins.txt file! If you ever need to use another admin.txt file, you can re-direct which file to load using the command "adminsfile".

Also, if a plugin creates console commands, these will have to be entered with a dot (.) at the start. For example, if I created a plugin that fired a rocket everytime I entered the command "firerocket" in the console, it would have to be entered as ".firerocket".
Conclusion & Final words
You will now have learnt mostly how Sven Coop's Angelscript plugin system works, how to load further plugins and which type of Angelscript files can be loaded. Whether you're a map maker or server owner, Angelscript can easily help you add useful functions. As a proof-of-concept and a bonus for finishing this guide, here's a video of me going through Black Mesa with the newfound Angelscript possibilities.

Thanks for your time and interest in Sven Coop!

< >
Zergeant  [author] Jun 1 @ 12:44pm 
Lines starting with "//" are so called Comments. The program will ignore those lines and are mostly for programmers and readers to keep in mind, that is correct.
❤️☕️Cuphead🥤❤ May 31 @ 4:45am 
so that's why with Keep in mind that lines starting with "//" im i right?
deludank Sep 25, 2018 @ 5:33pm 
how to add afb on sven server?
vil Jun 25, 2018 @ 6:54pm 
right. i thought so, but wasn't sure. thanks for the help!
Zergeant  [author] Jun 25, 2018 @ 6:42pm 
I'm not sure and I don't think they are as well documented. You can just open them in a text editor like Notepad++ and search for "CClientCommand", which registers the command for clients to use. Remember that you need to type a dot (.) in front of the AS command, e.g. .slap player.
vil Jun 25, 2018 @ 6:38pm 
how do i use the vox and yell plugins? do i have to look through the as file for the console commands or something? is it documented somewhere?
Sturmgewehrz Jun 12, 2018 @ 4:05pm 
i figured that out, but no angelscript plugin commands that require being admin work for me despite my steam id being in admins.txt and it showing that I'm the server owner in game.
Cadλver Jun 11, 2018 @ 9:00pm 
If you are running an dedicated server you need to add rcon before any of that cvar.
eg: rcon as_reloadplugins
Sturmgewehrz Jun 11, 2018 @ 8:29pm 
For some reason none of the admin commands (as_reloadplugin, as_removeplugin, etc.) work for me, it doesn't even recognize them as a command. as_listplugins works fine though. I'm set as admin/owner in admins.txt and I have the gold icon next to my name in the server.
Zergeant  [author] Jun 25, 2017 @ 12:21pm 
Hi Rei. From the way you're describing it, it should be fully doable. I've fallen out a bit with development around Angelscript in SC unfortunately so I'm not sure if it's still impossible to write to a file.
You can load data from a file though so you should be able to get coordinates from points of interest in your desired map and store it manually in a file, and then load the coordinates with Angelscript to put a checkpoint at a location.
Lots of things have changed with Angelscript though such as servers finally being able to load custom weapons. Hope this helps.