1
0
Fork 0
forked from Simnation/Main
Main/resources/[defaultmaps]/prompt_sandy_mechanic/open_functions.lua

76 lines
2.5 KiB
Lua
Raw Normal View History

2025-08-06 09:20:57 +02:00
--[[
OPEN SOURCE FUNCTIONS FOR CUSTOM INTEGRATIONS
These functions allow you to add custom checks, permissions, and interactions
NOTE: These functions run on CLIENT SIDE - use callbacks for server data
Example 1: General interaction check (distance, items, conditions, etc.)
function CanPlayerInteract(propName, serverId)
local ped = PlayerPedId()
if propName == "prompt_sandy_is_garage_rollup" then
-- Check if player has specific item (using callback to server)
local hasKey = lib.callback.await('garage:hasKey', false)
return hasKey
elseif propName == "prompt_sandy_is_lift" then
return IsPedInAnyVehicle(ped, false) -- Must be in vehicle to use lift
end
return true
end
Example 2: Job/permission specific access (use callbacks for server data)
function HasJobAccess(propName, serverId)
if propName == "prompt_sandy_is_secret_door" then
local hasAccess = lib.callback.await('garage:checkMechanicAccess', false)
return hasAccess
elseif propName == "prompt_sandy_is_floorgate" then
local isAdmin = lib.callback.await('garage:checkAdminAccess', false)
return isAdmin
end
return true
end
Example 3: Custom labels based on player data
function GetCustomLabel(propName, serverId, defaultLabel)
if propName == "prompt_sandy_is_garage_rollup" then
local hasAccess = lib.callback.await('garage:checkMechanicAccess', false)
if hasAccess then
return "Open/Close Garage Door"
else
return "Access Denied - Mechanics Only"
end
elseif propName == "prompt_sandy_is_engine_full" then
return "Use Engine Lift - $50"
end
return defaultLabel
end
Example 4: Custom actions on interaction
function OnPropInteraction(propName, serverId, propState)
if propName == "prompt_sandy_is_secret_door" then
TriggerEvent('garage:showSecretMenu')
elseif propName == "prompt_sandy_is_engine_full" then
TriggerServerEvent('garage:chargeEngineUse', propState)
lib.notify({
title = 'Engine Lift',
description = 'Engine lift ' .. (propState and "lowered" or "raised"),
type = 'success'
})
end
end
]]
function CanPlayerInteract(propName, serverId)
return true
end
function HasJobAccess(propName, serverId)
return true
end
function GetCustomLabel(propName, serverId, defaultLabel)
return defaultLabel
end
function OnPropInteraction(propName, serverId, propState)
end