Помощь в взаимодействие с игроком через ПКМ+Key

Morus

Участник
Автор темы
27
0
Версия MoonLoader
.026-beta
Помогите,не знаю как сделать данное взаимодействие,ибо чайник в Lua.Помогите пожалуйста.
 

Miron Diamond

Известный
244
162
Lua:
if isKeyDown(VK_RBUTTON) then
if isKeyJustPressed(VK_MENU) then
     local result, ped = getCharPlayerIsTargeting(PLAYER_HANDLE)
     if result and doesCharExist(ped) then
         local success, id = sampGetPlayerIdByCharHandle(ped)
         if success then
             local pname = sampGetPlayerNickname(id)
             local pscore = sampGetPlayerScore(id)
             Player_ID = id
             sampAddChatMessage('Вы начали взаимодействие с игроком: '..pname..' ('.. Player_ID .. ')', -1)
         end
     end
end
end
Вырезал со своего, пробуй :)
 
  • Нравится
Реакции: Morus

Miron Diamond

Известный
244
162
А если я хочу вставить туда /invite id куда это вставлять?
Lua:
if isKeyDown(VK_RBUTTON) then
if isKeyJustPressed(VK_MENU) then
     local result, ped = getCharPlayerIsTargeting(PLAYER_HANDLE)
     if result and doesCharExist(ped) then
         local success, id = sampGetPlayerIdByCharHandle(ped)
         if success then
             local pname = sampGetPlayerNickname(id)
             local pscore = sampGetPlayerScore(id)
             Player_ID = id
             sampAddChatMessage('Вы начали взаимодействие с игроком: '..pname..' ('.. Player_ID .. ')', -1)
             sampSendChat("/invite " .. Player_ID)
         end
     end
end
end
 
  • Нравится
Реакции: Morus

Morus

Участник
Автор темы
27
0
Lua:
if isKeyDown(VK_RBUTTON) then
if isKeyJustPressed(VK_MENU) then
     local result, ped = getCharPlayerIsTargeting(PLAYER_HANDLE)
     if result and doesCharExist(ped) then
         local success, id = sampGetPlayerIdByCharHandle(ped)
         if success then
             local pname = sampGetPlayerNickname(id)
             local pscore = sampGetPlayerScore(id)
             Player_ID = id
             sampAddChatMessage('Вы начали взаимодействие с игроком: '..pname..' ('.. Player_ID .. ')', -1)
             sampSendChat("/invite " .. Player_ID)
         end
     end
end
end

Не работает Мирон
Актуально.
 
Последнее редактирование:

Miron Diamond

Известный
244
162
Не работает Мирон
Актуально.
Работает. Просто ты не поставил в цикл.
Lua:
            while true do wait(0)
                            if isKeyDown(VK_RBUTTON) then
             if isKeyJustPressed(VK_MENU) then
                 local result, ped = getCharPlayerIsTargeting(PLAYER_HANDLE)
                 if result and doesCharExist(ped) then
                     local success, id = sampGetPlayerIdByCharHandle(ped)
                     if success then
                         local pname = sampGetPlayerNickname(id)
                         local pscore = sampGetPlayerScore(id)
                         Player_ID = id
                         sampAddChatMessage('Вы начали взаимодействие с игроком: '..pname..' ('.. Player_ID .. ')', -1)
                         sampSendChat("/invite " .. Player_ID)
                             end
                         end
                     end
                 end
            end

P.S. Тестировал, всё должно работать. (ПКМ + Alt)
 

Angr

Известный
291
100
Работает. Просто ты не поставил в цикл.
Lua:
            while true do wait(0)
                            if isKeyDown(VK_RBUTTON) then
             if isKeyJustPressed(VK_MENU) then
                 local result, ped = getCharPlayerIsTargeting(PLAYER_HANDLE)
                 if result and doesCharExist(ped) then
                     local success, id = sampGetPlayerIdByCharHandle(ped)
                     if success then
                         local pname = sampGetPlayerNickname(id)
                         local pscore = sampGetPlayerScore(id)
                         Player_ID = id
                         sampAddChatMessage('Вы начали взаимодействие с игроком: '..pname..' ('.. Player_ID .. ')', -1)
                         sampSendChat("/invite " .. Player_ID)
                             end
                         end
                     end
                 end
            end

P.S. Тестировал, всё должно работать. (ПКМ + Alt)
Про либу Vkeys ничего ты не написал)
 
  • Нравится
Реакции: Miron Diamond

Morus

Участник
Автор темы
27
0
Про либу Vkeys ничего ты не написал)
Имеется
Работает. Просто ты не поставил в цикл.
Lua:
            while true do wait(0)
                            if isKeyDown(VK_RBUTTON) then
             if isKeyJustPressed(VK_MENU) then
                 local result, ped = getCharPlayerIsTargeting(PLAYER_HANDLE)
                 if result and doesCharExist(ped) then
                     local success, id = sampGetPlayerIdByCharHandle(ped)
                     if success then
                         local pname = sampGetPlayerNickname(id)
                         local pscore = sampGetPlayerScore(id)
                         Player_ID = id
                         sampAddChatMessage('Вы начали взаимодействие с игроком: '..pname..' ('.. Player_ID .. ')', -1)
                         sampSendChat("/invite " .. Player_ID)
                             end
                         end
                     end
                 end
            end

P.S. Тестировал, всё должно работать. (ПКМ + Alt)
Все равно не работает почему то
 

Morus

Участник
Автор темы
27
0
Скрипт сам работает? А то он может крашиться маленько погодя)?
И важно чтобы ты наводил пкм на игрока(не бота) и нажимал
Все я сделал,прост не подключил библиотеку.