Sourcemod: Difference between revisions
No edit summary |
mNo edit summary |
||
Line 112: | Line 112: | ||
\x07008000 for enabled, unlocked or simply positive [green] | \x07008000 for enabled, unlocked or simply positive [green] | ||
\x07b30000 for disabled, locked or simply negative, also for warnings [red]</pre> | \x07b30000 for disabled, locked or simply negative, also for warnings [red]</pre> | ||
[[Category:Sourcemod]] |
Revision as of 02:29, 11 February 2022
Sourcemod allows you to extend Empires without having access to the C++ code.
Installation
- Install MetaMod:
- Download sourcemod: http://www.sourcemod.net/downloads.php?branch=stable
- Copy the cfg and addons folders to your empires folder
- Install some Sourcemod Plugins
Developing Plugins
Empires has a lot of game events you can make use of. For an example of plugins you can make see our sourcemod repository.
Compiling from Source
Thanks to people smarter than me, compiling from source is pretty easy.
Take your source-file or source-text and pop it in this: http://www.sourcemod.net/compiler.php
Download your compiled plugin, and put it in your sourcemod/plugins folder.
Or you can use spcomp.exe inside your sourcemod folders (\addons\sourcemod\scripting\spcomp.exe) (for windows)
Just drag and drop your source-file onto the .exe.
Sourcemod offsets and signatures
Get latest offsets ready to use here https://git.empiresmod.com/sourcemod/sourcemodoffsets
If you have issues with invalid signatures.
Example:
L 03/18/2017 - 00:02:51: [SDKTOOLS] Invalid detour address passed - Disabling detour to prevent crashes L 03/18/2017 - 00:02:51: [SM] Exception reported: Entity Outputs are disabled - See error logs for details
Choice 1. Just download latest ready to use offsets here: https://git.empiresmod.com/sourcemod/sourcemodoffsets
Choice 2. Replace the linux signatures in sdkhooks and sdktools files with the mac signatures. (this is already included in the above release)
This is rather temporary fix and needs testing
Example:
/* CBaseEntityOutput::FireOutput */ "#default" { "Signatures" { "FireOutput" { "library" "server" "windows" "\x55\x8B\xEC\x81\x2A\x2A\x2A\x2A\x2A\xA1\x2A\x2A\x2A\x2A\x33\xC5\x89\x45\x2A\x8B\x45\x2A\x53\x56\x8B\x2A\x2A\x57\x8B\x2A\x2A\x89\x2A\x2A\x2A\x2A\x2A\x89\x2A\x2A\x2A\x2A\x2A\x89\x2A\x2A\x2A\x2A\x2A\xC7" "linux" "@_ZN17CBaseEntityOutput10FireOutputE9variant_tP11CBaseEntityS2_f" "mac" "@_ZN17CBaseEntityOutput10FireOutputE9variant_tP11CBaseEntityS2_f" } } }
Dumping updated Sourcemod offsets and signatures
Related thread: https://forums.empiresmod.com/index.php?threads/calculating-updated-sourcemod-vtable-offsets.20571/
Tool needed: https://delftelectronics.nl/empires/tools/vtablescanner3.zip
The tool requires linux. If you are running 64bit linux, you will probably need to run the following to be able to run 32bit apps:
dpkg --add-architecture i386 apt-get update apt install libc6:i386 libelf1:i386
Unpack the vtablescanner3.zip anywhere in your linux.
Next you need a server.so file from your dedicated server which is located in /empires_dedicated/empires/bin
Copy server.so to the Release folder in the vtablescanner folder that you extracted. (vtablescanner/Release/server.so)
Now open your terminal inside the Release folder.
And enter the following command:
LD_LIBRARY_PATH="./" ./vtabledump ./server.so '_ZTV10CEmpPlayer' >dump.txt
The outputted RAW offsets are now located in vtablescanner/Release/dump.txt
Now if you want to output a proper file for SourceMod.
Open the terminal again inside Release folder.
Type:
./createoffsetscript >dumpsmoffsets.txt
This output file is the game.empires.txt which you can put into your:
\addons\sourcemod\gamedata\sdkhooks.games\custom\game.empires.txt
\addons\sourcemod\gamedata\sdktools.games\custom\game.empires.txt
Also check this for offsets that need adjusting after a dump: https://git.empiresmod.com/sourcemod/sourcemodoffsets/issues/1
Plugin-Making tips
Dumping:
To get a dump of entity properties specific to empires and similar things, use following commands.
"sm_dump_teprops" - Dumps tempentity props to a file
"sm_dump_netprops_xml" - Dumps the networkable property table as an XML file
"sm_dump_netprops" - Dumps the networkable property table as a text file
"sm_dump_classes" - Dumps the class list as a text file
"sm_dump_datamaps" - Dumps the data map list as a text file
"sm_dump_admcache" - Dumps the admin cache for debugging
"sm_dump_handles" - Dumps Handle usage to a file for finding Handle leaks
Just add a filename after the command and you will find the dump files in empires folder.
Just using some of those commands might make your client/server hang or even crash, but it will probably still make the dump, or just retry.
Colors for messages:
Custom colors usable by PrintToChat and similar.
Examples:
\x079764FF BE \x07FF2323 NF PrintToChatAll("\x04[PLUGIN]\x079764FF BE\x01 not ready"); PrintToChatAll("\x04[PLUGIN]\x01 Commander left\x07FF2323 NF");
\x07 - Type of coloring/message (custom colors seem to only work with \x07 and \x08)
9764FF - HTML RRGGBB color without the # (You can pick your own color for example here: https://www.w3schools.com/colors/colors_picker.asp)
Neoony's color standards: (Updated 18.4.2017 - Added player name color
\x01 for standard text \x04 for plugin things (example: "\x04[NCEV]\x01") [green] \x079764FF for Brenodi Empire team [eyedropped from chat text] \x07FF2323 for Northern Faction team [eyedropped from chat text] \x07CB4491 for Both teams [mixed color of BE and NF, somewhat pink] \x07CCCCCC for Spectators [gray] \x07ff6600 for player name, if you cant use team colors for that [orange] \x073399ff for displaying time, mainly seconds [light blue] \x07008000 for enabled, unlocked or simply positive [green] \x07b30000 for disabled, locked or simply negative, also for warnings [red]