Как сделать функцию, чтобы персонаж пересел на водительское место в машине? Какие opcodes или функции испо

Bode Dus Behhhh

Новичок
Автор темы
2
0
Версия MoonLoader
.026-beta
Помогите новичку с Lua :(
Вот часть кода:
Lua:
 if imgui.Button("Pegar p1") then
  if isCharInAnyCar(PLAYER_PED) then 
  local carhandle = storeCarCharIsInNoSave(PLAYER_PED)
    local idcar = getCarModel(carhandle)
    sampForceVehicleSync(carhandle)
      sampSendEnterVehicle(carhandle,1)

Мой код:
Lua:
script_name("Menu do bode")
script_author("bode dus behhhh")
require "lib.moonloader"
local imgui = require "imgui"
local key = require "vkeys"
local armakill = imgui.ImInt(31)
local idkill = imgui.ImInt(-1)
local menu = imgui.ImBool(false)
local test = imgui.ImInt(50)
local test2 = imgui.ImInt(25)
local tab = 1
local custom_x = imgui.ImFloat(0.0)
local custom_y = imgui.ImFloat(0.0)
local custom_z = imgui.ImFloat(0.0)
local muni = imgui.ImInt(200)
local arma = imgui.ImInt(31)
local tx = imgui.ImFloat(0.0)
local ty = imgui.ImFloat(0.0)
local tz = imgui.ImFloat(0.0)
local vida = imgui.ImInt(50)
local colete = imgui.ImInt(100)
local muni2 = imgui.ImInt(1000)
local idskin = imgui.ImInt(0)
local velplayer = imgui.ImFloat(0.0)
local texto = imgui.ImBuffer(256)
function imgui.OnDrawFrame()
     imgui.SetNextWindowPos(imgui.ImVec2(360.0, 100.0), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(700.0, 500.0), imgui.Cond.FirstUseEver)
        imgui.Begin('Aprendendo imgui', menu,imgui.WindowFlags.ShowBorders)

    imgui.BeginChild("tabs",imgui.ImVec2(120,0), true)
    if imgui.Button("Player",imgui.ImVec2(100, 0)) then
        tab = 1
    end
    
    if imgui.Button("Weapons",imgui.ImVec2(100, 0)) then
        tab = 2
    end

    if imgui.Button("Servidor",imgui.ImVec2(100, 0)) then
        tab = 3
    end
    if imgui.Button("Vida",imgui.ImVec2(100,0)) then
        tab = 4
    end
    if imgui.Button("Car",imgui.ImVec2(100,0)) then
    tab = 5
    end
    imgui.EndChild()
    imgui.SameLine()

    imgui.BeginChild("content", imgui.ImVec2(0, 0), true)
    if tab == 1 then
        imgui.Text("Teleport functions")
        imgui.Separator()

        imgui.Text("Coordenadas")
        imgui.InputFloat("X", custom_x, -1000, 1000)
        imgui.InputFloat("Y",custom_y, -1000, 1000)
        imgui.InputFloat("Z", custom_z, -1000, 1000)
        if imgui.Button("Teleportar") then
            setCharCoordinates(PLAYER_PED, custom_x.v, custom_y.v, custom_z.v)
        sampAddChatMessage("Teleportado para: "..custom_x.v..", "..custom_y.v..", "..custom_z.v.." !", 0x00FF00)
        end
        

    elseif tab == 2 then
        imgui.Text("Weapons")
        imgui.SameLine()
       imgui.SliderInt("ID da arma",arma,0,60)
        imgui.SliderInt("Quantidade de municao",muni,0,1000)
        if imgui.Button("Puxar a arma") then
            sampForceWeaponsSync()
        giveWeaponToChar(PLAYER_PED,arma.v,muni.v)
        
        sampAddChatMessage("A arma id: "..arma.v.." com "..muni.v.."!!!", 0x00FF00)
        end
        imgui.SameLine()
        if imgui.Button("Remover arma") then
            removeWeaponFromChar(PLAYER_PED,arma.v)
            sampAddChatMessage("Arma id: "..arma.v.." removida!!!", 0xFF0000)
        end
        imgui.SliderInt("Puxar municao para sua arma",muni2,0,1000)
        
       if imgui.Button("Puxar municao") then
        local weaponID = getCurrentCharWeapon(PLAYER_PED)
 imgui.Text("O id da arma atual e: "..weaponID)
 sampForceWeaponsSync()
        giveWeaponToChar(PLAYER_PED,weaponID,muni2.v)
       end
        
elseif tab == 3 then
    imgui.Text("Informacoes do servidor")
        imgui.Separator()
       if imgui.Button("Reconectar") then
         sampAddChatMessage("Reconectando...", 0xC0C0C0)
            sampDisconnectWithReason(0)
            sampConnect(sampGetCurrentServerAddress())
    end
    imgui.Separator()
    imgui.Text("Teste damager sem raknet")
 
    imgui.InputInt("ID do player", idkill, -1, 100)
    wait(2)
    imgui.SliderInt("Arma",armakill,0,60)
    if imgui.Button("Kill") then
        sampSetLocalPlayerName("MKL_Staff")
        sampSendGiveDamage(idkill.v, 100.0, armakill.v,9)  -- -9 = cabeça
        end
    if imgui.Button("kill teste") then
        sampSendDeathByPlayer(idkill.v, 9)
    end
    imgui.Separate()
    if imgui.Button("Teste") then
        sampSendSpectatorData()
    end
elseif tab == 4 then
    imgui.Text("Funcoes de vida")
    imgui.Separator()
    imgui.SliderInt("Define sua vida",vida,0,100)
    if imgui.Button("Setar vida") then
    setCharHealth(PLAYER_PED,vida.v)
    sampAddChatMessage("Voce setou "..vida.v.." de hp na sua vida!",0x00FF00)
    end
    imgui.SameLine()
    if imgui.Button("Suicide") then
        setCharHealth(PLAYER_PED,0)
        sampAddChatMessage("Voce se suicidou!",0xFF0000)
    end
    imgui.SliderInt("Defina seu colete",colete,0,100)
    if imgui.Button("Setar colete") then
    addArmourToChar(PLAYER_PED,colete.v)
    sampAddChatMessage("Voce setou "..colete.v.." de hp em seu colete !",0x00FF00)
    end
    local godmode = false
    if imgui.Button("God mode") then
        sampAddChatMessage("God mode ativado! \n Nao tem como desativar -_-", 0x00FF00)
    godmode = not godmode
    end
    lua_thread.create(function()
    while true do
    wait(0)
    if godmode then
    setCharHealth(PLAYER_PED,200)
    addArmourToChar(PLAYER_PED,100)
    end
    end
    end)
    
elseif tab == 5 then
    imgui.Text("Funcoes de carro")
    imgui.Separator()
   if imgui.Button("Pegar p1") then
  if isCharInAnyCar(PLAYER_PED) then 
  local carhandle = storeCarCharIsInNoSave(PLAYER_PED)
    local idcar = getCarModel(carhandle)
    sampForceVehicleSync(carhandle)
      sampSendEnterVehicle(carhandle,1)
     end
    end
    if imgui.Button("Explodir seu carro") then
        if isCharInAnyCar(PLAYER_PED) then 
  local carhandle = storeCarCharIsInNoSave(PLAYER_PED)
    local idcar = getCarModel(carhandle)
    sampForceVehicleSync(carhandle)
        explodeCar(carhandle)
        end
    end
    end
    imgui.EndChild()
     imgui.End()
     end
function main()

    imgui.Process = false
    
    while true do
        wait(0)
        
        -- Tecla para abrir/fechar menu
        if wasKeyPressed(key.VK_J) then
            menu.v = not menu.v
            imgui.Process = menu.v
    end
    end
    end
    
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4


style.WindowRounding = 5.0
style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
style.ChildWindowRounding = 2.0
style.FrameRounding = 2.0
style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
style.ScrollbarSize = 15.0
style.ScrollbarRounding = 9
style.GrabMinSize = 5.0
style.GrabRounding = 1.0

colors[clr.WindowBg]               = imgui.ImVec4(0.10, 0.10, 0.10, 0.95)
colors[clr.ChildWindowBg]                = imgui.ImVec4(0.10, 0.10, 0.10, 1.00)
colors[clr.TitleBg]                = imgui.ImVec4(0.20, 0.05, 0.05, 1.00)
colors[clr.TitleBgActive]          = imgui.ImVec4(0.30, 0.05, 0.05, 1.00)
colors[clr.Button]                 = imgui.ImVec4(0.50, 0.10, 0.10, 1.00)
colors[clr.ButtonHovered]          = imgui.ImVec4(0.70, 0.20, 0.20, 1.00)
colors[clr.ButtonActive]           = imgui.ImVec4(0.90, 0.30, 0.30, 1.00)
colors[clr.Text]                   = imgui.ImVec4(1.00, 1.00, 1.00, 1.00)
colors[clr.FrameBg]                = imgui.ImVec4(0.20, 0.05, 0.05, 1.00)
colors[clr.FrameBgHovered]         = imgui.ImVec4(0.30, 0.10, 0.10, 1.00)
colors[clr.FrameBgActive]          = imgui.ImVec4(0.40, 0.15, 0.15, 1.00)
colors[clr.Header]                 = imgui.ImVec4(0.50, 0.10, 0.10, 1.00)
colors[clr.HeaderHovered]          = imgui.ImVec4(0.70, 0.20, 0.20, 1.00)
colors[clr.HeaderActive]           = imgui.ImVec4(0.90, 0.30, 0.30, 1.00)
colors[clr.CheckMark]              = imgui.ImVec4(0.90, 0.30, 0.30, 1.00)
colors[clr.SliderGrab]             = imgui.ImVec4(0.70, 0.20, 0.20, 1.00)
colors[clr.SliderGrabActive]       = imgui.ImVec4(0.90, 0.30, 0.30, 1.00)

up
 
Последнее редактирование:

Digger Man52

52NGG
Проверенный
1,114
989
sampForceVehicleSync - выкидывай
sampSendEnterVehicle - только отправляет пакет о том, что ты начинаешь садиться в транспорт, тебе нужно еще и телепортироваться в него используя https://wiki.blast.hk/moonloader/lua/warpCharIntoCar или https://wiki.blast.hk/moonloader/lua/warpCharIntoCarAsPassenger
upd: у тебя вообще все неправильно, откуда ты взял getCarModel? если ты хочешь получить сампвоский id транспорта, используй https://wiki.blast.hk/moonloader/lua/sampGetVehicleIdByCarHandle
а вообще хуйню какую то пишешь
 
  • Нравится
Реакции: Bode Dus Behhhh

Bode Dus Behhhh

Новичок
Автор темы
2
0
sampForceVehicleSync - выкидывай
sampSendEnterVehicle - только отправляет пакет о том, что ты начинаешь садиться в транспорт, тебе нужно еще и телепортироваться в него используя https://wiki.blast.hk/moonloader/lua/warpCharIntoCar или https://wiki.blast.hk/moonloader/lua/warpCharIntoCarAsPassenger
upd: у тебя вообще все неправильно, откуда ты взял getCarModel? если ты хочешь получить сампвоский id транспорта, используй https://wiki.blast.hk/moonloader/lua/sampGetVehicleIdByCarHandle
а вообще хуйню какую то пишешь
Понял, спасибо! Буду использовать warpCharIntoCar и sampGetVehicleIdByCarHandle. Извините за ошибки, еще учусь :)