Sven Co-op
83 평점
Loading Angelscript plugins on your server
Zergeant 님이 작성
Learn about Angelscript and how to mount Angelscript plugins on your server.
   
어워드
즐겨찾기
즐겨찾기됨
즐겨찾기 해제
Introduction
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 PlayerManagement.as, EntityManager.as and Teleport.as, 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"
"name"
The "name" keyvalue serves to separate plugins from eachother, this is an obligatory keyvalue.
"script"
The path to the script, starting from scripts/plugins directory. Also an obligatory keyvalue.
"adminlevel"
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.
"concommandns"
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.

Command
What it does
Restriction
as_listplugins
Lists plugins currently loaded on the server
Everyone
as_reloadplugin
Reload a plugin from the list of plugins
Admin
as_removeplugin
Removes a plugin from the list of plugins
Admin
as_reloadplugins
Reloads all plugins from the plugin list
Admin
as_removeplugins
Removes all plugins from the server
Admin

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.

PlayerManagement.as
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
댓글 70
THE COMBINE245 2022년 5월 24일 오전 7시 28분 
Good friend because the complements such as night vision and the creator entity that is to generate npc no longer work
Davix291 2020년 3월 27일 오전 11시 10분 
ok, after a bit I found out that I have angelscript and everything but, it looks like that steamID actualy gives me the wrong ID? instead of STEAM_1:0:28300115 Svencoop actualy wanted STEAM_0:0:28300115 for some reason. sorry if I typed stuff here anyway
Davix291 2020년 3월 27일 오전 10시 47분 
I recently installed a Svencoop server on my pc using SteamCMD, for some reason it doesn't look like I have Angelscript or something like that, I can't add myself to admins using admins.txt for some reasons and when lookig for as_ commands listing with "cvarlist as_" only 3 commands pop up: as_file_size_quota; as_log_level; as_script_log_max;
Deludank 2020년 2월 11일 오전 6시 59분 
@Grain Elevator for some reason the say command is blocked by the game, is like if was blacklisted.
Cadλver 2020년 2월 1일 오전 12시 16분 
You had to use rcon as_command
Grain Elevator 2020년 1월 31일 오전 10시 05분 
How do you run Angelscript commands through the server console? Using "say .command" through the server console does not call script commands, instead it just says the string without parsing it.
SpiriT 2020년 1월 1일 오후 11시 37분 
.
Zergeant  [작성자] 2019년 6월 1일 오후 12시 44분 
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.
Red The Fox 2019년 5월 31일 오전 4시 45분 
so that's why with Keep in mind that lines starting with "//" im i right?
zearl 2018년 6월 25일 오후 6시 54분 
right. i thought so, but wasn't sure. thanks for the help!