объединение clickwarp в скрипт

sadasdasdasdasdasd

Участник
Автор темы
82
16
Версия MoonLoader
Другое
хочу поместить clickwarp в свой скрипт, но что то пошло не так, при нажатии на checkbox, скрипт крашит и вылезает ошибка на 90 строке, не могу разобраться, подскажите пожалуйста
вот код:

Lua:
script_name('ShishaHub')
script_author('Shisha')


require "lib.moonloader"
local keys = require ('vkeys')
local imgui = require('imgui')
local encoding = require('encoding')
encoding.default = 'CP1251'
u8 = encoding.UTF8
local huy = require("samp.events")
local piska = 0


local oX = 250
local oY = 430


local main_window_state = imgui.ImBool(false)
local text_buffer_name = imgui.ImBuffer(256)

local stime = imgui.ImBool(false)
local abmrun = imgui.ImBool(false)
local clwarp = imgui.ImBool(false)

bike = {[481] = true, [509] = true, [510] = true}
moto = {[448] = true, [461] = true, [462] = true, [463] = true, [468] = true, [471] = true, [521] = true, [522] = true, [523] = true, [581] = true, [586] = true}


function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

    sampRegisterChatCommand("mmenu", cmd_imgui)

    imgui.Process = false

    while true do
        wait(0)
        if main_window_state.v == false then
            imgui.Process = false
        end
        if stime.v then
            sampTextdrawCreate(221, "Server_time:", oX, oY)
            sampTextdrawSetLetterSizeAndColor(221, 0.3, 1.7, 0xFFe1e1e1)
            sampTextdrawSetOutlineColor(221, 0.5, 0xFF000000)
            sampTextdrawSetAlign(221, 1)
            sampTextdrawSetStyle(221, 2)
            timer = os.time() + piska
            sampTextdrawCreate(222, os.date("%H:%M:%S", timer), oX + 90, oY)
            sampTextdrawSetLetterSizeAndColor(222, 0.3, 1.7, 0xFFff6347)
            sampTextdrawSetOutlineColor(222, 0.5, 0xFF000000)
            sampTextdrawSetAlign(222, 1)
            sampTextdrawSetStyle(222, 2)
            wait(500)
            textDrawIsWorking = true
        else
            if textDrawIsWorking then
                sampTextdrawDelete(221)
                sampTextdrawDelete(222)
                textDrawIsWorking = false
            end
        end
        if abmrun.v then
            if isCharOnAnyBike(playerPed) and isKeyCheckAvailable() and isKeyDown(0xA0) then    -- onBike&onMoto SpeedUP [[LSHIFT]] --
                if bike[getCarModel(storeCarCharIsInNoSave(playerPed))] then
                    setGameKeyState(16, 255)
                    wait(10)
                    setGameKeyState(16, 0)
                elseif moto[getCarModel(storeCarCharIsInNoSave(playerPed))] then
                    setGameKeyState(1, -128)
                    wait(10)
                    setGameKeyState(1, 0)
                end
            end
            
            if isCharOnFoot(playerPed) and isKeyDown(0x31) and isKeyCheckAvailable() then -- onFoot&inWater SpeedUP [[1]] --
                setGameKeyState(16, 256)
                wait(10)
                setGameKeyState(16, 0)
            elseif isCharInWater(playerPed) and isKeyDown(0x31) and isKeyCheckAvailable() then
                setGameKeyState(16, 256)
                wait(10)
                setGameKeyState(16, 0)
            end
        end
        if clwarp.v then
            local sw, sh = getScreenResolution()
            -- is cursor in game window bounds?
            if sx >= 0 and sy >= 0 and sx < sw and sy < sh then
              local posX, posY, posZ = convertScreenCoordsToWorld3D(sx, sy, 700.0)
              local camX, camY, camZ = getActiveCameraCoordinates()
              -- search for the collision point
              local result, colpoint = processLineOfSight(camX, camY, camZ, posX, posY, posZ, true, true, false, true, false, false, false)
              if result and colpoint.entity ~= 0 then
                local normal = colpoint.normal
                local pos = Vector3D(colpoint.pos[1], colpoint.pos[2], colpoint.pos[3]) - (Vector3D(normal[1], normal[2], normal[3]) * 0.1)
                local zOffset = 300
                if normal[3] >= 0.5 then zOffset = 1 end
                -- search for the ground position vertically down
                local result, colpoint2 = processLineOfSight(pos.x, pos.y, pos.z + zOffset, pos.x, pos.y, pos.z - 0.3,
                  true, true, false, true, false, false, false)
                if result then
                  pos = Vector3D(colpoint2.pos[1], colpoint2.pos[2], colpoint2.pos[3] + 1)
      
                  local curX, curY, curZ  = getCharCoordinates(playerPed)
                  local dist              = getDistanceBetweenCoords3d(curX, curY, curZ, pos.x, pos.y, pos.z)
                  local hoffs             = renderGetFontDrawHeight(font)
      
                  sy = sy - 2
                  sx = sx - 2
                  renderFontDrawText(font, string.format("%0.2fm", dist), sx, sy - hoffs, 0xEEEEEEEE)
      
                  local tpIntoCar = nil
                  if colpoint.entityType == 2 then
                    local car = getVehiclePointerHandle(colpoint.entity)
                    if doesVehicleExist(car) and (not isCharInAnyCar(playerPed) or storeCarCharIsInNoSave(playerPed) ~= car) then
                      displayVehicleName(sx, sy - hoffs * 2, getNameOfVehicleModel(getCarModel(car)))
                      local color = 0xAAFFFFFF
                      if isKeyDown(VK_RBUTTON) then
                        tpIntoCar = car
                        color = 0xFFFFFFFF
                      end
                      renderFontDrawText(font2, "Hold right mouse button to teleport into the car", sx, sy - hoffs * 3, color)
                    end
                  end
      
                  createPointMarker(pos.x, pos.y, pos.z)
      
                  -- teleport!
                  if isKeyDown(keyApply) then
                    if tpIntoCar then
                      if not jumpIntoCar(tpIntoCar) then
                        -- teleport to the car if there is no free seats
                        teleportPlayer(pos.x, pos.y, pos.z)
                      end
                    else
                      if isCharInAnyCar(playerPed) then
                        local norm = Vector3D(colpoint.normal[1], colpoint.normal[2], 0)
                        local norm2 = Vector3D(colpoint2.normal[1], colpoint2.normal[2], colpoint2.normal[3])
                        rotateCarAroundUpAxis(storeCarCharIsInNoSave(playerPed), norm2)
                        pos = pos - norm * 1.8
                        pos.z = pos.z - 0.8
                      end
                      teleportPlayer(pos.x, pos.y, pos.z)
                    end
                    removePointMarker()
      
                    while isKeyDown(keyApply) do wait(0) end
                    showCursor(false)
                  end
                end
              end
            end
        end
        wait(0)
        removePointMarker()
        end
end



function cmd_imgui(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end



function imgui.OnDrawFrame()
    imgui.Begin("ShishaHub", main_window_state)
    imgui.Text("Всем ку",text_buffer_name)
    imgui.Checkbox("Sever time by KALASHNIKOV", stime)
    imgui.Checkbox("AutoBikeMoto", abmrun)
    imgui.Checkbox("clickwarp", clwarp)
    imgui.End()
end

function isKeyCheckAvailable()
    if abmrun.v then
        if not isSampLoaded() then
            return true
        end
        if not isSampfuncsLoaded() then
            return not sampIsChatInputActive() and not sampIsDialogActive()
        end
        return not sampIsChatInputActive() and not sampIsDialogActive() and not isSampfuncsConsoleActive()
    end
end

function huy.onShowDialog(dialogId,style,title,button1,button2,text)
    if stime.v then
        if string.match(text, "Текущее время") then
            chislo, mesyac, god = string.match(text, "Сегодняшняя дата:     {2EA42E}(%d+):(%d+):(%d+)")
            chas, minuti, sekundi = string.match(text, "Текущее время:     {345690}(%d+):(%d+):(%d+)")
            datetime = {year = god,month = mesyac,day = chislo,hour = chas,min = minuti,sec = sekundi}
            piska = tostring(os.time(datetime)) - os.time()
        end
    end
end

function initializeRender()
    if clwarp.v then
        font = renderCreateFont("Tahoma", 10, FCR_BOLD + FCR_BORDER)
        font2 = renderCreateFont("Arial", 8, FCR_ITALICS + FCR_BORDER)
    end
end

function rotateCarAroundUpAxis(car, vec)
    if clwarp.v then
        local mat = Matrix3X3(getVehicleRotationMatrix(car))
        local rotAxis = Vector3D(mat.up:get())
        vec:normalize()
        rotAxis:normalize()
        local theta = math.acos(rotAxis:dotProduct(vec))
        if theta ~= 0 then
            rotAxis:crossProduct(vec)
            rotAxis:normalize()
            rotAxis:zeroNearZero()
            mat = mat:rotate(rotAxis, -theta)
        end
        setVehicleRotationMatrix(car, mat:get())
        end
    end

function readFloatArray(ptr, idx)
    if clwarp.v then
        return representIntAsFloat(readMemory(ptr + idx * 4, 4, false))
    end
end

function writeFloatArray(ptr, idx, value)
    if clwarp.v then
        writeMemory(ptr + idx * 4, 4, representFloatAsInt(value), false)
    end
end

function getVehicleRotationMatrix(car)
    if clwarp.v then
        local entityPtr = getCarPointer(car)
        if entityPtr ~= 0 then
            local mat = readMemory(entityPtr + 0x14, 4, false)
            if mat ~= 0 then
            local rx, ry, rz, fx, fy, fz, ux, uy, uz
            rx = readFloatArray(mat, 0)
            ry = readFloatArray(mat, 1)
            rz = readFloatArray(mat, 2)

            fx = readFloatArray(mat, 4)
            fy = readFloatArray(mat, 5)
            fz = readFloatArray(mat, 6)

            ux = readFloatArray(mat, 8)
            uy = readFloatArray(mat, 9)
            uz = readFloatArray(mat, 10)
            return rx, ry, rz, fx, fy, fz, ux, uy, uz
            end
        end
    end
end

function setVehicleRotationMatrix(car, rx, ry, rz, fx, fy, fz, ux, uy, uz)
    if clwarp.v then
        local entityPtr = getCarPointer(car)
        if entityPtr ~= 0 then
            local mat = readMemory(entityPtr + 0x14, 4, false)
            if mat ~= 0 then
            writeFloatArray(mat, 0, rx)
            writeFloatArray(mat, 1, ry)
            writeFloatArray(mat, 2, rz)

            writeFloatArray(mat, 4, fx)
            writeFloatArray(mat, 5, fy)
            writeFloatArray(mat, 6, fz)

            writeFloatArray(mat, 8, ux)
            writeFloatArray(mat, 9, uy)
            writeFloatArray(mat, 10, uz)
            end
        end
        end
end

function displayVehicleName(x, y, gxt)
    if clwarp.v then
        x, y = convertWindowScreenCoordsToGameScreenCoords(x, y)
        useRenderCommands(true)
        setTextWrapx(640.0)
        setTextProportional(true)
        setTextJustify(false)
        setTextScale(0.33, 0.8)
        setTextDropshadow(0, 0, 0, 0, 0)
        setTextColour(255, 255, 255, 230)
        setTextEdge(1, 0, 0, 0, 100)
        setTextFont(1)
        displayText(x, y, gxt)
    end
end

function createPointMarker(x, y, z)
    if clwarp.v then
        pointMarker = createUser3dMarker(x, y, z + 0.3, 4)
    end
end

function removePointMarker()
    if clwarp.v then
        if pointMarker then
            removeUser3dMarker(pointMarker)
            pointMarker = nil
        end
    end
end

function getCarFreeSeat(car)
    if clwarp.v then
        if doesCharExist(getDriverOfCar(car)) then
            local maxPassengers = getMaximumNumberOfPassengers(car)
            for i = 0, maxPassengers do
            if isCarPassengerSeatFree(car, i) then
                return i + 1
            end
            end
            return nil -- no free seats
        else
            return 0 -- driver seat
        end
    end
end

function jumpIntoCar(car)
    if clwarp.v then
        local seat = getCarFreeSeat(car)
        if not seat then return false end                         -- no free seats
        if seat == 0 then warpCharIntoCar(playerPed, car)         -- driver seat
        else warpCharIntoCarAsPassenger(playerPed, car, seat - 1) -- passenger seat
        end
        restoreCameraJumpcut()
        return true
        end
    end

function teleportPlayer(x, y, z)
    if clwarp.v then
        if isCharInAnyCar(playerPed) then
            setCharCoordinates(playerPed, x, y, z)
        end
        setCharCoordinatesDontResetAnim(playerPed, x, y, z)
        end
    end


function setCharCoordinatesDontResetAnim(char, x, y, z)
    if clwarp.v then
        if doesCharExist(char) then
            local ptr = getCharPointer(char)
            setEntityCoordinates(ptr, x, y, z)
        end
    end
end

function setEntityCoordinates(entityPtr, x, y, z)
    if clwarp.v then
        if entityPtr ~= 0 then
            local matrixPtr = readMemory(entityPtr + 0x14, 4, false)
            if matrixPtr ~= 0 then
            local posPtr = matrixPtr + 0x30
            writeMemory(posPtr + 0, 4, representFloatAsInt(x), false) -- X
            writeMemory(posPtr + 4, 4, representFloatAsInt(y), false) -- Y
            writeMemory(posPtr + 8, 4, representFloatAsInt(z), false) -- Z
            end
    end
end

function showCursor(toggle)
    if clwarp.v then
        if toggle then
            sampSetCursorMode(CMODE_LOCKCAM)
        else
            sampToggleCursor(false)
        end
        cursorEnabled = toggle
        end
    end
end
 

sadasdasdasdasdasd

Участник
Автор темы
82
16
попробуй добавить перед 90 строкой:
Lua:
local sx, sy = getCursorPos()
ошибка на 90 строке не вылезает, но вылезает варнинг и крашит скрипт, в консоли:

Код:
[ML] (error) ShishaHub: cannot resume non-suspended coroutine
stack traceback:
    [C]: in function 'renderGetFontDrawHeight'
    C:\GTA 140K BY DAPO SHOW\moonloader\yaMyzhikHub.lua:108: in function <C:\GTA 140K BY DAPO SHOW\moonloader\yaMyzhikHub.lua:30>
[ML] (error) ShishaHub: Script died due to an error. (0F2A9AC4)
 

sadasdasdasdasdasd

Участник
Автор темы
82
16
При нажатии на checkbox появляется маркер кликварпа (без нажатия на колёсик), и при попытки нажать лкм, ничего не просходит

Lua:
script_name('ShishaHub')
script_author('Shisha')


require "lib.moonloader"
local keys = require ('vkeys')
local imgui = require('imgui')
local encoding = require('encoding')
encoding.default = 'CP1251'
u8 = encoding.UTF8
local huy = require("samp.events")
local piska = 0
local font = renderCreateFont("tahoma", 12)


local oX = 250
local oY = 430


local main_window_state = imgui.ImBool(false)
local text_buffer_name = imgui.ImBuffer(256)

local stime = imgui.ImBool(false)
local abmrun = imgui.ImBool(false)
local clwarp = imgui.ImBool(false)

bike = {[481] = true, [509] = true, [510] = true}
moto = {[448] = true, [461] = true, [462] = true, [463] = true, [468] = true, [471] = true, [521] = true, [522] = true, [523] = true, [581] = true, [586] = true}


function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

    sampRegisterChatCommand("mmenu", cmd_imgui)

    imgui.Process = false

    while true do
        wait(0)
        if main_window_state.v == false then
            imgui.Process = false
        end
        if stime.v then
            sampTextdrawCreate(221, "Server_time:", oX, oY)
            sampTextdrawSetLetterSizeAndColor(221, 0.3, 1.7, 0xFFe1e1e1)
            sampTextdrawSetOutlineColor(221, 0.5, 0xFF000000)
            sampTextdrawSetAlign(221, 1)
            sampTextdrawSetStyle(221, 2)
            timer = os.time() + piska
            sampTextdrawCreate(222, os.date("%H:%M:%S", timer), oX + 90, oY)
            sampTextdrawSetLetterSizeAndColor(222, 0.3, 1.7, 0xFFff6347)
            sampTextdrawSetOutlineColor(222, 0.5, 0xFF000000)
            sampTextdrawSetAlign(222, 1)
            sampTextdrawSetStyle(222, 2)
            wait(500)
            textDrawIsWorking = true
        else
            if textDrawIsWorking then
                sampTextdrawDelete(221)
                sampTextdrawDelete(222)
                textDrawIsWorking = false
            end
        end
        if abmrun.v then
            if isCharOnAnyBike(playerPed) and isKeyCheckAvailable() and isKeyDown(0xA0) then    -- onBike&onMoto SpeedUP [[LSHIFT]] --
                if bike[getCarModel(storeCarCharIsInNoSave(playerPed))] then
                    setGameKeyState(16, 255)
                    wait(10)
                    setGameKeyState(16, 0)
                elseif moto[getCarModel(storeCarCharIsInNoSave(playerPed))] then
                    setGameKeyState(1, -128)
                    wait(10)
                    setGameKeyState(1, 0)
                end
            end
            
            if isCharOnFoot(playerPed) and isKeyDown(0x31) and isKeyCheckAvailable() then -- onFoot&inWater SpeedUP [[1]] --
                setGameKeyState(16, 256)
                wait(10)
                setGameKeyState(16, 0)
            elseif isCharInWater(playerPed) and isKeyDown(0x31) and isKeyCheckAvailable() then
                setGameKeyState(16, 256)
                wait(10)
                setGameKeyState(16, 0)
            end
        end
        if clwarp.v then
            local sw, sh = getScreenResolution()
            local sx, sy = getCursorPos()
            if sx >= 0 and sy >= 0 and sx < sw and sy < sh then
              local posX, posY, posZ = convertScreenCoordsToWorld3D(sx, sy, 700.0)
              local camX, camY, camZ = getActiveCameraCoordinates()
              -- search for the collision point
              local result, colpoint = processLineOfSight(camX, camY, camZ, posX, posY, posZ, true, true, false, true, false, false, false)
              if result and colpoint.entity ~= 0 then
                local normal = colpoint.normal
                local pos = Vector3D(colpoint.pos[1], colpoint.pos[2], colpoint.pos[3]) - (Vector3D(normal[1], normal[2], normal[3]) * 0.1)
                local zOffset = 300
                if normal[3] >= 0.5 then zOffset = 1 end
                -- search for the ground position vertically down
                local result, colpoint2 = processLineOfSight(pos.x, pos.y, pos.z + zOffset, pos.x, pos.y, pos.z - 0.3,
                  true, true, false, true, false, false, false)
                if result then
                  pos = Vector3D(colpoint2.pos[1], colpoint2.pos[2], colpoint2.pos[3] + 1)
      
                  local curX, curY, curZ  = getCharCoordinates(playerPed)
                  local dist              = getDistanceBetweenCoords3d(curX, curY, curZ, pos.x, pos.y, pos.z)
                  local hoffs             = renderGetFontDrawHeight(font)
      
                  sy = sy - 2
                  sx = sx - 2
                  renderFontDrawText(font, string.format("%0.2fm", dist), sx, sy - hoffs, 0xEEEEEEEE)
      
                  local tpIntoCar = nil
                  if colpoint.entityType == 2 then
                    local car = getVehiclePointerHandle(colpoint.entity)
                    if doesVehicleExist(car) and (not isCharInAnyCar(playerPed) or storeCarCharIsInNoSave(playerPed) ~= car) then
                      displayVehicleName(sx, sy - hoffs * 2, getNameOfVehicleModel(getCarModel(car)))
                      local color = 0xAAFFFFFF
                      if isKeyDown(VK_RBUTTON) then
                        tpIntoCar = car
                        color = 0xFFFFFFFF
                      end
                      renderFontDrawText(font2, "Hold right mouse button to teleport into the car", sx, sy - hoffs * 3, color)
                    end
                  end
      
                  createPointMarker(pos.x, pos.y, pos.z)
      
                  -- teleport!
                  if isKeyDown(keyApply) then
                    if tpIntoCar then
                      if not jumpIntoCar(tpIntoCar) then
                        -- teleport to the car if there is no free seats
                        teleportPlayer(pos.x, pos.y, pos.z)
                      end
                    else
                      if isCharInAnyCar(playerPed) then
                        local norm = Vector3D(colpoint.normal[1], colpoint.normal[2], 0)
                        local norm2 = Vector3D(colpoint2.normal[1], colpoint2.normal[2], colpoint2.normal[3])
                        rotateCarAroundUpAxis(storeCarCharIsInNoSave(playerPed), norm2)
                        pos = pos - norm * 1.8
                        pos.z = pos.z - 0.8
                      end
                      teleportPlayer(pos.x, pos.y, pos.z)
                    end
                    removePointMarker()
      
                    while isKeyDown(keyApply) do wait(0) end
                    showCursor(false)
                  end
                end
              end
            end
        end
        wait(0)
        removePointMarker()
        end
end



function cmd_imgui(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end



function imgui.OnDrawFrame()
    imgui.Begin("ShishaHub", main_window_state)
    imgui.Text("Всем ку",text_buffer_name)
    imgui.Checkbox("Sever time by KALASHNIKOV", stime)
    imgui.Checkbox("AutoBikeMoto", abmrun)
    imgui.Checkbox("clickwarp", clwarp)
    imgui.End()
end

function isKeyCheckAvailable()
    if abmrun.v then
        if not isSampLoaded() then
            return true
        end
        if not isSampfuncsLoaded() then
            return not sampIsChatInputActive() and not sampIsDialogActive()
        end
        return not sampIsChatInputActive() and not sampIsDialogActive() and not isSampfuncsConsoleActive()
    end
end

function huy.onShowDialog(dialogId,style,title,button1,button2,text)
    if stime.v then
        if string.match(text, "Текущее время") then
            chislo, mesyac, god = string.match(text, "Сегодняшняя дата:     {2EA42E}(%d+):(%d+):(%d+)")
            chas, minuti, sekundi = string.match(text, "Текущее время:     {345690}(%d+):(%d+):(%d+)")
            datetime = {year = god,month = mesyac,day = chislo,hour = chas,min = minuti,sec = sekundi}
            piska = tostring(os.time(datetime)) - os.time()
        end
    end
end

function initializeRender()
    if clwarp.v then
        font = renderCreateFont("Tahoma", 10, FCR_BOLD + FCR_BORDER)
        font2 = renderCreateFont("Arial", 8, FCR_ITALICS + FCR_BORDER)
    end
end

function rotateCarAroundUpAxis(car, vec)
    if clwarp.v then
        local mat = Matrix3X3(getVehicleRotationMatrix(car))
        local rotAxis = Vector3D(mat.up:get())
        vec:normalize()
        rotAxis:normalize()
        local theta = math.acos(rotAxis:dotProduct(vec))
        if theta ~= 0 then
            rotAxis:crossProduct(vec)
            rotAxis:normalize()
            rotAxis:zeroNearZero()
            mat = mat:rotate(rotAxis, -theta)
        end
        setVehicleRotationMatrix(car, mat:get())
        end
    end

function readFloatArray(ptr, idx)
    if clwarp.v then
        return representIntAsFloat(readMemory(ptr + idx * 4, 4, false))
    end
end

function writeFloatArray(ptr, idx, value)
    if clwarp.v then
        writeMemory(ptr + idx * 4, 4, representFloatAsInt(value), false)
    end
end

function getVehicleRotationMatrix(car)
    if clwarp.v then
        local entityPtr = getCarPointer(car)
        if entityPtr ~= 0 then
            local mat = readMemory(entityPtr + 0x14, 4, false)
            if mat ~= 0 then
            local rx, ry, rz, fx, fy, fz, ux, uy, uz
            rx = readFloatArray(mat, 0)
            ry = readFloatArray(mat, 1)
            rz = readFloatArray(mat, 2)

            fx = readFloatArray(mat, 4)
            fy = readFloatArray(mat, 5)
            fz = readFloatArray(mat, 6)

            ux = readFloatArray(mat, 8)
            uy = readFloatArray(mat, 9)
            uz = readFloatArray(mat, 10)
            return rx, ry, rz, fx, fy, fz, ux, uy, uz
            end
        end
    end
end

function setVehicleRotationMatrix(car, rx, ry, rz, fx, fy, fz, ux, uy, uz)
    if clwarp.v then
        local entityPtr = getCarPointer(car)
        if entityPtr ~= 0 then
            local mat = readMemory(entityPtr + 0x14, 4, false)
            if mat ~= 0 then
            writeFloatArray(mat, 0, rx)
            writeFloatArray(mat, 1, ry)
            writeFloatArray(mat, 2, rz)

            writeFloatArray(mat, 4, fx)
            writeFloatArray(mat, 5, fy)
            writeFloatArray(mat, 6, fz)

            writeFloatArray(mat, 8, ux)
            writeFloatArray(mat, 9, uy)
            writeFloatArray(mat, 10, uz)
            end
        end
        end
end

function displayVehicleName(x, y, gxt)
    if clwarp.v then
        x, y = convertWindowScreenCoordsToGameScreenCoords(x, y)
        useRenderCommands(true)
        setTextWrapx(640.0)
        setTextProportional(true)
        setTextJustify(false)
        setTextScale(0.33, 0.8)
        setTextDropshadow(0, 0, 0, 0, 0)
        setTextColour(255, 255, 255, 230)
        setTextEdge(1, 0, 0, 0, 100)
        setTextFont(1)
        displayText(x, y, gxt)
    end
end

function createPointMarker(x, y, z)
    if clwarp.v then
        pointMarker = createUser3dMarker(x, y, z + 0.3, 4)
    end
end

function removePointMarker()
    if clwarp.v then
        if pointMarker then
            removeUser3dMarker(pointMarker)
            pointMarker = nil
        end
    end
end

function getCarFreeSeat(car)
    if clwarp.v then
        if doesCharExist(getDriverOfCar(car)) then
            local maxPassengers = getMaximumNumberOfPassengers(car)
            for i = 0, maxPassengers do
            if isCarPassengerSeatFree(car, i) then
                return i + 1
            end
            end
            return nil -- no free seats
        else
            return 0 -- driver seat
        end
    end
end

function jumpIntoCar(car)
    if clwarp.v then
        local seat = getCarFreeSeat(car)
        if not seat then return false end                         -- no free seats
        if seat == 0 then warpCharIntoCar(playerPed, car)         -- driver seat
        else warpCharIntoCarAsPassenger(playerPed, car, seat - 1) -- passenger seat
        end
        restoreCameraJumpcut()
        return true
        end
    end

function teleportPlayer(x, y, z)
    if clwarp.v then
        if isCharInAnyCar(playerPed) then
            setCharCoordinates(playerPed, x, y, z)
        end
        setCharCoordinatesDontResetAnim(playerPed, x, y, z)
        end
    end


function setCharCoordinatesDontResetAnim(char, x, y, z)
    if clwarp.v then
        if doesCharExist(char) then
            local ptr = getCharPointer(char)
            setEntityCoordinates(ptr, x, y, z)
        end
    end
end

function setEntityCoordinates(entityPtr, x, y, z)
    if clwarp.v then
        if entityPtr ~= 0 then
            local matrixPtr = readMemory(entityPtr + 0x14, 4, false)
            if matrixPtr ~= 0 then
            local posPtr = matrixPtr + 0x30
            writeMemory(posPtr + 0, 4, representFloatAsInt(x), false) -- X
            writeMemory(posPtr + 4, 4, representFloatAsInt(y), false) -- Y
            writeMemory(posPtr + 8, 4, representFloatAsInt(z), false) -- Z
            end
    end
end

function showCursor(toggle)
    if clwarp.v then
        if toggle then
            sampSetCursorMode(CMODE_LOCKCAM)
        else
            sampToggleCursor(false)
        end
        cursorEnabled = toggle
        end
    end
end