- 264
- 26
- Версия MoonLoader
- .026-beta
привет всем. я пытался добавить эту штуку в слежку, но что-то не получается. помогите пожалуйста мне решить данную проблему! заранее спасибо всем за помощь, кто её проявит.
Lua:
key = require("vkeys")
local radius = 250
KEY = key.VK_R
active = true
trailer = nil
function main()
while not isSampAvailable() do wait(100) end
sampAddChatMessage("attachTrailer загружен! Активация/деактивация: /atr", -1)
sampAddChatMessage("Разработчик: Yuriy Code", -1)
sampRegisterChatCommand("atr", function()
active = not active
printString("AttachTrailer: "..(active and "ON" or "OFF"), 500)
end)
while true do wait(0)
if isKeyDown(KEY) and not sampIsCursorActive() and isCharInAnyCar(1) and getDriverOfCar(getCarCharIsUsing(1)) == 1 and active then
local screenX, screenY = getScreenResolution()
local centerX = screenX / 2
local centerY = screenY / 3.3
local segments = 256
for i = 0, segments - 1 do
local angle1 = (i / segments) * 2 * math.pi
local angle2 = ((i + 1) / segments) * 2 * math.pi
local x1 = centerX + radius * math.cos(angle1)
local y1 = centerY + radius * math.sin(angle1)
local x2 = centerX + radius * math.cos(angle2)
local y2 = centerY + radius * math.sin(angle2)
renderDrawLine(x1, y1, x2, y2, 2, 0xff66aaaa)
end
local vehs = getAllVehicles()
local clear = true
if #vehs > 0 then
for i = 1, #vehs do
if vehs[i] ~= getCarCharIsUsing(1) then
local xx, yy, zz = getCarCoordinates(vehs[i])
local xxx, yyy = convert3DCoordsToScreen(xx, yy, zz)
local px, py, pz = getCharCoordinates(1)
local dx = xxx - centerX
local dy = yyy - centerY
if dx*dx + dy*dy <= radius*radius and isCarOnScreen(vehs[i]) and getDistanceBetweenCoords3d(px, py, pz, xx, yy, zz) <= 120 then
renderDrawLine(xxx, yyy, centerX, centerY, 3, -1)
trailer = vehs[i]
clear = false
break
end
end
end
end
if clear then
trailer = nil
end
end
if not isKeyDown(KEY) and trailer ~= nil then
if isCharInAnyCar(1) and doesVehicleExist(trailer) then
if isTrailerAttachedToCab(trailer, getCarCharIsUsing(1)) then
detachTrailerFromCab(trailer, getCarCharIsUsing(1))
trailer = nil
else
attachTrailerToCab(trailer, getCarCharIsUsing(1))
end
end
trailer = nil
end
end
end