Skip to content

Commit c4ee034

Browse files
committed
Unfinished mkdocs support
1 parent c9209d1 commit c4ee034

File tree

371 files changed

+25047
-34
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

371 files changed

+25047
-34
lines changed

build/gitbook/development/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# development
1+
# Development
22

33
To get started with lua scripting, you'll need a suitable text editor. We suggest [VS Code](https://code.visualstudio.com/) or [Sublime Text](https://www.sublimetext.com/), but in theory [Notepad++](https://notepad-plus-plus.org/download/) or even the built-in Microsoft Notepad will probably work just fine. After choosing an editor, head over to
44

build/gitbook/development/examples/auto_buy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Talk shit
1+
# Auto buy
22

33
This script adds an "Auto buy AWP" checkbox to the misc tab, useful for spread HvH when AWP purchases are limited.
44

build/mkdocs/docs/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Overview
2+
3+
This website documents the configuration options, usage and LUA API of [gamesense.pub](https://gamesense.pub).
4+
5+
The first category is targeted at end users that aren't interested in learning the gamesense LUA API. The other categories are meant for new and experienced developers and the majority of users shouldn't have to care about them.

build/mkdocs/docs/SUMMARY.md

Lines changed: 329 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# development
2+
3+
To get started with lua scripting, you'll need a suitable text editor. We suggest [VS Code](https://code.visualstudio.com/) or [Sublime Text](https://www.sublimetext.com/), but in theory [Notepad++](https://notepad-plus-plus.org/download/) or even the built-in Microsoft Notepad will probably work just fine. After choosing an editor, head over to
4+
5+
If you're unfamiliar with the Lua programming language, [Lua in 5 minutes](https://learnxinyminutes.com/docs/lua/) is a great guide to get started.
6+
7+
## Things to keep in mind:
8+
9+
- By default, all loaded lua scripts share the same environment. This means that if 2 scripts use a global variable with the same name, they will conflict with each other and cause all kinds of issues. To prevent this, always remember to make your variables, functions, etc **local**
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Compiling lua scripts
2+
3+
**Compiling scripts can give a slight performance boost, although you should be fine without it.**
4+
5+
{% hint style="success" %}
6+
[**Download from MEGA**](https://mega.nz/#!JpFAhYjb!35AbAx8sGdmVAI3o-EVHtGA_-Y1WqReo7WWUWHOdYo4)
7+
{% endhint %}
8+
9+
1. Download the archive and extract it anywhere
10+
2. Copy the script you want to compile into the extracted folder
11+
3. Open command prompt, navigate to that folder
12+
13+
After you successfully extracted it, type the following command:
14+
15+
{% code-tabs %}
16+
{% code-tabs-item title="compile.cmd" %}
17+
```text
18+
luajit.exe -b script.lua compiled.ljbc
19+
```
20+
{% endcode-tabs-item %}
21+
{% endcode-tabs %}
22+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Editors
2+
3+
Your editor setup is very important to avoid common issues and be productive. The editors mentioned here are very extensible and can be improved a lot to make lua scripting more enjoyable, people have even made extensions for them just for the gamesense API.
4+
5+
This section shows how to best configure your editor for writing scripts for gamesense lua scripting
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# GameSense API Snippets
2+
*Credits to Nexxed*
3+
4+
1. Open Atom and go to "File" -> "Snippets..." to open the snippets.cson file.
5+
2. [Download](https://gamesense.pub/forums/viewtopic.php?id=12394) and/or paste the contents of the Atom snippets into the snippets.cson file.
6+
3. Save the file and restart Atom for the changes to take effect.
7+
8+
Note: This requires you to install the [language-lua](https://atom.io/packages/language-lua) package for the editor.
9+
10+
These snippets have descriptions (VSCode & Atom only) for most API functions as well as arguments and are currently up-to-date with the current API.
11+
12+
Thread: https://gamesense.pub/forums/viewtopic.php?id=12394
13+
14+
# Suggested extensions
15+
16+
- [language-lua](https://atom.io/packages/language-lua)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# GameSense API Snippets
2+
*Credits to Nexxed*
3+
4+
1. Open Sublime and go to "Preferences" -> "Browse Packages" while in the editor.
5+
2. [Download](https://gamesense.pub/forums/viewtopic.php?id=12394), rename and drag the gamesense.sublime-completions file into the packages folder.
6+
3. Profit!
7+
8+
These snippets have descriptions (VSCode & Atom only) for most API functions as well as arguments and are currently up-to-date with the current API.
9+
10+
Thread: https://gamesense.pub/forums/viewtopic.php?id=12394
11+
12+
# Suggested extensions
13+
14+
- [LuaExtended](https://packagecontrol.io/packages/LuaExtended)
15+
- [SublimeLinter](https://packagecontrol.io/packages/SublimeLinter)
16+
- [SublimeLinter-luacheck](https://packagecontrol.io/packages/SublimeLinter-luacheck)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# GameSense API Snippets
2+
*Credits to Nexxed*
3+
4+
1. Go to the [VSCode Marketplace page of the GameSense Lua API Snippets](https://marketplace.visualstudio.com/items?itemName=Nexxed.gamesense-lua) and click the green install button.
5+
2. Follow the instructions.
6+
3. Profit!
7+
8+
These snippets have descriptions (VSCode & Atom only) for most API functions as well as arguments and are currently up-to-date with the current API.
9+
10+
Thread: https://gamesense.pub/forums/viewtopic.php?id=12394
11+
12+
# Suggested extensions
13+
14+
- [LuaExtended](https://packagecontrol.io/packages/LuaExtended)
15+
- [SublimeLinter](https://packagecontrol.io/packages/SublimeLinter)
16+
- [SublimeLinter-luacheck](https://packagecontrol.io/packages/SublimeLinter-luacheck)
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
---
2+
description: List of events that you can listen to using client.set_event_callback
3+
---
4+
# Events
5+
6+
### List of events:
7+
8+
#### paint
9+
10+
Fired every time the game renders a frame while being connected to a server. Can be used to draw to the screen using the renderer.* functions
11+
12+
13+
{% page-ref page="/developers/globals/renderer" %}
14+
15+
16+
#### run_command
17+
18+
Fired every time the game runs a command (usually 64 times a second, equal to tickrate) while you're alive. This is the best event for processing data that only changes when the game receives an update from the server, like information about other players.
19+
20+
Key | Description
21+
--- | -----------
22+
**chokedcommands** | Amount of commands that the client has choked
23+
**command_number** | Current command number
24+
25+
26+
27+
#### setup_command
28+
29+
Fired every time the game prepares a move command that's sent to the server. This is ran before cheat features like antiaim and can be used to modify user input (view angles, pressed keys, movement) how it's seen by the cheat. For example, setting `in_use = 1` will disable antiaim the same way pressing use key ingame does. This is the preferred method of setting user input and should be used instead of `client.exec` whenever possible
30+
31+
Key | Description
32+
--- | -----------
33+
**chokedcommands** | Amount of commands that the client has choked
34+
**command_number** | Current command number
35+
**pitch** | Pitch view angle
36+
**yaw** | Yaw view angle
37+
**forwardmove** | Forward / backward speed (-450 to 450)
38+
**sidemove** | Left / right speed (-450 to 450)
39+
**move_yaw** | Yaw angle that's used for movement. If not set, view yaw is used
40+
**allow_send_packet** | Set to false to make the cheat choke the current command (when possible)
41+
**in_attack** | IN_ATTACK Button
42+
**in_jump** | IN_JUMP Button
43+
**in_duck** | IN_DUCK Button
44+
**in_forward** | IN_FORWARD Button
45+
**in_back** | IN_BACK Button
46+
**in_use** | IN_USE Button
47+
**in_cancel** | IN_CANCEL Button
48+
**in_left** | IN_LEFT Button
49+
**in_right** | IN_RIGHT Button
50+
**in_moveleft** | IN_MOVELEFT Button
51+
**in_moveright** | IN_MOVERIGHT Button
52+
**in_attack2** | IN_ATTACK2 Button
53+
**in_run** | IN_RUN Button
54+
**in_reload** | IN_RELOAD Button
55+
**in_alt1** | IN_ALT1 Button
56+
**in_alt2** | IN_ALT2 Button
57+
**in_score** | IN_SCORE Button
58+
**in_speed** | IN_SPEED Button
59+
**in_walk** | IN_WALK Button
60+
**in_zoom** | IN_ZOOM Button
61+
**in_weapon1** | IN_WEAPON1 Button
62+
**in_weapon2** | IN_WEAPON2 Button
63+
**in_bullrush** | IN_BULLRUSH Button
64+
**in_grenade1** | IN_GRENADE1 Button
65+
**in_grenade2** | IN_GRENADE2 Button
66+
**in_attack3** | IN_ATTACK3 Button
67+
**weaponselect** |
68+
**weaponsubtype** |
69+
70+
71+
72+
#### console_input
73+
74+
Fired every time the user types something in the game console and presses enter. Return false from the event handler to make the game not process the input
75+
76+
|| Property
77+
------ | --------
78+
1 | console input text
79+
80+
81+
**Examples:**
82+
83+
{% code-tabs %}
84+
{% code-tabs-item %}
85+
```lua
86+
client.set_event_callback("console_input", function(text)
87+
client.log("entered: '", text, "'")
88+
end)
89+
```
90+
{% endcode-tabs-item %}
91+
{% endcode-tabs %}
92+
93+
#### net_update_start
94+
95+
Fired before the game processes entity updates from the server. (`FrameStageNotify FRAME_NET_UPDATE_START`) Be careful when using this event to modify entity data, some things have to be restored manually as not even a full update will update them
96+
97+
98+
99+
#### net_update_end
100+
101+
Fired after an entity update packet is received from the server. (`FrameStageNotify FRAME_NET_UPDATE_END`)
102+
103+
104+
105+
#### predict_command
106+
107+
Fired when the game prediction is ran
108+
109+
Key | Description
110+
--- | -----------
111+
**command_number** | Command number of the predicted command
112+
113+
114+
115+
#### aim_fire
116+
117+
Fired when the rage aimbot shoots at a player
118+
119+
Key | Description
120+
--- | -----------
121+
**id** | Shot ID, this can be used to find the corresponding aim_hit / aim_miss event
122+
**target** | Target player entindex
123+
**hit_chance** | Chance the shot will hit, depends on spread
124+
**hitgroup** | Targeted hit group, this is not the same thing as a hitbox
125+
**damage** | Predicted damage the shot will do
126+
**backtrack** | Amount of ticks the player was backtracked
127+
**boosted** | True if accuracy boost was used to increase the accuracy of the shot
128+
**high_priority** | True if the shot was at a high priority record, like on shot backtrack
129+
**interpolated** | Player was interpolated
130+
**extrapolated** | Player was extrapolated
131+
**teleported** | Target player was teleporting (breaking lag compensation)
132+
**tick** | Tick the shot was fired at. This can be used to draw the hitboxes using client.draw_hitboxes
133+
**x** | X world coordinate of the aim point
134+
**y** | X world coordinate of the aim point
135+
**z** | Z world coordinate of the aim point
136+
137+
138+
**Examples:**
139+
140+
{% code-tabs %}
141+
{% code-tabs-item %}
142+
```lua
143+
local function time_to_ticks(t)
144+
return floor(0.5 + (t / globals.tickinterval()))
145+
end
146+
147+
local hitgroup_names = {'generic', 'head', 'chest', 'stomach', 'left arm', 'right arm', 'left leg', 'right leg', 'neck', '?', 'gear'}
148+
149+
local function aim_fire(e)
150+
local flags = {
151+
e.teleported and 'T' or '',
152+
e.interpolated and 'I' or '',
153+
e.extrapolated and 'E' or '',
154+
e.boosted and 'B' or '',
155+
e.high_priority and 'H' or ''
156+
}
157+
local group = hitgroup_names[e.hitgroup + 1] or '?'
158+
print(string.format('Fired at %s (%s) for %d dmg (chance=%d%%, bt=%2d, flags=%s)', entity.get_player_name(e.target), group, e.damage, math.floor(e.hit_chance + 0.5), time_to_ticks(e.backtrack), table.concat(flags)))
159+
end
160+
client.set_event_callback('aim_fire', aim_fire)
161+
```
162+
{% endcode-tabs-item %}
163+
{% endcode-tabs %}
164+
165+
#### aim_hit
166+
167+
Fired when the rage aimbot hit a shot at a player
168+
169+
Key | Description
170+
--- | -----------
171+
**id** | Shot ID, the corresponding aim_fire event has the same ID
172+
**target** | Target player entindex
173+
**hit_chance** | Actual hit chance the shot had
174+
**hitgroup** | Hit group that was hit. This is not the same thing as a hitbox
175+
**damage** | Actual damage the shot did
176+
177+
178+
**Examples:**
179+
180+
{% code-tabs %}
181+
{% code-tabs-item %}
182+
```lua
183+
local hitgroup_names = {'generic', 'head', 'chest', 'stomach', 'left arm', 'right arm', 'left leg', 'right leg', 'neck', '?', 'gear'}
184+
185+
local function aim_hit(e)
186+
local group = hitgroup_names[e.hitgroup + 1] or '?'
187+
print(string.format('Hit %s in the %s for %d damage (%d health remaining)', entity.get_player_name(e.target), group, e.damage, entity.get_prop(e.target, 'm_iHealth')))
188+
end
189+
client.set_event_callback('aim_hit', aim_hit)
190+
```
191+
{% endcode-tabs-item %}
192+
{% endcode-tabs %}
193+
194+
#### aim_miss
195+
196+
Fired when the rage aimbot missed a shot at a player
197+
198+
Key | Description
199+
--- | -----------
200+
**id** | Shot ID, the corresponding aim_fire event has the same ID
201+
**target** | Target player entindex
202+
**hit_chance** | Actual hit chance the shot had
203+
**hitgroup** | Hit group that was missed. This is not the same thing as a hitbox
204+
**reason** | Reason the shot was missed. This can be 'spread', 'prediction error', 'death' or '?' (unknown / resolver)
205+
206+
207+
**Examples:**
208+
209+
{% code-tabs %}
210+
{% code-tabs-item %}
211+
```lua
212+
local hitgroup_names = {'generic', 'head', 'chest', 'stomach', 'left arm', 'right arm', 'left leg', 'right leg', 'neck', '?', 'gear'}
213+
214+
local function aim_miss(e)
215+
local group = hitgroup_names[e.hitgroup + 1] or '?'
216+
print(string.format('Missed %s (%s) due to %s', entity.get_player_name(e.target), group, e.reason))
217+
end
218+
client.set_event_callback('aim_miss', aim_miss)
219+
```
220+
{% endcode-tabs-item %}
221+
{% endcode-tabs %}
222+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Examples
2+
3+
These example show how to use certain parts of the gamesense API and highlight best practices.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Talk shit
2+
3+
This script adds an "Auto buy AWP" checkbox to the misc tab, useful for spread HvH when AWP purchases are limited.
4+
5+
```lua
6+
local ui_get, console_cmd = ui.get, client.exec
7+
8+
local auto_buy_awp = ui.new_checkbox("MISC", "Miscellaneous", "Auto buy AWP")
9+
10+
local function on_round_prestart(e)
11+
if ui_get(auto_buy_awp) then
12+
console_cmd("buy awp;")
13+
end
14+
end
15+
client.set_event_callback("round_prestart", on_round_prestart)
16+
```
17+
18+
Originally written by admin
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Create interface
2+
3+
This script is an example for "client.create_interface".
4+
With this function you can access classes or functions provided by the game itself.
5+
6+
{% code-tabs %}
7+
{% code-tabs-item title="create_interface.lua" %}
8+
```lua
9+
local ffi = require 'ffi'
10+
11+
ffi.cdef[[
12+
typedef unsigned char wchar_t;
13+
14+
typedef bool (__thiscall *IsButtonDown_t)(void*, int);
15+
]]
16+
local interface_ptr = ffi.typeof('void***')
17+
18+
local raw_inputsystem = client.create_interface('inputsystem.dll', 'InputSystemVersion001')
19+
20+
-- cast the lightuserdata to a type that we can dereference
21+
local inputsystem = ffi.cast(interface_ptr, raw_inputsystem) -- void***
22+
23+
-- dereference the interface pointer to get its vtable
24+
local inputsystem_vtbl = inputsystem[0] -- void**
25+
26+
-- vtable is an array of functions, the 15th is IsButtonDown
27+
local raw_IsButtonDown = inputsystem_vtbl[15] -- void*
28+
29+
-- cast the function pointer to a callable type
30+
local is_button_pressed = ffi.cast('IsButtonDown_t', raw_IsButtonDown)
31+
32+
local function run_command(cmd)
33+
if is_button_pressed(inputsystem, 36) then -- ButtonCode_t for Z
34+
print('Z is pressed')
35+
end
36+
return false
37+
end
38+
39+
client.set_event_callback('run_command', run_command)
40+
```
41+
{% endcode-tabs-item %}
42+
{% endcode-tabs %}
43+
44+
Originally written by admin

0 commit comments

Comments
 (0)