A JavaScript wrapper over SourceMod
npm install sourcemod.js
npm install sourcemod.js
`
`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/.
Contributing
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.
License
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:
- smlib
- sm-json
- sm-websocket
- SourceMod Sockets
- ws
Big thanks to punteroo for helping with the GiveWeapon` code!