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 shortcutlocal CB = exports["kimi_callbacks"]-- register callback to get the players distance to a specified positionCB:Register("getPlayerDistanceToPosition", function(position)local playerPosition =GetEntityCoords(PlayerPedId())return#(playerPosition - position)end)-- function that triggers a callback to receive the position of a vehiclefunctionGetVehiclePositionFromServer(plate)local position = CB:Trigger("getVehiclePositionFromPlate", plate)return positionend
Server side
-- create shortcutlocal CB = exports["kimi_callbacks"]-- register a callback to get a vehicles position from its plateCB:Register("getVehiclePositionFromPlate", function(playerId,plate)local vehicles =GetAllVehicles()for i =1, #vehicles doif (DoesEntityExist(vehicles[i])) thenif (GetVehicleNumberPlateText(vehicles[i]) == plate)) thenreturnGetEntityCoords(vehicles[i])endendendreturnnilend)-- function that triggers a callback to receive the players distance -- to a specified positionfunctionGetPlayerDistanceToPosition(playerId,position)local distance = CB:Trigger("getPlayerDistanceToPosition", playerId, position)return distanceend