Обновить Lua API
110
Lua-API.md
110
Lua-API.md
@@ -101,4 +101,112 @@ How it looks as user (you):
|
|||||||
|
|
||||||
And when admin takes screenshot:
|
And when admin takes screenshot:
|
||||||
<br/>
|
<br/>
|
||||||

|

|
||||||
|
|
||||||
|
### ``fatal.run_on_client(code: string)``
|
||||||
|
This method allows you to run the code from menuside on client
|
||||||
|
|
||||||
|
**Example**
|
||||||
|
```lua
|
||||||
|
if not MENU_DLL then
|
||||||
|
fatal.notify("Please run in menustate (click on RMB)")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
RunString("print('Hi on menu!')")
|
||||||
|
fatal.run_on_client("print('Hi on client!')")
|
||||||
|
```
|
||||||
|
|
||||||
|
### ``fatal.config_get(key: string) -> any``
|
||||||
|
### ``fatal.config_set(key: string, value: any)``
|
||||||
|
### ``fatal.menu_tab(name: string) -> number``
|
||||||
|
### ``fatal.menu_checkbox(tab: number, label: string, id: string)``
|
||||||
|
### ``fatal.menu_slider_float(tab: number, label: string, id: string, min: number, max: number)``
|
||||||
|
### ``fatal.menu_slider_int(tab: number, label: string, id: string, min: number, max: number)``
|
||||||
|
### ``fatal.menu_combo(tab: number, label: string, id: string, items: table | ...string)``
|
||||||
|
### ``fatal.menu_color(tab: number, label: string, id: string) ``
|
||||||
|
### ``fatal.menu_button(tab: number, label: string, id: string)``
|
||||||
|
### ``fatal.menu_text(tab: number, label: string, id: string, default_value: string = "")``
|
||||||
|
### ``fatal.menu_label(tab: number, text: string, id: string = "")``
|
||||||
|
### ``fatal.menu_separator(tab: number)``
|
||||||
|
### ``fatal.notify(message: string)``
|
||||||
|
|
||||||
|
**Example**
|
||||||
|
```lua
|
||||||
|
-- Making a tab "My Script"
|
||||||
|
local tab = fatal.menu_tab("My Script")
|
||||||
|
|
||||||
|
-- Add some elements
|
||||||
|
fatal.menu_separator(tab)
|
||||||
|
fatal.menu_checkbox(tab, "Enable aimbot", "enable_aimbot")
|
||||||
|
fatal.menu_checkbox(tab, "Silent aim", "silent_aim")
|
||||||
|
fatal.menu_slider_float(tab, "FOV", "aim_fov", 0, 180)
|
||||||
|
fatal.menu_slider_float(tab, "Smooth", "aim_smooth", 0, 30)
|
||||||
|
fatal.menu_slider_int(tab, "Backtrack ticks", "bt_ticks", 0, 12)
|
||||||
|
fatal.menu_combo(tab, "Target selection", "target_mode", {
|
||||||
|
"Crosshair",
|
||||||
|
"Distance",
|
||||||
|
"Lowest Health",
|
||||||
|
"FOV"
|
||||||
|
})
|
||||||
|
-- Also can be used but not recommended
|
||||||
|
-- fatal.menu_combo(tab, "Target selection", "target_mode", "Crosshair", "Distance", "Lowest Health", "FOV")
|
||||||
|
fatal.menu_color(tab, "ESP Color", "esp_color")
|
||||||
|
fatal.menu_separator(tab)
|
||||||
|
fatal.menu_label(tab, "This is just a text")
|
||||||
|
fatal.menu_text(tab, "Custom Message", "custom_msg", "Hello World")
|
||||||
|
fatal.menu_button(tab, "Print message", "btn_print")
|
||||||
|
fatal.menu_button(tab, "Reset config", "btn_reset")
|
||||||
|
|
||||||
|
-- Load saved fields
|
||||||
|
local saved_fov = fatal.config_get("aim_fov")
|
||||||
|
if saved_fov then
|
||||||
|
-- field is loaded from config
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Main cycle - reading values
|
||||||
|
hook.Add("Think", "my_script_loop", function()
|
||||||
|
local enabled = fatal.config_get("enable_aimbot")
|
||||||
|
if not enabled then return end
|
||||||
|
|
||||||
|
local fov = fatal.config_get("aim_fov") or 0
|
||||||
|
local smooth = fatal.config_get("aim_smooth") or 0
|
||||||
|
local ticks = fatal.config_get("bt_ticks") or 0
|
||||||
|
|
||||||
|
-- Saving config values
|
||||||
|
fatal.config_set("aim_fov", fov)
|
||||||
|
fatal.config_set("aim_smooth", smooth)
|
||||||
|
fatal.config_set("bt_ticks", ticks)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Handler for button "Print message"
|
||||||
|
hook.Add("Think", "btn_print_handler", function()
|
||||||
|
if fatal.config_get("btn_print") then -- Guarantee that button click will be handled once
|
||||||
|
local msg = fatal.config_get("custom_msg") or "no message"
|
||||||
|
print(msg)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Handler for button "Reset config"
|
||||||
|
hook.Add("Think", "btn_reset_handler", function()
|
||||||
|
if fatal.config_get("btn_reset") then
|
||||||
|
fatal.config_set("enable_aimbot", false)
|
||||||
|
fatal.config_set("silent_aim", false)
|
||||||
|
fatal.config_set("aim_fov", 0)
|
||||||
|
fatal.config_set("aim_smooth", 0)
|
||||||
|
fatal.config_set("bt_ticks", 0)
|
||||||
|
fatal.config_set("custom_msg", "")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Notification on load
|
||||||
|
fatal.notify("My Script loaded successfully!")
|
||||||
|
|
||||||
|
-- Creating some tabs (to test scroll with mouse wheel)
|
||||||
|
tab = fatal.menu_tab("My Script 1")
|
||||||
|
tab = fatal.menu_tab("My Script 2")
|
||||||
|
tab = fatal.menu_tab("My Script 3")
|
||||||
|
```
|
||||||
|
|
||||||
|
How it looks in game:
|
||||||
|
<br/>
|
||||||
|

|
||||||
Reference in New Issue
Block a user