You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 15, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+3-38Lines changed: 3 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,32 +8,10 @@ A JavaScript wrapper over SourceMod.
8
8
9
9
[SourceMod](https://www.sourcemod.net/) is a modification to Source servers, such as Team Fortress 2 and Counter-Strike: Global Offensive. SourceMod allows you to write plugins that modify the game in all sorts of ways, while SourceMod.JS lets you write plugins or custom server logic in JavaScript (instead of SourcePawn, the complicated language SourceMod uses), then interface with a SourceMod server via WebSockets.
10
10
11
-
# Installation
12
11
```
13
12
npm install sourcemod.js
14
13
```
15
14
16
-
First of all, install [MetaMod: Source](https://www.sourcemm.net/) and [SourceMod](https://www.sourcemod.net/) onto your Source server. Any version over **1.10** should work. Run your server and ensure SourceMod is working by running `sm version`.
17
-
18
-
Head over to the [releases](https://github.com/Infinixius/sourcemod.js/releases), and grab the latest plugin download. Drop it in `tf\addons\sourcemod\plugins`.
19
-
20
-
The plugin also uses [clugg's `sm-json`](https://github.com/clugg/sm-json) and [peace-maker's `sm-websocket`](https://github.com/peace-maker/sm-websocket) to communicate with the JavaScript plugin over WebSockets. Go ahead and install them to your server.
21
-
22
-
Go ahead and run your server. You should see the following if it worked:
23
-
```
24
-
[SMJS] sourcemod.js loaded!
25
-
[SMJS] Started WebSocket server on port 12345!
26
-
```
27
-
28
-
You can also run the console command `smjs_test`:
29
-
```
30
-
[SMJS] Test!
31
-
```
32
-
33
-
While the connection via WebSockets technically allows you to remotely control a SourceMod server, it's ideal to have the server and the SourceMod.JS plugin running on the same computer (or network) to minimize latency.
34
-
35
-
# Examples
36
-
37
15
```js
38
16
import { Server } from"sourcemod.js"
39
17
@@ -62,23 +40,10 @@ Documentation is available at [https://sourcemod.js.org/](https://sourcemod.js.o
62
40
63
41
Before creating an issue or pull request, please ensure that it hasn't already been reported or suggested, and double-check the [docs](https://infinixi.us/sourcemod.js).
64
42
43
+
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!
44
+
65
45
Other than that, feel free to contribute! Bugfixes, new features, or just better code in general are all greatly appreciated!
66
46
67
47
# License
68
48
69
-
This project is under the [MIT License](https://mit-license.org/). This allows you to use, modify, and distribute the source code as long as you include the license.
70
-
71
-
# Troubleshooting
72
-
73
-
### `Exception reported: Invalid match index passed.`
74
-
75
-
This is an issue with `sm-websockets`. Use [this version](https://github.com/peace-maker/sm-websocket/files/7966813/websocket.zip) I built myself that contains the fix, or just build it yourself.
76
-
77
-
### `Error: connect ECONNREFUSED`
78
-
79
-
This error boils down to the JavaScript plugin not being able to connect to the WebSocket server. This could be for several reasons:
80
-
81
-
- The SourceMod server isn't up
82
-
- The SourceMod plugin isn't working
83
-
- The port (`12345`) is taken by another service, or isn't port forwarded properly. (you need to port forward this port if you aren't accessing the WebSocket server from a LAN connection)
84
-
- You aren't connected to the internet
49
+
This project is under the [MIT License](https://mit-license.org/). This allows you to use, modify, and distribute the source code as long as you include the license.
<h2><ahref="index.html">Home</a></h2><h2><ahref="https://github.com/Infinixius/sourcemod.js" target="_blank" class="menu-item" id="github_link" >GitHub</a></h2><h2><ahref="https://www.npmjs.com/package/sourcemod.js" target="_blank" class="menu-item" id="npm_link" >NPM</a></h2><h3>Classes</h3><ul><li><ahref="Console.html">Console</a><ulclass='methods'><lidata-type='method'><ahref="Console.html#command">command</a></li><lidata-type='method'><ahref="Console.html#print">print</a></li></ul></li><li><ahref="Player.html">Player</a><ulclass='methods'><lidata-type='method'><ahref="Player.html#centerHint">centerHint</a></li><lidata-type='method'><ahref="Player.html#chat">chat</a></li><lidata-type='method'><ahref="Player.html#fetch">fetch</a></li><lidata-type='method'><ahref="Player.html#hint">hint</a></li><lidata-type='method'><ahref="Player.html#kick">kick</a></li><lidata-type='method'><ahref="Player.html#playSound">playSound</a></li><lidata-type='method'><ahref="Player.html#resetRendering">resetRendering</a></li><lidata-type='method'><ahref="Player.html#setRendering">setRendering</a></li><lidata-type='method'><ahref="Player.html#slap">slap</a></li><lidata-type='method'><ahref="Player.html#teleport">teleport</a></li><lidata-type='method'><ahref="Player.html#update">update</a></li></ul></li><li><ahref="Players.html">Players</a><ulclass='methods'><lidata-type='method'><ahref="Players.html#broadcast">broadcast</a></li><lidata-type='method'><ahref="Players.html#broadcastCenterHint">broadcastCenterHint</a></li><lidata-type='method'><ahref="Players.html#broadcastHint">broadcastHint</a></li><lidata-type='method'><ahref="Players.html#broadcastSound">broadcastSound</a></li><lidata-type='method'><ahref="Players.html#fetch">fetch</a></li><lidata-type='method'><ahref="Players.html#get">get</a></li></ul></li><li><ahref="Server.html">Server</a><ulclass='methods'><lidata-type='method'><ahref="Server.html#connect">connect</a></li><lidata-type='method'><ahref="Server.html#disconnect">disconnect</a></li><lidata-type='method'><ahref="Server.html#fetch">fetch</a></li><lidata-type='method'><ahref="Server.html#setMap">setMap</a></li><lidata-type='method'><ahref="Server.html#setNextMap">setNextMap</a></li></ul></li><li><ahref="Socket.html">Socket</a><ulclass='methods'><lidata-type='method'><ahref="Socket.html#disconnect">disconnect</a></li><lidata-type='method'><ahref="Socket.html#send">send</a></li></ul></li></ul><h3>Tutorials</h3><ul><li><ahref="tutorial-Configuration.html">Configuration</a></li><li><ahref="tutorial-Installation.html">Installation</a></li><li><ahref="tutorial-SoundsCSGO.html">Sounds - Counter-Strike: Global Offensive</a></li><li><ahref="tutorial-SoundsHL2.html">Sounds - Half-Life 2</a></li><li><ahref="tutorial-SoundsTF2.html">Sounds - Team Fortress 2</a></li><li><ahref="tutorial-Troubleshooting.html">Troubleshooting</a></li></ul><h3>Global</h3><ul><li><ahref="global.html#checkBytes">checkBytes</a></li><li><ahref="global.html#DisconnectReasons">DisconnectReasons</a></li><li><ahref="global.html#EngineVersion">EngineVersion</a></li><li><ahref="global.html#Events">Events</a></li><li><ahref="global.html#Messages">Messages</a></li><li><ahref="global.html#randArray">randArray</a></li><li><ahref="global.html#randInt">randInt</a></li><li><ahref="global.html#range">range</a></li><li><ahref="global.html#RenderEffects">RenderEffects</a></li><li><ahref="global.html#RenderModes">RenderModes</a></li></ul>
45
45
</nav>
46
46
47
47
<divid="main">
@@ -579,7 +579,7 @@ <h5>Parameters:</h5>
579
579
<brclass="clear">
580
580
581
581
<footer>
582
-
Documentation generated by <ahref="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Wed Feb 16 2022 17:02:50 GMT-0500 (Eastern Standard Time) using the <ahref="https://github.com/clenemt/docdash">docdash</a> theme.
582
+
Documentation generated by <ahref="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun May 01 2022 17:19:11 GMT-0400 (Eastern Daylight Time) using the <ahref="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <ahref="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Wed Feb 16 2022 17:02:50 GMT-0500 (Eastern Standard Time) using the <ahref="https://github.com/clenemt/docdash">docdash</a> theme.
116
+
Documentation generated by <ahref="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun May 01 2022 17:19:11 GMT-0400 (Eastern Daylight Time) using the <ahref="https://github.com/clenemt/docdash">docdash</a> theme.
0 commit comments