onSendEnterVehicle

Tyniadec

Новичок
Автор темы
16
0
Версия MoonLoader
Другое
Хочу чтобы бинд на альт и ктрл работал только тогда, когда когда персонаж сидит за рулем
Придумал вот такую фигню. В голове у меня это должно работать, на практике не выходит. Возможно проблему просто в том, что я плохо знаю синтаксис. А может я просто тупой?
Lua:
function sampev.onSendEnterVehicle(id,pass)
local rul = false
 if(tostring(pass)) then
 else
    rul = not rul
 end
 if isKeyJustPressed(VK_MENU) then
    if rul then
    sampSendChat('/l')
    end
 elseif isKeyJustPressed(VK_CONTROL) then
    if rul then
    sampSendChat('/e')
    end
 end
end
 
Решение
Lua:
function main()
   if not isSampLoaded() or not isSampfuncsLoaded() then return end
   while not isSampAvailable() do wait(100) end
   while true do
         wait(0)
         if isCharInCarDriver(PLAYER_PED) then
if isKeyJustPressed(VK_MENU) then
    sampSendChat('/l')
 elseif isKeyJustPressed(VK_CONTROL) then
    sampSendChat('/e')
end
   end
end

function isCharInCarDriver(ped)
    return isCharInAnyCar(ped) and getDriverOfCar(storeCarCharIsInNoSave(ped)) == ped
end

damag

Женюсь на официантке в моем любимом баре
Проверенный
1,152
1,194
Lua:
function test()
if isCharInAnyCar(PLAYER_PED) or isCharOnAnyBike(playerPed) then
if isKeyJustPressed(VK_MENU) then
    if rul then
    sampSendChat('/l')
    end
elseif isKeyJustPressed(VK_CONTROL) then
    if rul then
    sampSendChat('/e')
    end
end
end
 
Последнее редактирование:

Albertio

Attention! Thanks for your attention.
877
702
Код:
function test()
if isCharOnAnyBike(playerPed) then
if isKeyJustPressed(VK_MENU) then
    if rul then
    sampSendChat('/l')
    end
elseif isKeyJustPressed(VK_CONTROL) then
    if rul then
    sampSendChat('/e')
    end
end
end
У тебя в коде идет проверка сидит ли игрок в любом мотоцикле или велосипеде
 

Tyniadec

Новичок
Автор темы
16
0
А ты нормально объясни что ты хочешь реализовать?
Хочу бинд, чтобы при нажатии на Альт в чат отправлялась команда /l, но только в том случае, если персонаж сидит на рулем авто. С контролом аналогично, только /e
 

Izvinisb

Известный
Проверенный
964
598

Albertio

Attention! Thanks for your attention.
877
702
Lua:
function main()
   if not isSampLoaded() or not isSampfuncsLoaded() then return end
   while not isSampAvailable() do wait(100) end
   while true do
         wait(0)
         if isCharInCar(PLAYER_PED, storeCarCharIsInNoSave(PLAYER_PED)) then
if isKeyJustPressed(VK_MENU) then
    sampSendChat('/l')
 elseif isKeyJustPressed(VK_CONTROL) then
    sampSendChat('/e')
end
   end
end
Сорри за табуляцию пишу с тлф
 
D

deleted-user-204957

Гость
Lua:
function main()
   if not isSampLoaded() or not isSampfuncsLoaded() then return end
   while not isSampAvailable() do wait(100) end
   while true do
         wait(0)
         if isCharInCar(PLAYER_PED, storeCarCharIsInNoSave(PLAYER_PED)) then
if isKeyJustPressed(VK_MENU) then
    sampSendChat('/l')
elseif isKeyJustPressed(VK_CONTROL) then
    sampSendChat('/e')
end
   end
end
Сорри за табуляцию пишу с тлф
isCharInCar проверяет находится ли игрок в машине. А ему нужна проверка на водительское место.
 
  • Вау
Реакции: sᴀxᴏɴ

Albertio

Attention! Thanks for your attention.
877
702
Lua:
function main()
   if not isSampLoaded() or not isSampfuncsLoaded() then return end
   while not isSampAvailable() do wait(100) end
   while true do
         wait(0)
         if isCharInCarDriver(PLAYER_PED) then
if isKeyJustPressed(VK_MENU) then
    sampSendChat('/l')
 elseif isKeyJustPressed(VK_CONTROL) then
    sampSendChat('/e')
end
   end
end

function isCharInCarDriver(ped)
    return isCharInAnyCar(ped) and getDriverOfCar(storeCarCharIsInNoSave(ped)) == ped
end
 

Tyniadec

Новичок
Автор темы
16
0
Lua:
function main()
   if not isSampLoaded() or not isSampfuncsLoaded() then return end
   while not isSampAvailable() do wait(100) end
   while true do
         wait(0)
         if isCharInCarDriver(PLAYER_PED) then
if isKeyJustPressed(VK_MENU) then
    sampSendChat('/l')
elseif isKeyJustPressed(VK_CONTROL) then
    sampSendChat('/e')
end
   end
end

function isCharInCarDriver(ped)
    return isCharInAnyCar(ped) and getDriverOfCar(storeCarCharIsInNoSave(ped)) == ped
end
Прошлый код код работал, но правда не было проверки на водителя. Этот уже не работает
Прошу прощения, я доблюсь в глаза. Не увидел фукнцию в конце.
 

Albertio

Attention! Thanks for your attention.
877
702
Прошлый код код работал, но правда не было проверки на водителя. Этот уже не работает
Прошу прощения, я доблюсь в глаза. Не увидел фукнцию в конце.
Добавь после 13 строчки еще один end