dkm
Ripped a part utility folder and shoved it into a lib. Changed a lot of Utility prefixes to the modules name. This contains breaking changes. Scripts that use 0.2.0 will need to update to match the new format
This commit is contained in:
1 parent
a08c22afed
commit
84480f8939
36 files changed
+2523
-97
No files matched your search
@@ -0,0 +1,26 @@
|
||||
Marker = {}
|
||||
|
||||
function Marker.DrawMarker(data)
|
||||
local position = data.position or vector3(0.0, 0.0, 0.0)
|
||||
local offset = data.offset or vector3(0.0, 0.0, 0.0)
|
||||
local marker = data.marker or 1
|
||||
local pos = vector3(position.x + offset.x, position.y + offset.y, position.z + offset.z)
|
||||
local rotation = data.rotation or vector3(0, 0, 0)
|
||||
local size = data.size or vector3(1.0, 1.0, 1.0)
|
||||
local color = data.color or vector3(0, 255, 0)
|
||||
local alpha = data.alpha or 255
|
||||
local bobUpAndDown = data.bobUpAndDown
|
||||
DrawMarker(
|
||||
marker,
|
||||
pos.x, pos.y, pos.z,
|
||||
0.0, 0.0, 0.0,
|
||||
rotation.x, rotation.y, rotation.z,
|
||||
size.x, size.y, size.z,
|
||||
color.r, color.g, color.b, alpha,
|
||||
bobUpAndDown, false, false
|
||||
)
|
||||
end
|
||||
|
||||
exports("Makrer", Marker)
|
||||
|
||||
return Marker
|
||||
@@ -0,0 +1,110 @@
|
||||
Placeable = Placeable or {}
|
||||
Utility = Utility or Require("lib/client/utility.lua")
|
||||
|
||||
local activePlacementProp = nil
|
||||
lib.locale()
|
||||
|
||||
-- Object placer --
|
||||
local placementText = {
|
||||
locale('place_object_place'),
|
||||
locale('place_object_cancel'),
|
||||
locale('place_object_scroll_up'),
|
||||
locale('place_object_scroll_down')
|
||||
}
|
||||
|
||||
local function finishPlacing()
|
||||
Bridge.Notify.HideHelpText()
|
||||
if activePlacementProp == nil then return end
|
||||
DeleteObject(activePlacementProp)
|
||||
activePlacementProp = nil
|
||||
end
|
||||
|
||||
Placeable.PlaceObject = function(object, distance, snapToGround, allowedMats, offset)
|
||||
if activePlacementProp then return end
|
||||
|
||||
if not object then Prints.Error('no_prop_defined') end
|
||||
|
||||
local propObject = type(object) == 'string' and joaat(object) or object
|
||||
local heading = 0.0
|
||||
local checkDist = distance or 10.0
|
||||
|
||||
Utility.LoadModel(propObject)
|
||||
|
||||
activePlacementProp = CreateObject(propObject, 1.0, 1.0, 1.0, false, true, true)
|
||||
SetModelAsNoLongerNeeded(propObject)
|
||||
SetEntityAlpha(activePlacementProp, 150, false)
|
||||
SetEntityCollision(activePlacementProp, false, false)
|
||||
SetEntityInvincible(activePlacementProp, true)
|
||||
FreezeEntityPosition(activePlacementProp, true)
|
||||
|
||||
Bridge.Notify.ShowHelpText(type(placementText) == 'table' and table.concat(placementText) or placementText, {
|
||||
position = "left-center",
|
||||
})
|
||||
|
||||
local outLine = false
|
||||
|
||||
while activePlacementProp do
|
||||
--local hit, _, coords, _, materialHash = lib.raycast.fromCamera(1, 4)
|
||||
--local hit, _, coords, _, materialHash = lib.raycast.fromCamera(1, 4, nil)
|
||||
local hit, _, coords, _, materialHash = lib.raycast.fromCamera(1, 4)
|
||||
if hit then
|
||||
if offset then
|
||||
coords += offset
|
||||
end
|
||||
|
||||
SetEntityCoords(activePlacementProp, coords.x, coords.y, coords.z, false, false, false, false)
|
||||
local distCheck = #(GetEntityCoords(cache.ped) - coords)
|
||||
SetEntityHeading(activePlacementProp, heading)
|
||||
|
||||
if snapToGround then
|
||||
PlaceObjectOnGroundProperly(activePlacementProp)
|
||||
end
|
||||
|
||||
if outLine then
|
||||
outLine = false
|
||||
SetEntityDrawOutline(activePlacementProp, false)
|
||||
end
|
||||
|
||||
if (allowedMats and not allowedMats[materialHash]) or distCheck >= checkDist then
|
||||
if not outLine then
|
||||
outLine = true
|
||||
SetEntityDrawOutline(activePlacementProp, true)
|
||||
end
|
||||
end
|
||||
|
||||
if IsControlJustReleased(0, 38) then
|
||||
if not outLine and (not allowedMats or allowedMats[materialHash]) and distCheck < checkDist then
|
||||
finishPlacing()
|
||||
|
||||
return coords, heading
|
||||
end
|
||||
end
|
||||
|
||||
if IsControlJustReleased(0, 73) then
|
||||
finishPlacing()
|
||||
|
||||
return nil, nil
|
||||
end
|
||||
|
||||
if IsControlJustReleased(0, 14) then
|
||||
heading = heading + 5
|
||||
if heading > 360 then heading = 0.0 end
|
||||
end
|
||||
|
||||
if IsControlJustReleased(0, 15) then
|
||||
heading = heading - 5
|
||||
if heading < 0 then
|
||||
heading = 360.0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Placeable.StopPlacing = function()
|
||||
if not activePlacementProp then return end
|
||||
finishPlacing()
|
||||
end
|
||||
|
||||
return Placeable
|
||||
-- This is derrived and slightly altered from its creator and licensed under GPL-3.0 license Author:Zoo, the original is located here https://github.com/Renewed-Scripts/Renewed-Lib/tree/main
|
||||
@@ -0,0 +1,53 @@
|
||||
Scaleform = {}
|
||||
local function SetupScaleform(scaleform, Buttons)
|
||||
local scaleform = RequestScaleformMovie(scaleform)
|
||||
local timeout = 5000
|
||||
while not HasScaleformMovieLoaded(scaleform) and timeout > 0 do
|
||||
timeout = timeout - 1
|
||||
Wait(0)
|
||||
end
|
||||
assert(timeout > 0, 'Scaleform failed to load')
|
||||
|
||||
DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 0, 0)
|
||||
for i = 1,#Buttons do
|
||||
PushScaleformMovieFunction(scaleform, Buttons[i].type)
|
||||
if Buttons[i].int then PushScaleformMovieFunctionParameterInt(Buttons[i].int) end
|
||||
if Buttons[i].keyIndex then
|
||||
if type(Buttons[i].keyIndex) == "table" then
|
||||
for _, v in pairs(Buttons[i].keyIndex) do N_0xe83a3e3557a56640(GetControlInstructionalButton(2, v, true)) end
|
||||
else
|
||||
ScaleformMovieMethodAddParamPlayerNameString(GetControlInstructionalButton(2, Buttons[i].keyIndex[1], true))
|
||||
end
|
||||
end
|
||||
if Buttons[i].name then
|
||||
BeginTextCommandScaleformString("STRING")
|
||||
AddTextComponentScaleform(Buttons[i].name)
|
||||
EndTextCommandScaleformString()
|
||||
end
|
||||
if Buttons[i].type == 'SET_BACKGROUND_COLOUR' then
|
||||
for u = 1,4 do PushScaleformMovieFunctionParameterInt(80) end
|
||||
end
|
||||
PopScaleformMovieFunctionVoid()
|
||||
end
|
||||
return scaleform
|
||||
end
|
||||
|
||||
function Scaleform.SetupInstructionalButtons(buttons)
|
||||
buttons = buttons or {
|
||||
-- {type = "CLEAR_ALL"},
|
||||
-- {type = "SET_CLEAR_SPACE", int = 200},
|
||||
-- {type = "SET_DATA_SLOT", name = config?.place_object?.name or 'Place Object:', keyIndex = config?.place_object?.key or {223}, int = 5},
|
||||
-- {type = "SET_DATA_SLOT", name = config?.cancel_placement?.name or 'Cancel Placement:', keyIndex = config?.cancel_placement?.key or {222}, int = 4},
|
||||
-- {type = "SET_DATA_SLOT", name = config?.snap_to_ground?.name or 'Snap to Ground:', keyIndex = config?.snap_to_ground?.key or {19}, int = 1},
|
||||
-- {type = "SET_DATA_SLOT", name = config?.rotate?.name or 'Rotate:', keyIndex = config?.rotate?.key or {14, 15}, int = 2},
|
||||
-- {type = "SET_DATA_SLOT", name = config?.distance?.name or 'Distance:', keyIndex = config?.distance?.key or {14,15,36}, int = 3},
|
||||
-- {type = "SET_DATA_SLOT", name = config?.toggle_placement?.name or 'Toggle Placement:', keyIndex = config?.toggle_placement?.key or {199}, int = 0},
|
||||
-- {type = "DRAW_INSTRUCTIONAL_BUTTONS"},
|
||||
-- {type = "SET_BACKGROUND_COLOUR"},
|
||||
}
|
||||
local scaleform = SetupScaleform("instructional_buttons", buttons)
|
||||
return scaleform
|
||||
end
|
||||
|
||||
exports("Scaleform", Scaleform)
|
||||
return Scaleform
|
||||
@@ -0,0 +1,291 @@
|
||||
Utility = Utility or {}
|
||||
local blipIDs = {}
|
||||
local spawnedPeds = {}
|
||||
local ActivePoints = {}
|
||||
|
||||
Utility.CreateProp = function(model, coords, heading, networked)
|
||||
if networked == nil then networked = true end
|
||||
Utility.LoadModel(model)
|
||||
if not HasModelLoaded(model) then return Prints.Error("Model Has Not Loaded") end
|
||||
local propEntity = CreateObject(model, coords.x, coords.y, coords.z, networked, false, false)
|
||||
SetEntityHeading(propEntity, heading)
|
||||
SetModelAsNoLongerNeeded(model)
|
||||
return propEntity
|
||||
end
|
||||
|
||||
Utility.CreateVehicle = function(model, coords, heading, networked)
|
||||
if networked == nil then networked = true end
|
||||
Utility.LoadModel(model)
|
||||
if not HasModelLoaded(model) then return Prints.Error("Model Has Not Loaded") end
|
||||
local vehicle = CreateVehicle(model, coords.x, coords.y, coords.z, heading, networked, false)
|
||||
SetVehicleHasBeenOwnedByPlayer(vehicle, true)
|
||||
SetVehicleNeedsToBeHotwired(vehicle, false)
|
||||
SetModelAsNoLongerNeeded(model)
|
||||
SetVehRadioStation(vehicle, "OFF")
|
||||
return vehicle, { networkid = NetworkGetNetworkIdFromEntity(vehicle) or 0, coords = GetEntityCoords(vehicle), heading = GetEntityHeading(vehicle), }
|
||||
end
|
||||
|
||||
Utility.CreatePed = function(model, coords, heading, networked, clothing)
|
||||
if networked == nil then networked = true end
|
||||
Utility.LoadModel(model)
|
||||
if not HasModelLoaded(model) then return Prints.Error("Model Has Not Loaded") end
|
||||
local spawnedEntity = CreatePed(0, model, coords.x, coords.y, coords.z, heading, networked, false)
|
||||
if clothing then
|
||||
for componentID, v in pairs(clothing) do
|
||||
SetPedComponentVariation(spawnedEntity, componentID, v[1], v[2], 0)
|
||||
end
|
||||
end
|
||||
FreezeEntityPosition(spawnedEntity, true)
|
||||
SetEntityInvincible(spawnedEntity, true)
|
||||
SetBlockingOfNonTemporaryEvents(spawnedEntity, true)
|
||||
SetModelAsNoLongerNeeded(model)
|
||||
table.insert(spawnedPeds, spawnedEntity)
|
||||
return spawnedEntity
|
||||
end
|
||||
|
||||
Utility.StartBusySpinner = function(text)
|
||||
AddTextEntry(text, text)
|
||||
BeginTextCommandBusyString(text)
|
||||
AddTextComponentSubstringPlayerName(text)
|
||||
EndTextCommandBusyString(0)
|
||||
end
|
||||
|
||||
Utility.StopBusySpinner = function()
|
||||
if BusyspinnerIsOn() then BusyspinnerOff() end
|
||||
end
|
||||
|
||||
Utility.CreateBlip = function(coords, sprite, color, scale, label, shortRange)
|
||||
local blip = AddBlipForCoord(coords.x, coords.y, coords.z)
|
||||
SetBlipSprite(blip, sprite or 8)
|
||||
SetBlipColour(blip, color or 3)
|
||||
SetBlipScale(blip, scale or 0.8)
|
||||
SetBlipAsShortRange(blip, shortRange)
|
||||
AddTextEntry(label, label)
|
||||
BeginTextCommandSetBlipName(label)
|
||||
EndTextCommandSetBlipName(blip)
|
||||
table.insert(blipIDs, blip)
|
||||
return blip
|
||||
end
|
||||
|
||||
Utility.RemoveBlip = function(blip)
|
||||
local success = false
|
||||
for i, storedBlip in ipairs(blipIDs) do
|
||||
if storedBlip == blip then
|
||||
RemoveBlip(blip)
|
||||
table.remove(blipIDs, i)
|
||||
success = true
|
||||
break
|
||||
end
|
||||
end
|
||||
return success
|
||||
end
|
||||
|
||||
Utility.LoadModel = function(model)
|
||||
if type(model) ~= 'number' then model = joaat(model) end
|
||||
if not IsModelValid(model) and not IsModelInCdimage(model) then return false end
|
||||
RequestModel(model)
|
||||
local count = 0
|
||||
while not HasModelLoaded(model) and count < 30000 do
|
||||
Wait(0)
|
||||
count = count + 1
|
||||
end
|
||||
return HasModelLoaded(model)
|
||||
end
|
||||
|
||||
Utility.RemovePed = function(entity)
|
||||
local success = false
|
||||
DeleteEntity(entity)
|
||||
for i, storedEntity in ipairs(spawnedPeds) do
|
||||
if storedEntity == entity then
|
||||
table.remove(spawnedPeds, i)
|
||||
success = true
|
||||
break
|
||||
end
|
||||
end
|
||||
return success
|
||||
end
|
||||
|
||||
Utility.NativeInputMenu = function(text, length)
|
||||
local maxLength = Math.Clamp(length, 1, 50)
|
||||
local menutText = text or 'enter text'
|
||||
AddTextEntry(menutText, menutText)
|
||||
DisplayOnscreenKeyboard(1, menutText, "", "", "", "", "", maxLength)
|
||||
while(UpdateOnscreenKeyboard() == 0) do
|
||||
DisableAllControlActions(0)
|
||||
Wait(0)
|
||||
end
|
||||
if(GetOnscreenKeyboardResult()) then
|
||||
local result = GetOnscreenKeyboardResult()
|
||||
return result
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
Utility.GetEntitySkinData = function(entity)
|
||||
local skinData = {}
|
||||
skinData.clothing = {}
|
||||
for i = 0, 11 do
|
||||
skinData.clothing[i] = {GetPedDrawableVariation(entity, i), GetPedTextureVariation(entity, i)}
|
||||
end
|
||||
return skinData
|
||||
end
|
||||
|
||||
Utility.SetEntitySkinData = function(entity, skinData)
|
||||
for i = 0, 11 do
|
||||
SetPedComponentVariation(entity, i, skinData.clothing[i][1], skinData.clothing[i][2], 0)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
Utility.NativeAlert = function(data)
|
||||
local message = data.message or 'No message provided'
|
||||
local coords = data.coords or GetEntityCoords(cache.ped)
|
||||
local job = data.job
|
||||
local scale = data.scale or 0.8
|
||||
local sprite = data.sprite or 1
|
||||
TriggerServerEvent('community_bridge:server:alert', {message = message, coords = coords, job = job, scale = scale, sprite = sprite})
|
||||
end
|
||||
|
||||
Utility.ReloadSkin = function()
|
||||
local skinData = Utility.GetEntitySkinData(cache.ped)
|
||||
Utility.SetEntitySkinData(cache.ped, skinData)
|
||||
for _, props in pairs(GetGamePool("CObject")) do
|
||||
if IsEntityAttachedToEntity(cache.ped, props) then
|
||||
SetEntityAsMissionEntity(props, true, true)
|
||||
DeleteObject(props)
|
||||
DeleteEntity(props)
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
Utility.RestoreAppearance = function(data)
|
||||
return Utility.SetEntitySkinData(cache.ped, data)
|
||||
end
|
||||
|
||||
Utility.HelpText = function(text, duration)
|
||||
AddTextEntry(text, text)
|
||||
BeginTextCommandDisplayHelp(text)
|
||||
EndTextCommandDisplayHelp(0, false, true, duration or 5000)
|
||||
end
|
||||
|
||||
Utility.NotifyText = function(text)
|
||||
AddTextEntry(text, text)
|
||||
SetNotificationTextEntry(text)
|
||||
DrawNotification(false, true)
|
||||
end
|
||||
|
||||
Utility.TeleportPlayer = function(coords, conditionFunction, afterTeleportFunction)
|
||||
if conditionFunction ~= nil then
|
||||
if not conditionFunction() then
|
||||
return
|
||||
end
|
||||
end
|
||||
DoScreenFadeOut(2500)
|
||||
Wait(2500)
|
||||
SetEntityCoords(cache.ped, coords.x, coords.y, coords.z, false, false, false, false)
|
||||
if coords.w then
|
||||
SetEntityHeading(cache.ped, coords.w)
|
||||
end
|
||||
FreezeEntityPosition(cache.ped, true)
|
||||
local count = 0
|
||||
while not HasCollisionLoadedAroundEntity(cache.ped) and count <= 30000 do
|
||||
RequestCollisionAtCoord(coords.x, coords.y, coords.z)
|
||||
Wait(0)
|
||||
count = count + 1
|
||||
end
|
||||
FreezeEntityPosition(cache.ped, false)
|
||||
DoScreenFadeIn(1000)
|
||||
if afterTeleportFunction ~= nil then
|
||||
afterTeleportFunction()
|
||||
end
|
||||
end
|
||||
|
||||
Utility.GetEntityHashFromModel = function(model)
|
||||
if type(model) ~= 'number' then model = joaat(model) end
|
||||
return model
|
||||
end
|
||||
|
||||
Utility.GetClosestPlayer = function(coords, distanceScope, includeMe)
|
||||
local players = GetActivePlayers()
|
||||
local closestPlayer = 0
|
||||
local selfPed = cache.ped
|
||||
local selfCoords = coords or GetEntityCoords(cache.ped)
|
||||
local closestDistance = distanceScope or 5
|
||||
|
||||
for _, player in ipairs(players) do
|
||||
local playerPed = GetPlayerPed(player)
|
||||
if includeMe or playerPed ~= selfPed then
|
||||
local playerCoords = GetEntityCoords(playerPed)
|
||||
local distance = #(selfCoords - playerCoords)
|
||||
if closestDistance == -1 or distance < closestDistance then
|
||||
closestPlayer = player
|
||||
closestDistance = distance
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return closestPlayer, closestDistance, GetPlayerServerId(closestPlayer)
|
||||
end
|
||||
|
||||
-- register points
|
||||
Utility.RegisterPoint = function(pointCoords, pointDistance, pointOnEnter, pointOnExit)
|
||||
local enterZone = lib.points.new({
|
||||
coords = pointCoords,
|
||||
distance = pointDistance,
|
||||
onEnter = function(self)
|
||||
pointOnEnter(self)
|
||||
end,
|
||||
onExit = function(self)
|
||||
pointOnExit(self)
|
||||
end,
|
||||
})
|
||||
local pointID = Utility.CreateUniqueId(nil, 5, nil)
|
||||
ActivePoints[pointID] = enterZone
|
||||
return enterZone, pointID
|
||||
end
|
||||
|
||||
-- Function to retrieve the enterZone using pointID
|
||||
Utility.GetPointById = function(pointID)
|
||||
return ActivePoints[pointID]
|
||||
end
|
||||
|
||||
Utility.RemovePoint = function(pointID)
|
||||
local point = ActivePoints[pointID]
|
||||
if point then
|
||||
--print("Removing point with ID " .. pointID)
|
||||
point:remove() -- Call the remove method on the point (ensure this method stops all event listeners)
|
||||
ActivePoints[pointID] = nil -- Remove from ActivePoints table
|
||||
--print("Point removed successfully.")
|
||||
return true
|
||||
else
|
||||
--print("Point with ID " .. pointID .. " not found.")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
AddEventHandler('onResourceStop', function(resource)
|
||||
if resource == GetCurrentResourceName() then
|
||||
for _, blip in pairs(blipIDs) do
|
||||
if DoesBlipExist(blip.id) then
|
||||
RemoveBlip(blip.id)
|
||||
end
|
||||
end
|
||||
for _, ped in pairs(spawnedPeds) do
|
||||
if DoesEntityExist(ped) then
|
||||
DeleteEntity(ped)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('community_bridge:client:alert', function(data)
|
||||
local blip = Utility.CreateBlip(data.coords, data.sprite, 3, data.scale, data.message, true)
|
||||
SetTimeout(40000, function()
|
||||
Utility.RemoveBlip(blip)
|
||||
end)
|
||||
end)
|
||||
|
||||
exports('Utility', Utility)
|
||||
|
||||
return Utility
|
||||
@@ -0,0 +1,458 @@
|
||||
-- Credit: https://github.com/citizenfx/lua/blob/luaglm-dev/cfx/libs/scripts/examples/dataview.lua
|
||||
local dataView = setmetatable({
|
||||
EndBig = ">",
|
||||
EndLittle = "<",
|
||||
Types = {
|
||||
Int8 = { code = "i1" },
|
||||
Uint8 = { code = "I1" },
|
||||
Int16 = { code = "i2" },
|
||||
Uint16 = { code = "I2" },
|
||||
Int32 = { code = "i4" },
|
||||
Uint32 = { code = "I4" },
|
||||
Int64 = { code = "i8" },
|
||||
Uint64 = { code = "I8" },
|
||||
Float32 = { code = "f", size = 4 }, -- a float (native size)
|
||||
Float64 = { code = "d", size = 8 }, -- a double (native size)
|
||||
|
||||
LuaInt = { code = "j" }, -- a lua_Integer
|
||||
UluaInt = { code = "J" }, -- a lua_Unsigned
|
||||
LuaNum = { code = "n" }, -- a lua_Number
|
||||
String = { code = "z", size = -1, }, -- zero terminated string
|
||||
},
|
||||
|
||||
FixedTypes = {
|
||||
String = { code = "c" }, -- a fixed-sized string with n bytes
|
||||
Int = { code = "i" }, -- a signed int with n bytes
|
||||
Uint = { code = "I" }, -- an unsigned int with n bytes
|
||||
},
|
||||
}, {
|
||||
__call = function(_, length)
|
||||
return dataView.ArrayBuffer(length)
|
||||
end
|
||||
})
|
||||
dataView.__index = dataView
|
||||
|
||||
--[[ Create an ArrayBuffer with a size in bytes --]]
|
||||
function dataView.ArrayBuffer(length)
|
||||
return setmetatable({
|
||||
blob = string.blob(length),
|
||||
length = length,
|
||||
offset = 1,
|
||||
cangrow = true,
|
||||
}, dataView)
|
||||
end
|
||||
|
||||
--[[ Wrap a non-internalized string --]]
|
||||
function dataView.Wrap(blob)
|
||||
return setmetatable({
|
||||
blob = blob,
|
||||
length = blob:len(),
|
||||
offset = 1,
|
||||
cangrow = true,
|
||||
}, dataView)
|
||||
end
|
||||
|
||||
--[[ Return the underlying bytebuffer --]]
|
||||
function dataView:Buffer() return self.blob end
|
||||
function dataView:ByteLength() return self.length end
|
||||
function dataView:ByteOffset() return self.offset end
|
||||
function dataView:SubView(offset, length)
|
||||
return setmetatable({
|
||||
blob = self.blob,
|
||||
length = length or self.length,
|
||||
offset = 1 + offset,
|
||||
cangrow = false,
|
||||
}, dataView)
|
||||
end
|
||||
|
||||
--[[ Return the Endianness format character --]]
|
||||
local function ef(big) return (big and dataView.EndBig) or dataView.EndLittle end
|
||||
|
||||
--[[ Helper function for setting fixed datatypes within a buffer --]]
|
||||
local function packblob(self, offset, value, code)
|
||||
-- If cangrow is false the dataview represents a subview, i.e., a subset
|
||||
-- of some other string view. Ensure the references are the same before
|
||||
-- updating the subview
|
||||
local packed = self.blob:blob_pack(offset, code, value)
|
||||
if self.cangrow or packed == self.blob then
|
||||
self.blob = packed
|
||||
self.length = packed:len()
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
Create the API by using dataView.Types
|
||||
--]]
|
||||
for label,datatype in pairs(dataView.Types) do
|
||||
if not datatype.size then -- cache fixed encoding size
|
||||
datatype.size = string.packsize(datatype.code)
|
||||
elseif datatype.size >= 0 and string.packsize(datatype.code) ~= datatype.size then
|
||||
local msg = "Pack size of %s (%d) does not match cached length: (%d)"
|
||||
error(msg:format(label, string.packsize(datatype.code), datatype.size))
|
||||
return nil
|
||||
end
|
||||
|
||||
dataView["Get" .. label] = function(self, offset, endian)
|
||||
offset = offset or 0
|
||||
if offset >= 0 then
|
||||
local o = self.offset + offset
|
||||
local v,_ = self.blob:blob_unpack(o, ef(endian) .. datatype.code)
|
||||
return v
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
dataView["Set" .. label] = function(self, offset, value, endian)
|
||||
if offset >= 0 and value then
|
||||
local o = self.offset + offset
|
||||
local v_size = (datatype.size < 0 and value:len()) or datatype.size
|
||||
if self.cangrow or ((o + (v_size - 1)) <= self.length) then
|
||||
if not packblob(self, o, value, ef(endian) .. datatype.code) then
|
||||
error("cannot grow subview")
|
||||
end
|
||||
else
|
||||
error("cannot grow dataview")
|
||||
end
|
||||
end
|
||||
return self
|
||||
end
|
||||
end
|
||||
|
||||
for label,datatype in pairs(dataView.FixedTypes) do
|
||||
datatype.size = -1 -- Ensure cached encoding size is invalidated
|
||||
|
||||
dataView["GetFixed" .. label] = function(self, offset, typelen, endian)
|
||||
if offset >= 0 then
|
||||
local o = self.offset + offset
|
||||
if (o + (typelen - 1)) <= self.length then
|
||||
local code = ef(endian) .. "c" .. tostring(typelen)
|
||||
local v,_ = self.blob:blob_unpack(o, code)
|
||||
return v
|
||||
end
|
||||
end
|
||||
return nil -- Out of bounds
|
||||
end
|
||||
|
||||
dataView["SetFixed" .. label] = function(self, offset, typelen, value, endian)
|
||||
if offset >= 0 and value then
|
||||
local o = self.offset + offset
|
||||
if self.cangrow or ((o + (typelen - 1)) <= self.length) then
|
||||
local code = ef(endian) .. "c" .. tostring(typelen)
|
||||
if not packblob(self, o, value, code) then
|
||||
error("cannot grow subview")
|
||||
end
|
||||
else
|
||||
error("cannot grow dataview")
|
||||
end
|
||||
end
|
||||
return self
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- CREDITS
|
||||
-- Andyyy7666: https://github.com/overextended/ox_lib/pull/453
|
||||
-- AvarianKnight: https://forum.cfx.re/t/allow-drawgizmo-to-be-used-outside-of-fxdk/5091845/8?u=demi-automatic
|
||||
local dataview = dataView
|
||||
local enableScale = false -- allow scaling mode. doesnt scale collisions and resets when physics are applied it seems
|
||||
local gizmoEnabled = false
|
||||
local currentMode = 'translate'
|
||||
local isRelative = false
|
||||
local currentEntity
|
||||
|
||||
-- FUNCTIONS
|
||||
|
||||
local function normalize(x, y, z)
|
||||
local length = math.sqrt(x * x + y * y + z * z)
|
||||
if length == 0 then
|
||||
return 0, 0, 0
|
||||
end
|
||||
return x / length, y / length, z / length
|
||||
end
|
||||
|
||||
local identityMatrix = {
|
||||
vector3(1, 0, 0),
|
||||
vector3(0, 1, 0),
|
||||
vector3(0, 0, 1)
|
||||
}
|
||||
local function makeEntityMatrix(entity)
|
||||
local f, r, u, a = GetEntityMatrix(entity)
|
||||
local view = dataview.ArrayBuffer(60)
|
||||
|
||||
view:SetFloat32(0, r[1])
|
||||
:SetFloat32(4, r[2])
|
||||
:SetFloat32(8, r[3])
|
||||
:SetFloat32(12, 0)
|
||||
:SetFloat32(16, f[1])
|
||||
:SetFloat32(20, f[2])
|
||||
:SetFloat32(24, f[3])
|
||||
:SetFloat32(28, 0)
|
||||
:SetFloat32(32, u[1])
|
||||
:SetFloat32(36, u[2])
|
||||
:SetFloat32(40, u[3])
|
||||
:SetFloat32(44, 0)
|
||||
:SetFloat32(48, a[1])
|
||||
:SetFloat32(52, a[2])
|
||||
:SetFloat32(56, a[3])
|
||||
:SetFloat32(60, 1)
|
||||
|
||||
return view
|
||||
end
|
||||
|
||||
local function applyEntityMatrix(entity, view)
|
||||
local x1, y1, z1 = view:GetFloat32(16), view:GetFloat32(20), view:GetFloat32(24)
|
||||
local x2, y2, z2 = view:GetFloat32(0), view:GetFloat32(4), view:GetFloat32(8)
|
||||
local x3, y3, z3 = view:GetFloat32(32), view:GetFloat32(36), view:GetFloat32(40)
|
||||
local tx, ty, tz = view:GetFloat32(48), view:GetFloat32(52), view:GetFloat32(56)
|
||||
|
||||
if not enableScale then
|
||||
x1, y1, z1 = normalize(x1, y1, z1)
|
||||
x2, y2, z2 = normalize(x2, y2, z2)
|
||||
x3, y3, z3 = normalize(x3, y3, z3)
|
||||
end
|
||||
|
||||
SetEntityMatrix(entity,
|
||||
x1, y1, z1,
|
||||
x2, y2, z2,
|
||||
x3, y3, z3,
|
||||
tx, ty, tz
|
||||
)
|
||||
end
|
||||
|
||||
-- LOOPS
|
||||
|
||||
function RegisterButtonHandler(button, onPressed, onReleased)
|
||||
onPressed = onPressed and type(onPressed) == 'function' and onPressed
|
||||
onReleased = onReleased and type(onReleased) == 'function' and onReleased
|
||||
DisableControlAction(0, button, true)
|
||||
local pressed = IsDisabledControlJustPressed(0, button)
|
||||
local released = IsDisabledControlJustReleased(0, button)
|
||||
return (pressed and onPressed and onPressed()) or (released and onReleased and onReleased())
|
||||
end
|
||||
|
||||
|
||||
local function gizmoLoop(entity, onConfirm, onUpdate, onCancel)
|
||||
entity = tonumber(entity)
|
||||
EnterCursorMode()
|
||||
|
||||
if IsEntityAPed(entity) then
|
||||
SetEntityAlpha(entity, 200)
|
||||
else
|
||||
SetEntityDrawOutline(entity, true)
|
||||
end
|
||||
|
||||
while gizmoEnabled and DoesEntityExist(entity) do
|
||||
Wait(0)
|
||||
|
||||
DisableControlAction(0, 24, true) -- lmb
|
||||
DisableControlAction(0, 25, true) -- rmb
|
||||
DisableControlAction(0, 140, true) -- r
|
||||
DisableControlAction(0, 245, true) --t
|
||||
DisablePlayerFiring(PlayerId(), true)
|
||||
SetEntityCollision(entity, false, false)
|
||||
FreezeEntityPosition(entity, false)
|
||||
local matrixBuffer = makeEntityMatrix(entity)
|
||||
local changed = DrawGizmo(matrixBuffer:Buffer(), 'Editor1')
|
||||
if changed then
|
||||
print(GetEntityCoords(entity))
|
||||
applyEntityMatrix(entity, matrixBuffer)
|
||||
SetEntityCoords(entity, GetEntityCoords(entity))
|
||||
end
|
||||
|
||||
if onUpdate and type(onUpdate) == 'function' then onUpdate(entity, GetEntityCoords(entity), GetEntityRotation(entity)) end
|
||||
--controles
|
||||
--frontend confirm 18 [ENTER]
|
||||
RegisterButtonHandler(191, function()
|
||||
if not gizmoEnabled then return end
|
||||
gizmoEnabled = false
|
||||
if onConfirm and type(onConfirm) == 'function' then onConfirm(entity, GetEntityCoords(entity), GetEntityRotation(entity)) end
|
||||
end)
|
||||
--frontend cancel 202 [BACKSPACE]
|
||||
RegisterButtonHandler(202, function()
|
||||
if not gizmoEnabled then return end
|
||||
gizmoEnabled = false
|
||||
if onCancel and type(onCancel) == 'function' then onCancel(entity, GetEntityCoords(entity), GetEntityRotation(entity)) end
|
||||
CreateThread(function()
|
||||
local timeout = 100
|
||||
while timeout > 0 do
|
||||
DisableFrontendThisFrame()
|
||||
timeout = timeout - 1
|
||||
Wait(1)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
--register e
|
||||
RegisterButtonHandler(38, function()
|
||||
if not gizmoEnabled then return end
|
||||
gizmoEnabled = false
|
||||
local playerPos = GetEntityCoords(PlayerPedId())
|
||||
local entityPos = GetFinalRenderedCamCoord()
|
||||
local depth = #(playerPos - entityPos) -- Vector3 distance
|
||||
PlaceableObject.Create({spawned = entity}, nil, onConfirm, onUpdate, onCancel, {depth = depth})
|
||||
end)
|
||||
|
||||
--ctrl
|
||||
RegisterButtonHandler(36, function()
|
||||
if not gizmoEnabled then return end
|
||||
LeaveCursorMode()
|
||||
end, function()
|
||||
EnterCursorMode()
|
||||
end)
|
||||
|
||||
RegisterButtonHandler(19, function()
|
||||
if not gizmoEnabled then return end
|
||||
PlaceObjectOnGroundProperly_2(currentEntity)
|
||||
end)
|
||||
FreezeEntityPosition(entity, false)
|
||||
end
|
||||
|
||||
LeaveCursorMode()
|
||||
|
||||
if DoesEntityExist(entity) then
|
||||
if IsEntityAPed(entity) then SetEntityAlpha(entity, 255) end
|
||||
SetEntityDrawOutline(entity, false)
|
||||
end
|
||||
|
||||
gizmoEnabled = false
|
||||
currentEntity = nil
|
||||
return true
|
||||
end
|
||||
|
||||
-- local function textUILoop()
|
||||
-- CreateThread(function()
|
||||
-- while gizmoEnabled do
|
||||
-- Wait(100)
|
||||
-- local scaleText = (enableScale and '[S] - Scale Mode \n') or ''
|
||||
-- lib.showTextUI(
|
||||
-- ('Current Mode: %s | %s \n'):format(currentMode, (isRelative and 'Relative') or 'World') ..
|
||||
-- '[W] - Translate Mode \n' ..
|
||||
-- '[R] - Rotate Mode \n' ..
|
||||
-- scaleText ..
|
||||
-- '[Q] - Relative/World \n' ..
|
||||
-- '[LALT] - Snap To Ground \n' ..
|
||||
-- '[ENTER] - Done Editing \n'
|
||||
-- )
|
||||
-- end
|
||||
-- lib.hideTextUI()
|
||||
-- end)
|
||||
-- end
|
||||
|
||||
-- EXPORTS
|
||||
|
||||
|
||||
local function useGizmo(entity, onConfirm, onUpdate, onCancel)
|
||||
gizmoEnabled = true
|
||||
currentEntity = entity
|
||||
-- textUILoop()
|
||||
gizmoLoop(entity, onConfirm, onUpdate, onCancel)
|
||||
|
||||
return {
|
||||
handle = entity,
|
||||
position = GetEntityCoords(entity),
|
||||
rotation = GetEntityRotation(entity)
|
||||
}
|
||||
end
|
||||
|
||||
exports("useGizmo", useGizmo)
|
||||
|
||||
Gizmo = {}
|
||||
local running = false
|
||||
function Gizmo.UseGizmo(obj, onConfirm, onUpdate, onCancel)
|
||||
if running then return end
|
||||
running = true
|
||||
|
||||
--instructional buttons
|
||||
local scaleform = Scaleform.SetupInstructionalButtons({
|
||||
{type = "CLEAR_ALL"},
|
||||
{type = "SET_CLEAR_SPACE", int = 200},
|
||||
{type = "SET_DATA_SLOT", name = 'Translate:', keyIndex = {245}, int = 1},
|
||||
{type = "SET_DATA_SLOT", name = 'Scale:', keyIndex = {33}, int = 2},
|
||||
{type = "SET_DATA_SLOT", name = 'Rotate:', keyIndex = {45}, int = 3},
|
||||
{type = "SET_DATA_SLOT", name = 'Snap to Ground:', keyIndex = {19}, int = 4},
|
||||
{type = "SET_DATA_SLOT", name = 'Toggle Camera:', keyIndex = {36}, int = 5},
|
||||
{type = "SET_DATA_SLOT", name = 'Cancel Placement:', keyIndex = {202}, int = 6},
|
||||
{type = "SET_DATA_SLOT", name = 'Toggle Gizmo:', keyIndex = {38}, int = 7},
|
||||
{type = "DRAW_INSTRUCTIONAL_BUTTONS"},
|
||||
{type = "SET_BACKGROUND_COLOUR"},
|
||||
})
|
||||
local quit = false
|
||||
CreateThread(function()
|
||||
while not quit do
|
||||
DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255, 0)
|
||||
Wait(0)
|
||||
end
|
||||
running = false
|
||||
end)
|
||||
|
||||
quit = useGizmo(obj, onConfirm, onUpdate, onCancel)
|
||||
running = false
|
||||
end
|
||||
exports("UseGizmo", Gizmo.UseGizmo)
|
||||
|
||||
|
||||
--got rid of the cancer
|
||||
-- lib.addKeybind({
|
||||
-- name = '_gizmoLocal',
|
||||
-- description = 'toggle gizmo to be local to the entity instead of world',
|
||||
-- defaultKey = 'Q',
|
||||
-- onPressed = function(self)
|
||||
-- if not gizmoEnabled then return end
|
||||
-- isRelative = not isRelative
|
||||
-- ExecuteCommand('+gizmoLocal')
|
||||
-- end,
|
||||
-- onReleased = function (self)
|
||||
-- ExecuteCommand('-gizmoLocal')
|
||||
-- end
|
||||
-- })
|
||||
|
||||
-- lib.addKeybind({
|
||||
-- name = 'gizmoclose',
|
||||
-- description = 'close gizmo',
|
||||
-- defaultKey = 'RETURN',
|
||||
-- onPressed = function(self)
|
||||
-- if not gizmoEnabled then return end
|
||||
-- gizmoEnabled = false
|
||||
-- end,
|
||||
-- })
|
||||
|
||||
-- lib.addKeybind({
|
||||
-- name = 'gizmoSnapToGround',
|
||||
-- description = 'snap current gizmo object to floor/surface',
|
||||
-- defaultKey = 'LMENU',
|
||||
-- onPressed = function(self)
|
||||
-- if not gizmoEnabled then return end
|
||||
-- PlaceObjectOnGroundProperly_2(currentEntity)
|
||||
-- end,
|
||||
-- })
|
||||
|
||||
-- if enableScale then
|
||||
-- lib.addKeybind({
|
||||
-- name = '_gizmoScale',
|
||||
-- description = 'Sets mode for the gizmo to scale',
|
||||
-- defaultKey = 'S',
|
||||
-- onPressed = function(self)
|
||||
-- if not gizmoEnabled then return end
|
||||
-- currentMode = 'Scale'
|
||||
-- ExecuteCommand('+gizmoScale')
|
||||
-- end,
|
||||
-- onReleased = function (self)
|
||||
-- ExecuteCommand('-gizmoScale')
|
||||
-- end
|
||||
-- })
|
||||
-- end
|
||||
|
||||
|
||||
--onreousrcestop
|
||||
|
||||
AddEventHandler('onResourceStop', function(resource)
|
||||
if resource == GetCurrentResourceName() then
|
||||
if not gizmoEnabled then return end
|
||||
gizmoEnabled = false
|
||||
LeaveCursorMode()
|
||||
end
|
||||
end)
|
||||
|
||||
return Gizmo
|
||||
@@ -0,0 +1,168 @@
|
||||
Scaleform = Scaleform or Require("client/scaleform.lua")
|
||||
Utility = Utility or Require("client/utility.lua")
|
||||
Gizmo = Gizmo or Require("client/gizmo.lua")
|
||||
|
||||
PlaceableObject = PlaceableObject or {}
|
||||
local data = {
|
||||
entity = nil,
|
||||
placing = false,
|
||||
}
|
||||
|
||||
function PlaceableObject.Eyetrace(depth, disableSphere)
|
||||
local screenX = GetDisabledControlNormal(0, 239)
|
||||
local screenY = GetDisabledControlNormal(0, 240)
|
||||
|
||||
local world, normal = GetWorldCoordFromScreenCoord(screenX, screenY)
|
||||
local playerPos = GetEntityCoords(PlayerPedId())
|
||||
local target = playerPos + normal * depth
|
||||
if not disableSphere then
|
||||
DrawSphere(target.x, target.y, target.z, 0.5, 255, 0, 0, 0.5)
|
||||
end
|
||||
return target
|
||||
end
|
||||
|
||||
-- Creates a placeable object in the game world.
|
||||
-- @param model (string) The model of the object to create.
|
||||
-- @param onConfirm (function) [optional] The callback function to execute when the object is confirmed.
|
||||
-- @param onUpdate (function) [optional] The callback function to execute when the object is moved.
|
||||
-- @param onCancel (function) [optional] The callback function to execute when the object is canceled.
|
||||
-- @param settings (table) [optional] Additional settings for the placeable object.
|
||||
-- - depthMin (number) The minimum depth for the object placement. Default is 2.0.
|
||||
-- - depthMax (number) The maximum depth for the object placement. Default is 10.0.
|
||||
-- - rotationStep (number) The rotation step for the object. Default is 15.0.
|
||||
-- - depthStep (number) The depth step for the object. Default is 1.0.
|
||||
function PlaceableObject.Create(data, model, onConfirm, onUpdate, onCancel, settings, config)
|
||||
local settings = settings or {}
|
||||
local depthMin = settings.depthMin or 2.0
|
||||
depthMax = settings.depthMax or 10.0
|
||||
rotationStep = settings.rotationStep or 15.0
|
||||
depthStep = settings.depthStep or 1.0
|
||||
local depth = settings.depth or 10.0
|
||||
print(depth)
|
||||
data.placing = true
|
||||
data.paused = false
|
||||
local initialPos = nil
|
||||
local placeOnGround = true
|
||||
|
||||
--scaleform
|
||||
local scaleform = Scaleform.SetupInstructionalButtons({
|
||||
{type = "CLEAR_ALL"},
|
||||
{type = "SET_CLEAR_SPACE", int = 200},
|
||||
{type = "SET_DATA_SLOT", name = config?.place_object?.name or 'Place Object:', keyIndex = config?.place_object?.key or {223}, int = 5},
|
||||
{type = "SET_DATA_SLOT", name = config?.cancel_placement?.name or 'Cancel Placement:', keyIndex = config?.cancel_placement?.key or {222}, int = 4},
|
||||
{type = "SET_DATA_SLOT", name = config?.snap_to_ground?.name or 'Snap to Ground:', keyIndex = config?.snap_to_ground?.key or {19}, int = 1},
|
||||
{type = "SET_DATA_SLOT", name = config?.rotate?.name or 'Rotate:', keyIndex = config?.rotate?.key or {14, 15}, int = 2},
|
||||
{type = "SET_DATA_SLOT", name = config?.distance?.name or 'Distance:', keyIndex = config?.distance?.key or {14,15,36}, int = 3},
|
||||
{type = "SET_DATA_SLOT", name = config?.toggle_placement?.name or 'Toggle Placement:', keyIndex = config?.toggle_placement?.key or {199}, int = 0},
|
||||
{type = "SET_DATA_SLOT", name = config?.gizmo?.name or 'Toggle Gizmo:', keyIndex = config?.gizmo?.key or {38}, int = 6},
|
||||
{type = "DRAW_INSTRUCTIONAL_BUTTONS"},
|
||||
{type = "SET_BACKGROUND_COLOUR"},
|
||||
})
|
||||
CreateThread(function()
|
||||
local heading = -GetEntityHeading(PlayerPedId())
|
||||
|
||||
local pos = PlaceableObject.Eyetrace(depth)
|
||||
if not data.spawned and model then
|
||||
--get player heading
|
||||
local obj = Utility.CreateProp(model, pos, vector3(0, 0, heading), nil)
|
||||
data.spawned = obj
|
||||
end
|
||||
assert(data.spawned, "Failed to create object")
|
||||
SetEntityCollision(data.spawned, false, false)
|
||||
SetEntityAlpha(data.spawned, 150, false)
|
||||
|
||||
SetPedConfigFlag(PlayerPedId(), 146, true)
|
||||
SetCanClimbOnEntity(data.spawned, false)
|
||||
SetEntityCompletelyDisableCollision(data.spawned, true, false)
|
||||
SetEntityNoCollisionEntity(PlayerPedId(), data.spawned, false)
|
||||
|
||||
while data.placing do
|
||||
if data.paused then goto continue end
|
||||
DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255, 0)
|
||||
DisableControlAction(0, 24, true) -- Attack
|
||||
DisableControlAction(0, 25, true) -- Aim
|
||||
DisableControlAction(0, 36, true) -- INPUT_DUCK.
|
||||
|
||||
if IsControlJustPressed(0, 223) then -- left click
|
||||
if onConfirm and type(onConfirm) == 'function' then onConfirm(data.spawned, pos, heading) end
|
||||
data.placing = false
|
||||
end
|
||||
|
||||
if IsControlJustPressed(0, 222) then -- right click
|
||||
data.placing = false
|
||||
if onCancel and type(onCancel) == 'function' then
|
||||
onCancel(data.spawned, pos, heading)
|
||||
else
|
||||
DeleteEntity(data.spawned)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if IsControlPressed(0,19) then
|
||||
placeOnGround = not (placeOnGround or false)
|
||||
end
|
||||
|
||||
if IsControlJustPressed(0, 38) then -- TAB key to switch to gizmo
|
||||
data.placing = false
|
||||
return Gizmo.UseGizmo(data.spawned, onConfirm, onUpdate, onCancel)
|
||||
end
|
||||
|
||||
if IsControlPressed(0,224) then -- left ctrl
|
||||
if IsControlJustPressed(0, 261) then -- scroll up
|
||||
depth = depth + depthStep
|
||||
if depth > depthMax then
|
||||
depth = depthMax
|
||||
end
|
||||
end
|
||||
|
||||
if IsControlJustPressed(0, 262) then -- scroll down
|
||||
depth = depth - depthStep
|
||||
if depth < depthMin then
|
||||
depth = depthMin
|
||||
end
|
||||
end
|
||||
else
|
||||
if IsControlJustPressed(0, 261) then -- scroll up
|
||||
heading = heading + rotationStep
|
||||
if heading > 360 then
|
||||
heading = 0
|
||||
end
|
||||
end
|
||||
if IsControlJustPressed(0, 262) then -- scroll down
|
||||
heading = heading - rotationStep
|
||||
if heading < 0 then
|
||||
heading = 360
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
pos = PlaceableObject.Eyetrace(depth)
|
||||
if data.spawned then
|
||||
SetEntityCoords(data.spawned, pos.x, pos.y, pos.z)
|
||||
SetEntityHeading(data.spawned, heading)
|
||||
if placeOnGround then
|
||||
PlaceObjectOnGroundProperly(data.spawned)
|
||||
pos = GetEntityCoords(data.spawned)
|
||||
end
|
||||
end
|
||||
if onUpdate and type(onUpdate) == 'function' then onUpdate(data.spawned, pos, heading) end
|
||||
::continue::
|
||||
if IsControlJustPressed(0, 199) then -- home
|
||||
data.paused = not data.paused
|
||||
end
|
||||
Wait(1)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
|
||||
RegisterCommand("testers", function()
|
||||
PlaceableObject.Create({}, "prop_beachflag_01", function(entity, pos, heading)
|
||||
|
||||
end, function(entity, pos, heading)
|
||||
|
||||
end, function(entity, pos, heading)
|
||||
|
||||
end)
|
||||
end)
|
||||
Reference in new issue
Block a user