πŸ“–
Documentation
  • Welcome!
  • Common Issues
    • Keymaster
    • Updating resources
  • πŸ“„Scripts
    • πŸš™AdvancedParking
      • Installation
      • Commands
      • Exports (server)
      • Exports (client)
      • Events (server)
      • Events (client)
      • FAQ
    • 🚚VehicleTransport
      • Installation
      • How to use it
      • Creating a new transport
      • Exports (client)
      • Events (server & client)
    • πŸ”‘VehicleKeyChain
      • Installation
      • Commands
      • Exports (server)
      • Exports (client)
      • FAQ
    • πŸ—œοΈVehicleClamp - Pre-Release
      • Installation
      • Commands
      • Exports (server)
      • Exports (client)
      • Integration
        • ESX
        • QB
    • πŸ“„VehicleRegistration
      • Installation
      • Exports (server)
      • Exports (client)
    • πŸ“ƒVehicleInteraction
      • Installation
    • πŸ—ΊοΈVehicleTracker
      • Installation
      • Exports (server)
      • Exports (client)
    • 🌐JobTracker
      • Installation
    • πŸ•΅οΈβ€β™‚οΈVehicleForceFirstPerson
      • Installation
    • 🎯BulletRicochet
      • Installation
  • πŸ†“Free Scripts
    • πŸ“žkimi_callbacks
      • Installation
      • Exports (server)
      • Exports (client)
      • Examples
    • 🚜VehicleDeformation
      • Installation
      • Exports (server)
      • Exports (client)
    • 🎦OrbitCam
      • Installation
      • Exports (client)
      • Commands
    • πŸ”οΈEarthquakeSimulator
      • Installation
      • Exports (server)
      • Commands
    • πŸ’€DeathCam
      • Installation
Powered by GitBook
On this page
  • Client side
  • Server side
  1. Free Scripts
  2. kimi_callbacks

Examples

In these examples, we will register and trigger a server callback that can get a vehicles position from its plate across the whole map and we will register a client callback that retrieves the distance from a player to a specified position.

Client side

-- create shortcut
local CB = exports["kimi_callbacks"]

-- register callback to get the players distance to a specified position
CB:Register("getPlayerDistanceToPosition", function(position)
    local playerPosition = GetEntityCoords(PlayerPedId())
    return #(playerPosition - position)
end)

-- function that triggers a callback to receive the position of a vehicle
function GetVehiclePositionFromServer(plate)
    local position = CB:Trigger("getVehiclePositionFromPlate", plate)
    return position
end

Server side

-- create shortcut
local CB = exports["kimi_callbacks"]

-- register a callback to get a vehicles position from its plate
CB:Register("getVehiclePositionFromPlate", function(playerId, plate)
    local vehicles = GetAllVehicles()
    for i = 1, #vehicles do
        if (DoesEntityExist(vehicles[i])) then
            if (GetVehicleNumberPlateText(vehicles[i]) == plate)) then
                return GetEntityCoords(vehicles[i])
            end
        end
    end
    
    return nil
end)

-- function that triggers a callback to receive the players distance 
--    to a specified position
function GetPlayerDistanceToPosition(playerId, position)
    local distance = CB:Trigger("getPlayerDistanceToPosition", playerId, position)
    return distance
end
PreviousExports (client)NextVehicleDeformation

Last updated 1 year ago

πŸ†“
πŸ“ž