RSG Framework includes a built-in prompt system that creates native Red Dead Redemption 2 style interaction prompts. These prompts appear when players approach specific locations and can trigger events when the correct key is pressed.Location: resources/[framework]/rsg-core/client/prompts.lua
Prompts are the primary way players interact with the world in Red Dead Redemption 2. Using native prompts ensures a consistent and immersive experience.
-- CLIENT SIDElocal createdPrompts = {}-- Create prompts and store handleslocal function CreateJobPrompts() local prompt1 = exports['rsg-core']:createPrompt( 'job_start_point', vector3(100.0, 200.0, 30.0), RSGCore.Shared.Keybinds['E'], 'Start Job', { type = 'client', event = 'job:client:start', args = {} } ) table.insert(createdPrompts, prompt1)end-- Delete all created promptslocal function DeleteJobPrompts() for i, handle in ipairs(createdPrompts) do exports['rsg-core']:deletePrompt(handle) end createdPrompts = {}end-- Usage: Create prompts when player clocks inRegisterNetEvent('job:client:clockIn', function() CreateJobPrompts()end)-- Delete prompts when player clocks outRegisterNetEvent('job:client:clockOut', function() DeleteJobPrompts()end)
-- CLIENT SIDE-- Show prompt only if player has required itemlocal function CreateConditionalPrompt() -- First check if player has key RSGCore.Functions.TriggerCallback('housing:server:hasKey', function(hasKey) if hasKey then exports['rsg-core']:createPrompt( 'house_door', vector3(-350.5, 800.2, 116.8), RSGCore.Shared.Keybinds['E'], 'Enter House', { type = 'client', event = 'housing:client:enter', args = { houseId = 1 } } ) end end)end
Use Unique Location IDs: Each prompt needs a unique location identifier to prevent conflicts
Copy
-- Good: Descriptive and unique'valentine_bank_teller_1''rhodes_general_store_entrance'-- Bad: Generic or duplicate'bank''store'
Always Clean Up Prompts: Delete prompts when theyโre no longer needed to prevent memory leaks and ghost prompts
Copy
-- Store handles when creatinglocal handle = exports['rsg-core']:createPrompt(...)table.insert(myPrompts, handle)-- Delete when donefor _, h in ipairs(myPrompts) do exports['rsg-core']:deletePrompt(h)end
Use Config for Coordinates: Store prompt locations in config files for easy adjustment
Batch Creation: Create multiple prompts in a single loop, not in separate threads
Clean on Unload: Delete all prompts in onResourceStop
Minimal Distance: Use appropriate interaction distances
Avoid Duplicates: Check if prompt exists before creating
Copy
-- Clean up on resource stopAddEventHandler('onResourceStop', function(resource) if resource == GetCurrentResourceName() then for _, handle in ipairs(createdPrompts) do exports['rsg-core']:deletePrompt(handle) end endend)
-- Create door prompts that change based on lock statelocal function UpdateDoorPrompt(doorId, isLocked) -- Delete existing prompt if doorPrompts[doorId] then exports['rsg-core']:deletePrompt(doorPrompts[doorId]) end local doorConfig = Config.Doors[doorId] local label = isLocked and 'Unlock Door' or 'Lock Door' doorPrompts[doorId] = exports['rsg-core']:createPrompt( 'door_' .. doorId, doorConfig.coords, RSGCore.Shared.Keybinds['E'], label, { type = 'server', event = 'doors:server:toggle', args = { doorId = doorId } } )end