Skip to content

Commit 740c3ac

Browse files
author
Sierra Nevada
committed
feat: add Garry's Mod 10-12 support with Lua bridge
- Add gmod_bridge.py for automatic Lua addon installation - Auto-install Lua scripts to addons/sourcebox/lua/ - Implement picker with NPC priority targeting - Add auto-spawner for random placement on map load - Update README with GMod documentation and troubleshooting
1 parent 3ecd77a commit 740c3ac

File tree

4 files changed

+1312
-141
lines changed

4 files changed

+1312
-141
lines changed

README.md

Lines changed: 207 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,73 @@
11
# SourceBox
22

3-
An application with Source Engine integration through VScript.
3+
An application with Source Engine integration through VScript and Garry's Mod Lua scripting.
44

55
![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux-blue)
66
![Python](https://img.shields.io/badge/python-3.7+-green)
77
![License](https://img.shields.io/badge/license-MIT-orange)
88

99
> [!NOTE]
1010
> SRCBOX cube model is a custom model! You need to install it into your game custom folder otherwise it won't spawn when you press the cube in SourceBox window.
11-
> It should be this `YOUR_GAME\custom\srcbox\models\props\srcbox\srcbox.mdl`.
11+
> It should be in `YOUR_GAME\custom\srcbox\models\props\srcbox\srcbox.mdl`.
1212
>
1313
> You can download it [here!](https://github.com/Kiverix/srcbox.mdl/releases)
1414
1515
## Features
16-
- **Source Engine Bridge**: Spawn the very silly cube directly into Source games
17-
- **Picker (Aimbot)**: Advanced targeting system with manual selection
18-
- **AWP Quit Trigger**: Shoot spawned props with AWP to quit the game
19-
- **Auto-load Scripts**: Automatically loads on every map
20-
- **Auto spawning cube**: Spawn cube on random location of the map.
16+
- **Python Bridge**: Spawn props directly from SourceBox into your game
17+
- **Multi-game Support**: Works across most Source Engine games
2118

22-
## Supported Games
19+
### VScript Features (TF2 Branch Source Engine Games)
20+
- **Picker (Aimbot)**: Advanced targeting system with priority targeting (Players → Props)
21+
- **AWP Quit Trigger**: Shoot spawned SRCBOX props with AWP to quit the game (Only for CS:S)
22+
- **Auto-Spawner**: Automatically spawns cube at random locations on map load
23+
- **Auto-load Scripts**: Scripts automatically load on every map via `mapspawn.nut`
2324

24-
### VScript Support (Full Features)
25-
- Team Fortress 2
26-
- Counter-Strike: Source
27-
- Day of Defeat: Source
28-
- Half-Life 2: Deathmatch
29-
- Half-Life 1 Source: Deathmatch
25+
### Lua Features (Garry's Mod 10-12)
26+
- **Automatic Addon Installation**: Creates addon structure in `addons/sourcebox/lua/`
27+
- **Picker (Aimbot)**: Silent targeting system (NPCs → Players → Props)
28+
- **Auto-Spawner**: Spawns cube on map load at random locations
29+
- **Console Commands**: `picker_toggle`, `picker_next`, `sourcebox_spawn`
3030

31-
### Console Injection (Windows Only and Srcbox cube is supported only)
32-
- Any Source Games that don't have vscipts (usually it's old Source Engine so it's probably hl2.exe or something.)
31+
## Supported Games
3332

34-
> [!NOTE]
35-
> Linux will not work with console injection as this is for Windows only.
33+
### VScript Support (Full Features)
34+
| Game | VScript | Picker | AWP Quit | Auto-Spawn | Notes |
35+
|------|---------|--------|----------|------------|-------|
36+
| Team Fortress 2 ||||| AWP Quit only for CS:S |
37+
| Counter-Strike: Source |||||
38+
| Day of Defeat: Source ||||| AWP Quit only for CS:S |
39+
| Half-Life 2: Deathmatch ||||| AWP Quit only for CS:S |
40+
| Half-Life 1 Source: Deathmatch ||||| AWP Quit only for CS:S |
41+
42+
### Garry's Mod Support (Lua Bridge)
43+
| Version | Lua Bridge | Picker | Auto-Spawn | Notes |
44+
|---------|------------|--------|------------|-------|
45+
| GMod 10 |||| Sourcemod |
46+
| GMod 11 |||| Sourcemod |
47+
| GMod 12 |||| Sourcemod |
48+
| GMod 13 | 🚧 | 🚧 | 🚧 | Coming soon |
49+
| GMod 9 |||| Too primitive |
50+
51+
### Console Injection (Legacy Support - Windows Only)
52+
- Works with any Source mod without VScript support or Lua support
53+
- Only cube spawning supported
54+
- Brief window freeze during spawn
55+
- **Linux not supported**
3656

3757
## Installation
3858

3959
### Option 1: Pre-built Executable (Recommended)
4060
1. Download the latest release from [Releases](https://github.com/programmer1o1/sourcebox/releases)
4161
2. Extract the ZIP file
42-
3. Run any VScript supported games (TF2, CS:S, HL1S:DM, HL2:DM, DOD:S) before running Sourcebox program.
62+
3. **Important**: Launch your game **before** running SourceBox
4363
4. Run `SourceBox.exe` (Windows) or `./SourceBox` (Linux)
4464

4565
### Option 2: Manual Installation
46-
#### Prerequisites
4766

67+
#### Prerequisites
4868
- Python 3.7 or higher
4969
- pip package manager
50-
- A supported Source Engine game installed via Steam
70+
- A supported Source Engine game or Garry's Mod installed via Steam
5171

5272
#### Setup
5373

@@ -57,19 +77,19 @@ git clone https://github.com/programmer1o1/sourcebox.git
5777
cd sourcebox
5878
```
5979

60-
2. Create a virtual environment (for Linux users):
80+
2. Create a virtual environment (Linux):
6181
```bash
6282
python -m venv myenv
63-
6483
source myenv/bin/activate
6584
```
6685

6786
3. Install dependencies:
6887
```bash
6988
pip install -r requirements.txt
7089
```
71-
4. Run any VScript supported games (TF2, CS:S, HL1S:DM, HL2:DM, DOD:S) before running Sourcebox program.
72-
90+
91+
4. **Important**: Launch your game **before** running SourceBox
92+
7393
5. Run the application:
7494
```bash
7595
python Sourcebox.py
@@ -80,47 +100,120 @@ python Sourcebox.py
80100
### Controls
81101

82102
- **Left Click**: Interact with objects
83-
- **Cube**: Spawn the silly cube in-game
84-
- **Sphere**: Toggle error scene
85-
- **Cone**: Enter the Voidside tracker mode
86-
- **ESC**: Exit application
103+
- **Cube**: Spawn SRCBOX cube in-game
104+
- **Sphere**: Toggle error scene
105+
- **Cone**: Enter Voidside tracker mode
106+
- **ESC**: Exit application
107+
108+
### Source Engine Integration (VScript)
109+
110+
#### Automatic Setup
111+
1. Launch a supported Source game (TF2, CS:S, DOD:S, HL2:DM, HL1S:DM)
112+
2. Launch SourceBox
113+
3. Scripts automatically install to:
114+
- `game/scripts/vscripts/python_listener.nut`
115+
- `game/scripts/vscripts/picker.nut`
116+
- `game/scripts/vscripts/auto_spawner.nut`
117+
- `game/scripts/vscripts/mapspawn.nut`
118+
119+
#### In-Game Usage
120+
121+
**Spawning Props:**
122+
- Click the cube in SourceBox
123+
- Prop spawns at your crosshair
124+
- Works in single-player or local listen servers
125+
126+
**Picker Commands:**
127+
```javascript
128+
script PickerToggle() // toggle aimbot on/off
129+
script PickerNext() // manually cycle to next target
130+
```
87131

88-
### Source Engine Integration
132+
You can also set binds like these
133+
```
134+
bind mouse4 "script PickerToggle()"
135+
bind mouse5 "script PickerNext()"
136+
bind kp_plus "script PickerToggle()"
137+
```
89138

90-
#### FOR GAMES WITH VSCIRPTS
91-
1. **Automatic Setup**:
92-
- Launch Sourcebox while a supported game is running
93-
- Scripts are automatically installed to the game directory `game/scripts/vscripts/`
139+
**AWP Quit Feature:**
140+
- Shoot any spawned SRCBOX cube with AWP
141+
- Game quits immediately
142+
- Only works in CS:S
94143

95-
2. **In-Game Commands**:
144+
**Manual Script Loading** (if auto-load fails):
96145
```
97-
script PickerToggle() // toggle aimbot
98-
script PickerNext() // cycle targets
146+
sv_cheats 1
147+
script_execute python_listener
99148
```
100149

101-
You can also bind them:
150+
### Garry's Mod Integration (Lua)
151+
152+
#### Automatic Setup
153+
1. Launch GMod 10, 11, or 12 (sourcemod version)
154+
2. Launch SourceBox
155+
3. Addon automatically installs to:
156+
- `garrysmod/addons/sourcebox/lua/autorun/sourcebox_init.lua`
157+
- `garrysmod/addons/sourcebox/lua/autorun/sourcebox/sv_*.lua`
158+
4. Restart GMod game to load addon on first install
159+
160+
#### In-Game Usage
161+
162+
**Console Commands:**
102163
```
103-
bind mouse4 "script PickerToggle()"
104-
bind mouse5 "script PickerNext()"
164+
picker_toggle // toggle aimbot silently
165+
picker_next // cycle to next target
166+
sourcebox_spawn <model> [distance] // spawn any model
167+
```
168+
169+
**Examples:**
105170
```
171+
picker_toggle
172+
sourcebox_spawn props_junk/PopCan01a.mdl 300
173+
sourcebox_spawn props/srcbox/srcbox.mdl
174+
```
175+
176+
**Spawning Props:**
177+
- Click the cube in SourceBox
178+
- Prop spawns at crosshair
179+
- Props are fully visible and interactive
180+
181+
### Legacy Console Injection
106182

107-
3. **Spawning Props**:
108-
- Click the cube in Sourcebox
109-
- Prop spawns at your crosshair in-game
110-
- Shoot spawned props with AWP to quit the game (CS:S)
183+
**Requirements:**
184+
- Windows only
185+
- Running Source mod detected automatically
111186

112-
#### FOR GAMES WITH NO VSCRIPTS - WINDOWS ONLY AND ONLY CUBE SPAWNING IS SUPPORTED!
187+
**Spawning:**
188+
- Click cube in SourceBox
189+
- Console briefly opens, executes commands, closes
190+
- Window may freeze for ~200ms
191+
- Only SRCBOX cube supported
113192

114-
1. **Automatic Detection**:
115-
- Launch your Source game
116-
- Sourcebox detects it automatically (usually the file name is hl2.exe)
193+
## Troubleshooting
194+
195+
### Common Issues
196+
197+
**"No game configured" error:**
198+
- Make sure game is running **before** launching SourceBox
199+
- Check that game is installed via Steam
200+
- Try restarting Steam
201+
202+
**Scripts not loading in Source games:**
203+
- Type `sv_cheats 1` in console
204+
- Manually run: `script_execute python_listener`
205+
206+
**GMod addon not working:**
207+
- Make sure you're using GMod 10, 11, or 12 (sourcemod)
208+
- Restart GMod after first install
209+
- Check `garrysmod/addons/sourcebox/` exists
210+
- Use `lua_run include("autorun/sourcebox_init.lua")` to manually load
211+
212+
**AWP quit not working:**
213+
- Only works in CS:S
214+
- Must shoot SRCBOX cube specifically
215+
- Requires AWP weapon
117216

118-
2. **Spawning Props**:
119-
- Click the cube in Sourcebox
120-
- Console opens, executes commands, closes immediately
121-
- Window freezes briefly to hide console
122-
- Prop spawns at crosshair
123-
124217
## Development
125218

126219
### Building from Source
@@ -129,40 +222,82 @@ bind mouse5 "script PickerNext()"
129222
# install development dependencies
130223
pip install -r requirements.txt
131224

132-
# run in verbose mode for debugging
133-
python source_bridge.py # test bridge standalone
134-
```
225+
# test bridges standalone
226+
python source_bridge.py # test source engine bridge
227+
python gmod_bridge.py # test gmod bridge
135228

136-
### Compiling to Executable
137-
138-
1. Install PyInstaller:
139-
```bash
140-
pip install pyinstaller
229+
# run in verbose mode
230+
python Sourcebox.py
141231
```
142232

143-
2. Build the executable:
233+
### Compiling to Executable
144234

145235
**Windows:**
146236
```bash
147-
pyinstaller --onefile --windowed --name SourceBox --icon=assets/images/sourcebox.png --add-data "assets;assets" --exclude-module pkg_resources --exclude-module setuptools --exclude-module numpy --exclude-module pandas --exclude-module matplotlib --noupx --clean Sourcebox.py
237+
pip install pyinstaller
238+
pyinstaller --onefile --windowed --name SourceBox ^
239+
--icon=assets/images/sourcebox.png ^
240+
--add-data "assets;assets" ^
241+
--exclude-module pkg_resources ^
242+
--exclude-module setuptools ^
243+
--noupx --clean Sourcebox.py
148244
```
149245

150246
**Linux:**
151247
```bash
152-
pyinstaller --onefile --windowed --name SourceBox --icon=assets/images/sourcebox.png --add-data "assets:assets" --exclude-module pkg_resources --exclude-module setuptools --exclude-module numpy --exclude-module pandas --exclude-module matplotlib --hidden-import=OpenGL.platform.glx --hidden-import=OpenGL.arrays.vbo --collect-all OpenGL --noupx --clean Sourcebox.py
248+
pip install pyinstaller
249+
pyinstaller --onefile --windowed --name SourceBox \
250+
--icon=assets/images/sourcebox.png \
251+
--add-data "assets:assets" \
252+
--exclude-module pkg_resources \
253+
--exclude-module setuptools \
254+
--hidden-import=OpenGL.platform.glx \
255+
--hidden-import=OpenGL.arrays.vbo \
256+
--collect-all OpenGL \
257+
--noupx --clean Sourcebox.py
153258
```
154259

155-
3. The executable will be in the `dist/` folder!
260+
Output: `dist/SourceBox.exe` (Windows) or `dist/SourceBox` (Linux)
156261

157-
### Adding New Models
262+
### Adding Custom Models
158263

159-
Place `.mdl` files in your game's `models/props/` directory and reference them:
264+
**For Source Engine:**
265+
1. Place models in `game/custom/yourmod/models/props/`
266+
2. Spawn via Python:
160267
```python
161-
bridge.spawn("props/your_model/model.mdl", 200)
268+
bridge.spawn("props/yourmod/model.mdl", 200)
162269
```
163270

164-
## License
271+
**For Garry's Mod:**
272+
```python
273+
gmod_bridge.spawn_model("props/yourmod/model.mdl", 300)
274+
```
275+
276+
Or in-game console:
277+
```
278+
sourcebox_spawn props/yourmod/model.mdl 300
279+
```
280+
281+
## Technical Details
282+
283+
### VScript Communication
284+
- **Method**: File I/O via `scriptdata/` folder
285+
- **Files**: `python_command.txt`, `python_response.txt`
286+
- **Format**: JSON with session ID and command counter
287+
- **Rate**: Commands checked every 100ms
165288

166-
This project is licensed under the MIT License.
289+
### Lua Communication (GMod)
290+
- **Method**: File I/O via `data/` folder
291+
- **Files**: `sourcebox_command.txt`, `sourcebox_response.txt`
292+
- **Format**: JSON with session ID and command counter
293+
- **Rate**: Commands checked every 100ms
294+
- **Addon Path**: `addons/sourcebox/lua/autorun/`
295+
296+
### Console Injection (Legacy)
297+
- **Method**: Windows API message sending
298+
- **Process**: Freeze window → Open console → Paste command → Execute → Close console → Unfreeze
299+
- **Limitation**: Windows only, visual freeze, cube only
300+
301+
## License
167302

168-
---
303+
This project is licensed under the MIT License - see the LICENSE file for details.

0 commit comments

Comments
 (0)