-
Notifications
You must be signed in to change notification settings - Fork 12
Examples
Kiminaze edited this page Nov 29, 2022
·
1 revision
All examples below assume that you call the exports by shortening the function call:
local CB = exports["kimi_callbacks"]CB:Register("getPlayerPosition", function()
return GetEntityCoords(PlayerPedId())
end)CB:Register("getPlayerPositionAndHeading", function()
local playerPed = PlayerPedId()
return GetEntityCoords(playerPed), GetEntityHeading(playerPed)
end)CB:Register("getPlayerDistanceToPosition", function(position)
return #(GetEntityCoords(PlayerPedId()) - position)
end)function GetMoney()
return CB:Trigger("getMoney")
endfunction GetCashMoneyTimeout()
return CB:TriggerWithTimeout("getMoney", 500, "cash") or 0
endCB:Register("getMoney", function(source, moneyType)
-- get money from player with source
local cash, bank = GetMoneyFromPlayer(source)
if (moneyType == "cash") then
return cash
elseif (moneyType == "bank") then
return bank
end
return cash, bank
end)function GetPlayerPosition(playerId)
return CB:Trigger("getPlayerPosition", playerId)
endfunction GetPlayerPositionAndHeading(playerId)
return CB:Trigger("getPlayerPositionAndHeading", playerId)
endfunction GetPlayerDistanceToPosition(playerId, position)
return CB:TriggerWithTimeout("getPlayerDistanceToPosition", playerId, 500, position)
end