-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This page documents all available opcodes (Lua functions) exposed by MoonLoader III for GTA III scripting.
- Script Metadata
- Core / Flow Control
- Input & Camera
- Player
- Peds
- Vehicles
- Models & Streaming
- Game World
- Memory
- Debug / HUD
These functions are called at the top of your script to set metadata. They are optional — if script_name is not used, the filename (without .lua) is used for logging.
Sets the display name of the script used in logs.
script_name("My Cool Mod")Sets the author name.
script_author("YourName")Sets a short description.
script_description("Spawns cars when you type a cheat")Sets the version string.
script_version("1.0")| Global | Type | Description |
|---|---|---|
script_path |
string |
Full filesystem path to the running script |
print(...) |
function |
Prints to moonloader.log with the script's display name as prefix |
Yields the script for ms milliseconds. Must be called inside while true do loops to prevent freezing the game.
wait(1000) -- wait 1 secondReturns true if the player has typed the cheat string (A-Z, 0-9, space). The cheat is consumed after detection so it won't trigger again until retyped.
if test_cheat("NOC") then
print("No Clip activated!")
endReturns true if the Windows virtual-key code is currently held down. Uses GetAsyncKeyState.
if is_key_pressed(87) then -- VK_W
-- W is held
endReturns the current frame delta time multiplier (CTimer::ms_fTimeStep). Multiply by your speed value for frame-rate-independent movement.
local speedDt = SPEED * get_frame_delta_time()Returns the current camera position in world space.
local cx, cy, cz = get_camera_position()Returns a point in world space that the camera is looking at (camera position + forward vector).
local tx, ty, tz = get_camera_target()Returns the ped handle for player slot id (0 for player 1).
local ped = get_player_ped(0)Returns true if the player slot is active.
if is_player_playing(0) then ... endReturns true if the ped is currently inside any vehicle.
if is_char_in_any_car(ped) then ... endReturns the vehicle handle the player is driving, or 0 if on foot.
local car = get_player_car(0)Returns the player's current position.
local x, y, z = get_player_coords(0)Teleports the player to the given coordinates.
set_player_coords(0, 100.0, -50.0, 10.0)Allows or blocks the player from entering/exiting vehicles.
set_player_can_enter_exit_vehicles(0, false) -- lock player in/outSpawns a pedestrian at the given coordinates. type is the ePedType (e.g., 4 for civilian male). Returns a handle or 0 on failure.
local ped = create_ped(4, 7, x, y, z)Removes the ped from the world and frees memory.
delete_ped(ped)Teleports the ped.
set_ped_coords(ped, x, y, z)Returns the ped's position.
local x, y, z = get_ped_coords(ped)Returns true if the ped is inside a vehicle.
if is_ped_in_car(ped) then ... endEnables or disables collision for the ped.
set_ped_collision(ped, false) -- noclip for pedSpawns a vehicle. You must request_model + load_all_models_now beforehand. Returns handle or 0.
request_model(111)
load_all_models_now()
local car = create_car(111, x, y, z)Removes the vehicle from the world.
delete_car(car)Teleports the vehicle.
set_car_coords(car, x, y, z)Returns the vehicle's position.
local x, y, z = get_car_coords(car)Sets vehicle health.
set_car_health(car, 1500)Returns vehicle health.
local hp = get_car_health(car)Enables or disables collision for the vehicle.
set_car_collision(car, false)Returns true if the handle is still valid (vehicle not destroyed).
if does_car_exist(car) then ... endRequests a model to be loaded into memory.
request_model(111)Alias for request_model.
load_model(111)Returns true if the model is fully loaded. Important: In GTA III you must call load_all_models_now() after requesting, or this will stay false.
if has_model_loaded(111) then ... endForces all requested models to load immediately. Call this after request_model.
request_model(111)
load_all_models_now()Tells the streaming system it can unload this model to free memory.
mark_model_as_no_longer_needed(111)Returns the current game time in milliseconds.
local t = get_game_timer()Reads memory at the given address. size must be 1, 2, or 4.
local wanted = read_memory(0x9412BC, 1)Writes memory at the given address. size must be 1, 2, or 4.
write_memory(0x9412BC, 1, 0) -- clear wanted levelStub for calling game functions. Currently returns 0 and logs a warning.
local result = call_function(0x123456)Draws text on screen using CFont. Call inside a while true do wait(0) end loop to keep it visible.
while true do
wait(0)
print_string("Hello Liberty City!")
endDraws large heading-style text on screen.
print_big("BIG TEXT")script_name("Vehicle Spawner")
script_author("YourName")
script_description("Spawn a Kuruma with TESTLUA cheat")
script_version("1.0")
while true do
wait(0)
if test_cheat("TESTLUA") then
local px, py, pz = get_player_coords(0)
local model = 111 -- kuruma
request_model(model)
load_all_models_now()
if has_model_loaded(model) then
local car = create_car(model, px, py + 4.0, pz)
if car ~= 0 then
print_string("Kuruma spawned!")
end
mark_model_as_no_longer_needed(model)
end
end
end