A JavaScript wrapper over SourceMod.
SourceMod by itself is a modification to Source servers, such as Team Fortress 2 and Counter-Strike: Global Offensive. It allows you to write plugins that modify the game in all sorts of ways, from new gamemodes, to simple administration plugins. SourceMod.JS is a wrapper over SourceMod that lets you write plugins or custom server logic in JavaScript.
The JavaScript side (where you write your code) interfaces with an actual SourceMod server (where you install the plugin), via WebSockets. This effectively allows you to wirelessly control a server over the internet, but it is heavily recommended to host the SourceMod.JS plugin on the same machine (or network) as the actual SourceMod server, to reduce latency.
npm install sourcemod.js
import { Server } from "../index.js"
const server = new Server("ws://localhost:12345", { auth: "admin" })
server.connect()
server.on("ready", async () => {
console.log("Connected!")
server.players.on("connect", (id, name) => {
console.log(`${name} connected!`)
})
server.players.on("disconnect", (id, name) => {
console.log(`${name} disconnected!`)
})
})
// node test.js
// Connected!
// infinixius connected!
// infinixius disconnected!
Documentation is available at https://sourcemod.js.org/.
Before creating an issue or pull request, please ensure that it hasn't already been reported or suggested, and double-check the docs.
Currently, the only supported and tested game server is Team Fortress 2. If you'd like to help port and test sourcemod.js to other Source games, feel free to!
Other than that, feel free to contribute! Bugfixes, new features, or just better code in general are all greatly appreciated!
If you need help at any point, please feel free to contact me! You can find all of my links at https://infinixi.us, and my Discord is infinixius#5875. You can also ask for help on the issues page.
This project is under the MIT License. This allows you to use, modify, and distribute the source code as long as you include the license.
This project also makes use of the following libraries and/or projects:
Big thanks to punteroo for helping with the GiveWeapon
code!