### CLEO Script Example Source: https://wiki.blast.hk/gta-sa/opcodes/0C2E A practical example of Opcode 0C2E usage within a CLEO script. ```APIDOC ## CLEO Script Example ``` {$CLEO} wait 0 0AC8: 0@ = allocate_memory_size 128 0AD3: 0@ = format "gy test2pg п1" 0C2E: 1@ = strspn string1 0@ string2 "tepg ts12" 0B78: log "strspn > i %d" 1@ 0AC9: free_allocated_memory 0@ 0A93: end_custom_thread ``` ``` -------------------------------- ### Specific New Opcode Examples (3.1) Source: https://wiki.blast.hk/sampfuncs/changelog Examples of newly added opcodes in version 3.1. ```APIDOC ## Specific New Opcode Examples (3.1) ### Opcode Usage Examples: * **0B76:** `samp set_chat_input_text 1@` - Sets the text in the chat input field. * **0B77:** `samp get_chat_input_text_to 1@` - Gets the text from the chat input field. * **0B78:** `log "SAMPFUNCS"` - Logs the string "SAMPFUNCS" to the console. * **0B79:** `samp set_chat_input_enabled 1@` - Enables or disables the chat input field. * **0BA5:** `dialog 1@ set_focus_on_control 2@` - Sets focus on a specific control within a dialog. * **0BA6:** `dialog 1@ set_control 2@ size_XY 3@ 4@` - Sets the size of a control within a dialog. * **0BA7:** `dialog 1@ get_control 2@ size_to 3@ 4@` - Gets the size of a control within a dialog. * **0BA8:** `dialog 1@ set_control 2@ pos_XY 3@ 4@` - Sets the position of a control within a dialog. * **0BA9:** `dialog 1@ get_control 2@ pos_to 3@ 4@` - Gets the position of a control within a dialog. * **0BAA:** `dialog 1@ set_checkbox 2@ color 3@` - Sets the color of a checkbox in a dialog. * **0BAB:** `dialog 1@ is_exists` - Checks if a dialog exists. * **0C1D:** `4@ = array 1@ element 2@ el_size 3@` - Gets an element from an array. * **0C1E:** `array 1@ element 2@ el_size 3@ = 4@` - Sets an element in an array. * **0C1F:** `4@ = string_array 1@ element 2@ size 3@` - Gets a string element from a string array. * **0C20:** `string_array 1@ element 2@ size 3@ = 4@` - Sets a string element in a string array. ``` -------------------------------- ### GET /opcodes/0BE2 Source: https://wiki.blast.hk/ru/gta-sa/opcodes/0BE2 Documentation for the 0BE2 opcode used to setup an outgoing packet hook. ```APIDOC ## GET /opcodes/0BE2 ### Description Redirects outgoing network packets to a specified callback (label) for custom processing before they are sent to the server. ### Method OPCODE ### Endpoint 0BE2 ### Parameters #### Path Parameters - **@label** (label) - Required - The memory label representing the hook body to execute when a packet is intercepted. ### Request Example ``` 0BE2: raknet setup_outcoming_packet_hook @label ``` ### Response #### Success Response (N/A) - **Status** (void) - The opcode registers the hook globally within the SAMPFUNCS environment. #### Sanny Builder Definition ``` 0BE2=1,raknet setup_outcoming_packet_hook %1d% ``` ``` -------------------------------- ### Example Usage of taskPlayAnim (Lua) Source: https://wiki.blast.hk/ru/moonloader/lua/taskPlayAnim Demonstrates how to use the taskPlayAnim function within a Moonloader script. The example plays the 'WF_FWD' animation from the 'WAYFARER' IFP file when the 'X' key is pressed. ```lua require 'moonloader' function main() while true do wait(0) if isKeyJustPressed(VK_X) then taskPlayAnim(PLAYER_PED, "WF_FWD", "WAYFARER", 9, false, false, false, false, -1) end end end ``` -------------------------------- ### Example of Main Function Usage (Lua) Source: https://wiki.blast.hk/moonloader/lua/main An example demonstrating the `main` function in Moonloader. It includes loading assets, an infinite `while` loop with a mandatory `wait(0)` to prevent game freezing, player status checks, key press detection, and calling other functions like `loadStuff()`, `print()`, `isPlayerPlaying()`, `isKeyDown()`, and `doCoolStuff()`. ```lua function main() -- загрузим что-нибудь перед тем, как запустить бесконечный цикл loadStuff() key1_timesPressed = 0 -- бесконечный цикл - в данном примере именно в нём реализована основная часть скрипта while true do -- в нём обязательно должна присутствовать хотя-бы нулевая задержка, иначе игра попросту зависнет -- объясняется это тем, что весь процесс игры выполняется последовательно, в том числе и скрипты MoonLoader-а -- и поэтому периодически игре нужно давать возможность обработаться, делая паузу в каждом бесконечном цикле любого скрипта -- нулевая задержка приостановит выполнение скрипта ровно на один кадр (задержка в main не оказывает влияния на выполнение остальных событий) wait(0) if isPlayerPlaying(playerHandle) then if isKeyDown(0x31) then key1_timesPressed = key1_timesPressed + 1 print("Key 1 pressed " .. key1_timesPressed .. " times.") wait(500) end doCoolStuff() end end end ``` -------------------------------- ### Opcode 0C18 Example with CLEO Script Source: https://wiki.blast.hk/gta-sa/opcodes/0C18 An example showcasing Opcode 0C18 within a CLEO script. This snippet demonstrates memory allocation, string formatting, performing the substring search, logging the result, and freeing memory. ```CLEO Script {$CLEO} wait 0 0AC8: 0@ = allocate_memory_size 128 0AD3: 0@ = format "А ты уверен? =)" 0C18: 1@ = strstr string1 0@ string2 "ты" 0B78: log "strstr -> %s" 1@ 0AC9: free_allocated_memory 0@ 0A93: end_custom_thread ``` -------------------------------- ### Create a basic MoonLoader script Source: https://wiki.blast.hk/moonloader A minimal example demonstrating the script registration and the main entry point function required by the MoonLoader framework. ```lua script_name("Example") function main() print("Hello, world!") end ``` -------------------------------- ### CLEO Script Example for Opcode 0C2B Source: https://wiki.blast.hk/ru/gta-sa/opcodes/0C2B A complete CLEO script demonstrating how to allocate memory, format a string, use opcode 0C2B to locate a character, and log the result. ```CLEO {$CLEO} wait 0 0AC8: 0@ = allocate_memory_size 24 0AD3: 0@ = format "qwert bb zz" 0C2B: 1@ = strpbrk string 0@ control "z" 0B78: log "strpbrk(%s) -> %s" 0@ 1@ 0AC9: free_allocated_memory 0@ 0A93: end_custom_thread ``` -------------------------------- ### CLEO Script Example for Opcode 0C18 Source: https://wiki.blast.hk/ru/gta-sa/opcodes/0C18 A complete CLEO script demonstrating how to allocate memory, format a string, use opcode 0C18 to find a substring, and log the result. ```CLEO {$CLEO} wait 0 0AC8: 0@ = allocate_memory_size 128 0AD3: 0@ = format "А ты уверен? =)" 0C18: 1@ = strstr string1 0@ string2 "ты" 0B78: log "strstr -> %s" 1@ 0AC9: free_allocated_memory 0@ 0A93: end_custom_thread ``` -------------------------------- ### taskPlayAnim Function Documentation Source: https://wiki.blast.hk/moonloader/lua/taskPlayAnim Details on the taskPlayAnim function, its arguments, and an example of its usage. ```APIDOC ## taskPlayAnim ### Description Causes an actor to play or stop an animation. ### Method `taskPlayAnim(Ped ped, string animation, string IFP, float framedelta, bool loop, bool lockX, bool lockY, bool lockF, int time)` ### Parameters #### Arguments - **ped** (Ped) - Handle of the character. - **animation** (string) - Name of the animation. - **IFP** (string) - Animation file. - **framedelta** (float) - Animation speed. - **loop** (bool) - Animation looping (true - yes, false - no). - **lockX** (bool) - Lock X position (true - yes, false - no). - **lockY** (bool) - Lock Y position (true - yes, false - no). - **lockF** (bool) - Return to original position (true - return, false - do not return). - **time** (int) - Playback time. ### Request Example ```lua require 'moonloader' function main() while true do wait(0) if isKeyJustPressed(VK_X) then taskPlayAnim(PLAYER_PED, "WF_FWD", "WAYFARER", 9, false, false, false, false, -1) end end end ``` ### Response This function does not return a value, but controls character animations. ``` -------------------------------- ### onD3DDeviceLost Event Usage Example (Lua) Source: https://wiki.blast.hk/ru/moonloader/lua/onD3DDeviceLost An example demonstrating how to use the onD3DDeviceLost event in Lua within the Moonloader environment. It shows the typical pattern of calling OnLostDevice on a d3dxfont object to handle resource invalidation before the device reset. ```lua -- ... function onD3DDeviceLost() d3dxfont.vtbl.OnLostDevice(d3dxfont) end -- ... ``` -------------------------------- ### Start Car Fire Function Example (Lua) Source: https://wiki.blast.hk/ru/moonloader/lua/startCarFire Demonstrates how to use the startCarFire function in Lua for Moonloader. This function takes a vehicle handle as input and causes the vehicle to ignite. It's often used within game modding contexts like SAMP. ```lua function main() while not isSampAvailable() do wait(100) end sampRegisterChatCommand("fire", function() if isCharInAnyCar(playerPed) then startCarFire(storeCarCharIsInNoSave(playerPed)) end end) wait(-1) end ``` -------------------------------- ### Get Cursor Mode (Sanny Builder) Source: https://wiki.blast.hk/ru/gta-sa/opcodes/0B8E Example of using the 0B8E opcode in Sanny Builder to get the cursor mode and store it in a variable. ```sannybuilder 0B8E=1,samp %1d% = get_cursor_mode ``` -------------------------------- ### Get Car Health Opcode 0227 - Scripting Example Source: https://wiki.blast.hk/ru/gta-sa/opcodes/0227 This snippet shows a basic scripting example for opcode 0227, which is used to get the health of a car in GTA San Andreas. The opcode takes a car handle (0@) and assigns the car's health (0-1000) to a variable (1@). ```text 0227: 1@ = car 0@ health ``` -------------------------------- ### Connect to Server using Opcode 0B38 Source: https://wiki.blast.hk/gta-sa/opcodes/0b38 This snippet demonstrates how to initiate a connection to a SAMP server using a specified IP address and port. It requires the SAMPFUNCS library and is typically used within Sanny Builder scripts. ```Sanny Builder 0B38: samp connect_to_server "127.0.0.1" port 7777 ``` ```Sanny Builder Definition 0B38=2,samp connect_to_server %1s% port %2d% ``` -------------------------------- ### Get Textdraw Position using sampTextdrawGetPos Source: https://wiki.blast.hk/moonloader/lua/sampTextdrawGetPos Retrieves the X and Y coordinates of a specific textdraw identified by its ID. Requires the SAMPFUNCS library to be installed and active. ```lua float posX, float posY = sampTextdrawGetPos(int id) ``` -------------------------------- ### Get Download Status Opcode (Sanny Builder) Source: https://wiki.blast.hk/gta-sa/opcodes/0C66 Sanny Builder implementation for Opcode 0C66, used to get the status of a download. It takes the download ID as input and returns the download status. ```sannybuilder 0C66=2,%2d% = get_download %1d% state ``` -------------------------------- ### Get textdraw alignment using sampTextdrawGetAlign Source: https://wiki.blast.hk/moonloader/lua/sampTextdrawGetAlign Retrieves the alignment type of a specified SA-MP textdraw. Requires SAMPFUNCS to be installed and uses opcode 0C54. ```lua int align = sampTextdrawGetAlign(int id) ``` -------------------------------- ### Format string using Opcode 0AD3 Source: https://wiki.blast.hk/ru/gta-sa/opcodes/0AD3 Demonstrates how to use opcode 0AD3 to format a string with variables. It requires a pointer to pre-allocated memory, a format string, and the corresponding variables. ```CLEO 0AD3: 0@ = format "number %d text %s" 1@ 2@ ``` ```Sanny Builder 0AD3=-1,%1d% = format %2s% ``` -------------------------------- ### Opcode 0C19 Example Script in Sanny Builder Source: https://wiki.blast.hk/gta-sa/opcodes/0C19 A practical example script using opcode 0C19 within a CLEO thread. It allocates memory, formats a string, performs the search, logs the result, and frees memory. ```cleo {$CLEO} wait 0 0AC8: 0@ = allocate_memory_size 128 0AD3: 0@ = format "qwerty zxcv asdf" 0C19: 1@ = strcspn string1 0@ string2 "zrua" 0B78: log "strcspn -> %d" 1@ 0AC9: free_allocated_memory 0@ 0A93: end_custom_thread ``` -------------------------------- ### Copy Directory Opcode Usage Source: https://wiki.blast.hk/gta-sa/opcodes/0B05 Demonstrates the implementation of opcode 0B05 to copy a source directory to a destination directory. Requires the FileSystemOperations library to be installed. ```Sanny Builder 0B05: copy_directory "CLEO\dir1" to "CLEO\dir2" ``` ```Sanny Builder 0B05=2,copy_directory %1d% to %2d% ;; IF and SET ``` -------------------------------- ### Usage and Implementation of Opcode 0C2E Source: https://wiki.blast.hk/gta-sa/opcodes/0C2E Demonstrates the syntax for calling opcode 0C2E, its definition in Sanny Builder, and a complete CLEO script example. The opcode takes a string pointer and a character set string as input, returning the index of the first non-matching character. ```Sanny Builder 0C2E: 2@ = strspn string1 0@ string2 "abr cad ф" ``` ```Sanny Builder 0C2E=3,%3d% = strspn string1 %1d% string2 %2d% ``` ```CLEO {$CLEO} wait 0 0AC8: 0@ = allocate_memory_size 128 0AD3: 0@ = format "gy test2pg п1" 0C2E: 1@ = strspn string1 0@ string2 "tepg ts12" 0B78: log "strspn > i %d" 1@ 0AC9: free_allocated_memory 0@ 0A93: end_custom_thread ``` -------------------------------- ### Get player armor using sampGetPlayerArmor Source: https://wiki.blast.hk/moonloader/lua/sampGetPlayerArmor Retrieves the current armor level of a player identified by their ID. This function requires the SAMPFUNCS plugin to be installed and active. ```lua int armor = sampGetPlayerArmor(int id) ``` -------------------------------- ### Get Car Door Lock Status Example (Lua) Source: https://wiki.blast.hk/ru/moonloader/lua/getCarDoorLockStatus This Lua example demonstrates how to use the getCarDoorLockStatus function within a Moonloader script. It registers a chat command to check a car's door status by its ID, retrieving the vehicle handle and then calling the function to report if the car is open or closed. ```lua function main() repeat wait(0) until isSampAvailable() -- ждем доступность SA-MP sampRegisterChatCommand("check", function(arg) -- регистрируем команду, которая принимает id автомобиля (/check id) if tonumber(arg) then -- если аргумент - число, то local result, handle = sampGetCarHandleBySampVehicleId(tonumber(arg)) -- получаем хэндл кара if result then -- если машина существует, то local doorStatus = getCarDoorLockStatus(handle) -- получаем состояние двери (0 - открыта, 1 - закрыта) sampAddChatMessage("Машина "..(doorStatus == 0 and "открыта!" or "закрыта!"), -1) end end end) wait(-1) -- не даем скрипту завершиться end ``` -------------------------------- ### POST /moonloader/lua/allocateMemory Source: https://wiki.blast.hk/t/function/lua/moonloader Allocates a block of memory and returns a pointer. ```APIDOC ## POST /moonloader/lua/allocateMemory ### Description Allocates memory in the process space and returns the memory address. ### Method POST ### Endpoint /moonloader/lua/allocateMemory ### Request Body - **size** (int) - Required - Number of bytes to allocate. ### Response #### Success Response (200) - **pointer** (int) - The memory address of the allocated block. ``` -------------------------------- ### Sanny Builder Usage Source: https://wiki.blast.hk/gta-sa/opcodes/0C2E Example of how to use Opcode 0C2E within the Sanny Builder environment. ```APIDOC ## Sanny Builder Example ``` 0C2E=3,%3d% = strspn string1 %1d% string2 %2d% ``` ``` -------------------------------- ### Get textdraw outline parameters using sampTextdrawGetOutlineColor Source: https://wiki.blast.hk/moonloader/lua/sampTextdrawGetOutlineColor Retrieves the outline thickness and color for a given textdraw ID. This function requires the SAMPFUNCS plugin to be installed and active. ```lua int outline, int color = sampTextdrawGetOutlineColor(int id) ``` -------------------------------- ### Initialize and Render Font in MoonLoader Source: https://wiki.blast.hk/moonloader/lua/renderCreateFont Demonstrates how to load a system font using renderCreateFont with specific flags and render it to the screen using renderFontDrawText within a main loop. ```lua local font_flag = require('moonloader').font_flag local my_font = renderCreateFont('Verdana', 12, font_flag.BOLD + font_flag.SHADOW) function main() while true do wait(0) renderFontDrawText(my_font, 'Colors:\n{FF0000}Red\n{00FF00}Green\n{0000FF}Blue\n{80FFFFFF}Transparent white', 10, 400, 0xFFFFFFFF) end end ``` -------------------------------- ### Get Player Pool Pointer (Sanny Builder) Source: https://wiki.blast.hk/gta-sa/opcodes/0BB7 This code example shows the equivalent functionality of Opcode 0BB7 in Sanny Builder, a popular tool for scripting GTA San Andreas. It retrieves the player pool pointer. ```Sanny Builder 0BB7=1,samp %1d% = get_player_pool_ptr ``` -------------------------------- ### Get Player Health (Lua - Moonloader) Source: https://wiki.blast.hk/moonloader/lua/sampGetPlayerHealth Retrieves the health level of a specified player in SAMP. This function is part of the Moonloader library and requires the SAMPFUNCS library to be installed. It takes the player's ID as an argument and returns their current health as an integer. ```lua int health = sampGetPlayerHealth(int id) ``` -------------------------------- ### Lua Example: Get Nearest Road Coordinates Source: https://wiki.blast.hk/ru/moonloader/lua/getClosestStraightRoad This Lua code snippet demonstrates how to use the `getClosestStraightRoad` function to find the coordinates of the nearest road within a given radius. It retrieves the player's current coordinates and then calls `getClosestStraightRoad` to find the road nodes. ```lua -- Определение функции для получения координат ближайшей дороги в указанном радиусе function getNearestRoadCoordinates(radius) -- Получение текущих координат игрока и сохранение их в массив A local A = { getCharCoordinates(PLAYER_PED) } -- Вызов функции getClosestStraightRoad для нахождения ближайшей дороги в указанном радиусе и сохранение результата в массив B local B = { getClosestStraightRoad(A[1], A[2], A[3], 0, radius or 600) } -- Проверка наличия корректных координат if B[1] ~= 0 and B[2] ~= 0 and B[3] ~= 0 then -- Если найдены корректные координаты, возвращается true вместе с координатами ближайшей дороги return true, B[1], B[2], B[3] end -- Если корректные координаты не найдены, возвращается false return false end ``` -------------------------------- ### Download file from URL using Opcode 0C65 Source: https://wiki.blast.hk/gta-sa/opcodes/0C65 This snippet demonstrates how to use opcode 0C65 to initiate a file download from a remote URL to a local file. It returns a download handle index which can be used to track the operation. ```Sanny Builder 0C65: 3@ = download_url "http://boost.org/LICENSE_1_0.txt" to_file "boost_lic.txt" ``` ```Sanny Builder 0C65=3,%3d% = download_url %1d% to_file %2d% ``` -------------------------------- ### Get RPC Name by ID (Lua) Source: https://wiki.blast.hk/moonloader/lua/raknetGetRpcName Retrieves the string name of an RPC using its integer ID. This function is part of the Moonloader library and requires SAMPFUNCS to be installed. It takes an integer RPC ID as input and returns a zstring representing the RPC's name. ```lua zstring name = raknetGetRpcName(int rpc) ``` -------------------------------- ### Copy File using Opcode 0B04 Source: https://wiki.blast.hk/gta-sa/opcodes/0B04 Demonstrates the syntax for copying a file from a source path to a destination path using the 0B04 opcode. This operation requires the FileSystemOperations library to be installed. ```CLEO 0B04: copy_file "myfile.txt" to "CLEO.txt" ``` ```Sanny Builder 0B04=2,copy_file %1d% to %2d% ;; IF and SET ``` -------------------------------- ### Set Target Blip Coordinates Usage Example Source: https://wiki.blast.hk/ru/moonloader/lua/setTargetBlipCoordinates Demonstrates how to register a chat command in MoonLoader that triggers the setTargetBlipCoordinates function. The example waits for SA-MP initialization before registering the command. ```lua function main() while not isSampAvailable() do wait (100) end sampRegisterChatCommand("setmarker", marker) wait(-1) end function marker(x, y, z) setTargetBlipCoordinates(x, y, z) end ``` -------------------------------- ### Get Current Day of Week in Lua (Moonloader) Source: https://wiki.blast.hk/moonloader/lua/getCurrentDayOfWeek This Lua function, `getCurrentDayOfWeek`, is part of the Moonloader library and returns the current day of the week. It takes no arguments. The return value is an integer representing the day, with Saturday being indicated as 4. The exact starting day for the count is noted as potentially unclear. ```lua getCurrentDayOfWeek() ``` ```lua int weekday = getCurrentDayOfWeek() ``` -------------------------------- ### Search files using Opcode 0AE6 in Sanny Builder Source: https://wiki.blast.hk/gta-sa/opcodes/0AE6 Demonstrates the implementation of opcode 0AE6 to find the first file matching a pattern. It requires a search path string and a buffer variable to store the resulting filename, returning a handle for subsequent searches. ```Sanny Builder 0AE6: 0@ = find_first_file "CLEO\*.cs" get_filename_to 1@v ``` ```Sanny Builder 0AE6=3,%2d% = find_first_file %1d% get_filename_to %3d% ``` -------------------------------- ### GET 0C38 - Get Global Function Parameters Source: https://wiki.blast.hk/ru/gta-sa/opcodes/0C38 Retrieves the thread pointer and label pointer associated with a specific global function name. ```APIDOC ## GET 0C38 ### Description Retrieves the parameters for registering a global function, specifically the thread pointer and the label pointer. ### Method GET ### Endpoint 0C38 ### Parameters #### Path Parameters - **gfunc** (string) - Required - The name of the global function to query. ### Request Example 0C38: get_global_func "gfunc" thread 0@ label 1@ ### Response #### Success Response (200) - **0@** (int) - The pointer to the thread. - **1@** (int) - The pointer to the label. #### Response Example 0C38=2,get_global_func %1d% thread %2d% label %3d% ``` -------------------------------- ### POST /moonloader/lua/sampSendScmEvent Source: https://wiki.blast.hk/t/samp Sends a vehicle tuning event to the SAMP server. ```APIDOC ## POST /moonloader/lua/sampSendScmEvent ### Description Sends an SCM event related to vehicle tuning to the server. ### Method POST ### Endpoint /moonloader/lua/sampSendScmEvent ### Request Body - **vehicle_id** (int) - Required - The ID of the vehicle being tuned. - **component_id** (int) - Required - The ID of the tuning component. ### Request Example { "vehicle_id": 123, "component_id": 1010 } ### Response #### Success Response (200) - **status** (string) - Confirmation of event transmission. ``` -------------------------------- ### Implement INI Configuration Management in Lua Source: https://wiki.blast.hk/moonloader/lua/inicfg A complete example demonstrating how to load a configuration with defaults, modify values, and save the updated data back to an INI file using the inicfg library. ```lua local inicfg = require 'inicfg' local mainIni = inicfg.load({ settings = { title = "text", text_color = "0xAABBCC" }, location = { width = 100, height = 200, pos_x = 20, pos_y = 50 } }) function main() local anotherIni = inicfg.load(nil, "example_another_config") if anotherIni ~= nil then local newV1, newV2 = math.random(100, 1000), math.random(100, 1000) local newData = { main = { value1 = newV1, value2 = newV2, sum = newV1 + newV2 } } inicfg.save(newData, "example_another_config") end mainIni.settings.title = "Hello" mainIni.location.pos_x = 100 mainIni.location.pos_y = 75 inicfg.save(mainIni) end ``` -------------------------------- ### GET /moonloader/lua/doesFileExist Source: https://wiki.blast.hk/t/function/lua/moonloader Checks if a specific file exists on the filesystem. ```APIDOC ## GET /moonloader/lua/doesFileExist ### Description Checks if a file exists at the specified path. ### Method GET ### Endpoint /moonloader/lua/doesFileExist ### Parameters #### Query Parameters - **path** (string) - Required - The file path to verify. ### Response #### Success Response (200) - **exists** (boolean) - Returns true if the file exists, false otherwise. ``` -------------------------------- ### GET /opcodes/0C70 Source: https://wiki.blast.hk/gta-sa/opcodes/0C70 Retrieves the handle of a specified library module. ```APIDOC ## GET /opcodes/0C70 ### Description Returns the handle of the specified library module. This is commonly used in SAMP modding to interact with loaded DLLs. ### Method GET ### Endpoint 0C70 ### Parameters #### Path Parameters - **module_name** (string) - Required - The name of the library (e.g., "samp.dll") ### Request Example 0C70: 1@ = get_module "samp.dll" handle ### Response #### Success Response (200) - **handle** (handle) - The handle of the requested library. #### Response Example { "handle": "0x75A00000" } ``` -------------------------------- ### GET /opcodes/0AB6 Source: https://wiki.blast.hk/gta-sa/opcodes/0AB6 Retrieves the coordinates of the user-placed marker on the map. ```APIDOC ## GET /opcodes/0AB6 ### Description Retrieves the coordinates of the user-placed marker on the map and stores them into the provided variables. ### Method GET ### Endpoint 0AB6: store_target_marker_coords_to [var_x] [var_y] [var_z] ### Parameters #### Path Parameters - **var_x** (float) - Required - Variable to store the X coordinate - **var_y** (float) - Required - Variable to store the Y coordinate - **var_z** (float) - Required - Variable to store the Z coordinate ### Request Example 0AB6: store_target_marker_coords_to 0@ 1@ 2@ ### Response #### Success Response (200) - **0@** (float) - X coordinate of the marker - **1@** (float) - Y coordinate of the marker - **2@** (float) - Z coordinate of the marker #### Response Example { "x": 123.45, "y": 678.90, "z": 10.0 } ``` -------------------------------- ### Opcode 0C2F Example - CLEO Script Source: https://wiki.blast.hk/gta-sa/opcodes/0C2F An example of using Opcode 0C2F within a CLEO script to convert a string to an integer and log the results. It includes memory allocation and deallocation. ```cleo {$CLEO} wait 0 0AC8: 0@ = allocate_memory_size 128 0AD3: 0@ = format "2014 год" 0C2F: 1@ = strtol 0@ radix 10 store_end_to 2@ 0B78: log "strtol(%s) -> %d-ый%s" 0@ 1@ 2@ 0AC9: free_allocated_memory 0@ 0A93: end_custom_thread ``` -------------------------------- ### Launch Custom Thread with Opcode 0A92 Source: https://wiki.blast.hk/ru/gta-sa/opcodes/0A92 This snippet demonstrates how to invoke the 0A92 opcode to start an external script file. It accepts a file path relative to the CLEO folder and optional variables to pass to the new thread. ```Sanny Builder 0A92: create_custom_thread "script.sc" 0@ 1@ ``` ```Sanny Builder 0A92=-1,create_custom_thread %1s% ``` -------------------------------- ### System and Utility API Source: https://wiki.blast.hk/t/function Utility functions for file system checks, event handling, and low-level memory management. ```APIDOC ## GET /moonloader/lua/doesFileExist ### Description Checks if a file exists on the local file system. ### Method GET ### Endpoint /moonloader/lua/doesFileExist --- ## GET /moonloader/lua/addEventHandler ### Description Registers a new event handler based on the provided event name. ### Method GET ### Endpoint /moonloader/lua/addEventHandler --- ## GET /moonloader/lua/allocateMemory ### Description Allocates a block of memory and returns a pointer to the allocated memory area. ### Method GET ### Endpoint /moonloader/lua/allocateMemory ``` -------------------------------- ### Move Directory using Opcode 0B03 Source: https://wiki.blast.hk/gta-sa/opcodes/0B03 Demonstrates the syntax for moving a directory from a source path to a destination path using the CLEO opcode 0B03. This operation requires the FileSystemOperations library to be installed. ```CLEO 0B03: move_directory "CLEO\dir1" to "CLEO\dir2" ``` ```Sanny Builder 0B03=2,move_directory %1d% to %2d% ;; IF and SET ``` -------------------------------- ### GET 0BB2 - Get Misc Info Pointer Source: https://wiki.blast.hk/ru/gta-sa/opcodes/0BB2 Retrieves the memory pointer for miscellaneous SAMP data structures. ```APIDOC ## GET 0BB2 ### Description Retrieves a pointer to the miscellaneous data structure in the SAMP environment. ### Method GET ### Endpoint 0BB2 ### Parameters #### Path Parameters - **None** #### Query Parameters - **None** ### Request Example ``` 0BB2: samp 0@ = get_misc_info_ptr ``` ### Response #### Success Response (200) - **0@** (int) - The memory pointer to the miscellaneous data structure. #### Response Example ``` 0@ = 0x12345678 ``` ``` -------------------------------- ### Get Module Handle in Sanny Builder Source: https://wiki.blast.hk/gta-sa/opcodes/0C70 This snippet demonstrates how to use opcode 0C70 in Sanny Builder to get the handle of a library, specifically 'samp.dll'. It shows the opcode's syntax and how to assign the resulting handle to a variable. ```Sanny Builder 0C70=2,%2d% = get_module %1d% handle ``` -------------------------------- ### renderBegin Source: https://wiki.blast.hk/t/render Marks the beginning of drawing a shape using a specific method. ```APIDOC ## POST /moonloader/lua/renderBegin ### Description Begins the drawing process for a shape. ### Method POST ### Endpoint /moonloader/lua/renderBegin ### Parameters None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Emulate Incoming RPC with Opcode 0BF6 Source: https://wiki.blast.hk/gta-sa/opcodes/0BF6 This snippet demonstrates how to use opcode 0BF6 to emulate an incoming RPC in a Sanny Builder script. It requires an RPC ID and a BitStream object as input parameters. ```Sanny Builder 0BF6: raknet emul_rpc_receive 0@ bit_stream 1@ ``` ```Sanny Builder Definition 0BF6=2,raknet emul_rpc_receive %1d% bit_stream %2d% ``` -------------------------------- ### GET 0BB8 - Get Vehicle Pool Pointer Source: https://wiki.blast.hk/ru/gta-sa/opcodes/0BB8 Retrieves the memory pointer for the vehicle pool in SAMP. ```APIDOC ## GET 0BB8 ### Description Returns the memory pointer for the vehicle pool in SAMP. ### Method GET ### Endpoint 0BB8 ### Parameters #### Path Parameters - **None** #### Query Parameters - **None** ### Request Example ``` 0BB8: samp 0@ = get_vehicle_pool_ptr ``` ### Response #### Success Response (200) - **0@** (int) - The memory pointer to the vehicle pool. #### Response Example ``` 0@ = 12345678 ``` ``` -------------------------------- ### GET /opcodes/0C15 Source: https://wiki.blast.hk/ru/gta-sa/opcodes/0C15 Documentation for the 0C15 opcode used to concatenate strings in SAMPFUNCS. ```APIDOC ## GET /opcodes/0C15 ### Description Appends the content of the source string to the destination string. ### Method GET ### Endpoint 0C15 ### Parameters #### Path Parameters - **destination** (string) - Required - The target string buffer to which the source will be appended. - **source** (string) - Required - The string to be appended to the destination. ### Request Example ``` 0C15: strcat destination 0@ source 1@ ``` ### Response #### Success Response (200) - **result** (void) - The destination buffer is updated in memory. #### Response Example ``` {$CLEO} wait 0 0AC8: 0@ = allocate_memory_size 128 0AD3: 0@ = format "Привет" 0C15: strcat destination 0@ source " чувак." 0B78: log "strcat -> %s" 0@ 0AC9: free_allocated_memory 0@ 0A93: end_custom_thread ``` ``` -------------------------------- ### Register and Handle Client Commands Source: https://wiki.blast.hk/ru/sampfuncs/changelog Demonstrates the registration of a custom client-side command and the retrieval of its parameters using the updated opcode structure. ```SAMP-Scm 0B34: samp register_client_command "mycommand" to_label @mycommand 0B35: samp 0@ = get_last_command_params ``` -------------------------------- ### GET 0B7B - Get RakPeer Pointer Source: https://wiki.blast.hk/ru/gta-sa/opcodes/0B7B Retrieves the RakPeer pointer for use in SAMP modding scripts. ```APIDOC ## GET 0B7B ### Description Returns the pointer to the RakPeer interface used in SAMP. ### Method GET ### Endpoint 0B7B ### Parameters #### Request Body - **0@** (int) - Required - Variable to store the RakPeer pointer ### Request Example ``` 0B7B: samp 0@ = get_rakpeer ``` ### Response #### Success Response (200) - **0@** (int) - The memory address pointer to the RakPeer interface #### Response Example ``` 0@ = 12345678 ``` ``` -------------------------------- ### GET /opcodes/0172 Source: https://wiki.blast.hk/gta-sa/opcodes/0172 Retrieves the Z-axis rotation angle of a specified actor handle. ```APIDOC ## GET /opcodes/0172 ### Description Returns the rotation angle (Z-angle) of the specified actor. ### Method GET ### Endpoint /opcodes/0172 ### Parameters #### Path Parameters - **actor_handle** (handle) - Required - The actor handle (e.g., $PLAYER_ACTOR) ### Request Example ``` 0172: 0@ = actor $PLAYER_ACTOR Z_angle ``` ### Response #### Success Response (200) - **angle** (float) - The Z-axis rotation angle of the actor. #### Response Example ``` { "angle": 90.0 } ``` ``` -------------------------------- ### Display SAMP Dialog using Opcode 0B3B Source: https://wiki.blast.hk/gta-sa/opcodes/0b3b Demonstrates the syntax for invoking the 0B3B opcode to render a dialog box. Requires the SAMPFUNCS library and specifies dialog ID, caption, content, button labels, and style. ```Sanny Builder 0B3B: samp show_dialog id 0@ caption "dlg" text "content" button_1 "btn1" button_2 "btn0" style 5@ ``` ```Sanny Builder Definition 0B3B=6,samp show_dialog id %1d% caption %2s% text %3s% button_1 %4s% button_2 %5s% style %6d% ``` -------------------------------- ### Get Car Driver Opcode 046C Usage Source: https://wiki.blast.hk/ru/gta-sa/opcodes/046C This code snippet demonstrates the basic usage of opcode 046C in GTA San Andreas scripting to get the driver of a car. It takes a car handle as input and returns a player handle. ```script 046C: 1@ = car 0@ driver ``` -------------------------------- ### Get Cursor Position in Sanny Builder (GTA SA) Source: https://wiki.blast.hk/gta-sa/opcodes/0B5E This is the Sanny Builder representation for the opcode 0B5E, which gets the cursor's screen position. It defines the opcode and its output parameters in a format understandable by the Sanny Builder compiler. ```sannybuilder 0B5E=2,get_cursor_pos %1d% %2d% ``` -------------------------------- ### Executing Opcodes in SAMPFUNCS Console Source: https://wiki.blast.hk/sampfuncs/console Demonstrates how to execute opcodes directly within the SAMPFUNCS console. It highlights the importance of correct parameter order, referencing SASCM.ini for opcode details. The console supports Sanny Builder syntax and has predefined global variables. ```text 07A7: put_jetpack_on_actor $PLAYER_ACTOR 0226: store_actor $PLAYER_ACTOR health_to 0@ ``` -------------------------------- ### Get Player Struct Pointer (Sampfuncs) Source: https://wiki.blast.hk/gta-sa/opcodes/0B24 This code snippet demonstrates how to use opcode 0B24 in Sampfuncs to get the pointer to a player's structure. It takes a player ID as input and returns a pointer to the player's structure. ```asm 0B24: samp 1@ = get_player_struct_ptr 0@ ``` -------------------------------- ### Example Usage of Lua Memory Functions Source: https://wiki.blast.hk/moonloader/lua/memory Demonstrates how to use the 'memory' module in Lua to read a string from memory, check for cheat codes, and read/write integer values from specific memory addresses. This example includes a loop that continuously checks for player status and cheat activation. ```lua local mem = require "memory" function main() while not isPlayerPlaying(playerHandle) do wait(100) end local wut = mem.tostring(0x969110) print(wut) while true do wait(10) if testCheat("MONEY") then local money = mem.getint32(0xB7CE50) print("Current money: " .. money) -- добавить $250.000 mem.setint32(0xB7CE50, money + 250000) end end end ``` -------------------------------- ### GET Opcode 0B8E Source: https://wiki.blast.hk/ru/gta-sa/opcodes/0B8E Retrieves the current cursor mode status within the SA-MP environment. ```APIDOC ## GET 0B8E ### Description Returns the current cursor mode status in the SA-MP environment. ### Method GET ### Endpoint 0B8E ### Parameters #### Path Parameters - **0@** (int) - Required - Variable to store the returned cursor mode ### Request Example ``` 0B8E: samp 0@ = get_cursor_mode ``` ### Response #### Success Response (200) - **0@** (int) - The integer representing the current cursor mode #### Response Example ``` 0@ = 1 ``` ``` -------------------------------- ### Opcode 0C2E CLEO Script Example Source: https://wiki.blast.hk/ru/gta-sa/opcodes/0C2E An example of using Opcode 0C2E within a CLEO script to find the first character in a dynamically formatted string that does not match a specified set of characters, and logging the result. ```CLEO {$CLEO} wait 0 0AC8: 0@ = allocate_memory_size 128 0AD3: 0@ = format "gy test2pg п1" 0C2E: 1@ = strspn string1 0@ string2 "tepg ts12" 0B78: log "strspn > i %d" 1@ 0AC9: free_allocated_memory 0@ 0A93: end_custom_thread ``` -------------------------------- ### GET 0C58 - Get Textdraw Outline Source: https://wiki.blast.hk/gta-sa/opcodes/0C58 Retrieves the outline thickness and color parameters for a specified textdraw ID. ```APIDOC ## 0C58 Get Textdraw Outline ### Description Returns the outline parameters (thickness and color) of the specified textdraw. ### Method OPCODE ### Endpoint 0C58 ### Parameters #### Path Parameters - **0@** (int) - Required - The ID of the textdraw to query. ### Request Example 0C58: samp textdraw 0@ get_outline 1@ color 2@ ### Response #### Success Response - **1@** (int) - The thickness of the outline. - **2@** (int) - The color of the outline. ### Sanny Builder Definition 0C58=3,samp textdraw %1d% get_outline %2d% color %3d% ``` -------------------------------- ### Scan string using Opcode 0AD4 Source: https://wiki.blast.hk/ru/gta-sa/opcodes/0AD4 Demonstrates the syntax for using opcode 0AD4 to scan a string based on a provided format. It returns the number of successfully scanned values and stores them in the specified variables. ```CLEO 0AD4: 1@ = scan_string 0@ format "%d %f" 2@ 3@ ``` -------------------------------- ### GET 0BEF - Get BitStream Bytes Used Source: https://wiki.blast.hk/ru/gta-sa/opcodes/0BEF Retrieves the total number of bytes currently used within a specified RakNet BitStream. ```APIDOC ## GET 0BEF ### Description Returns the number of bytes currently used in a RakNet BitStream. ### Method GET ### Endpoint 0BEF ### Parameters #### Path Parameters - **0@** (int) - Required - The BitStream object reference. ### Request Example ``` 0BEF: raknet 1@ = bit_stream 0@ get_number_of_bytes_used ``` ### Response #### Success Response (200) - **1@** (int) - The number of bytes used in the BitStream. ### Sanny Builder Definition ``` 0BEF=2,raknet %2d% = bit_stream %1d% get_number_of_bytes_used ``` ``` -------------------------------- ### Game Key and Screen Resolution Opcode Documentation Source: https://wiki.blast.hk/sampfuncs/changelog Opcode documentation for setting game keys and retrieving screen resolution. These opcodes allow for programmatic control of game input and obtaining display information. ```SAMP 0B56: set_game_key 1 state 0xFF 0B5A: get_screen_resolution 0@ 1@ ``` -------------------------------- ### Example Usage of renderDrawPolygon (Lua) Source: https://wiki.blast.hk/ru/moonloader/lua/renderDrawPolygon This Lua code example demonstrates how to use the renderDrawPolygon function to draw a pentagon in the center of the screen. It shows how to obtain screen resolution and pass the correct arguments for position, size, corners, rotation, and color. ```lua -- пятиугольник по центру экрана local sx, sy = getScreenResolution() renderDrawPolygon(sx / 2, sy / 2, 150, 150, 5, 0.0, 0xFF1166AA) ```