Skip to content

Instantly share code, notes, and snippets.

@ilya-pirogov
Last active July 6, 2018 03:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilya-pirogov/ff2c7c2316f3f3e3eb0c919d92b49dde to your computer and use it in GitHub Desktop.
Save ilya-pirogov/ff2c7c2316f3f3e3eb0c919d92b49dde to your computer and use it in GitHub Desktop.
local CurrentAction
-- цикл для проверки что мы внутри маркера
Citizen.CreateThread(function()
local ped = GetPlayerPed(-1)
local coords = GetEntityCoords(playerPed)
while true do
Wait(50) -- кадлые 50 фреймов поскольку GetDistanceBetweenCoords тяжелая операция
if GetDistanceBetweenCoords(coords, Config.MarkerSet.x, Config.MarkerSet.y, Config.MarkerSet.z, true) < Config.MarkerSize.x then
-- мы внутри маркера
CurrentAction = "SET"
elseif GetDistanceBetweenCoords(coords, Config.MarkerGet.x, Config.MarkerGet.y, Config.MarkerGet.z, true) < Config.MarkerSize.x then
CurrentAction = "GET"
else
-- мы снаружи маркера
CurrentAction = nil
end
end
end)
-- цикл для рисования маркеров и проверки нажатия клавиши
Citizen.CreateThread(function()
local ped = GetPlayerPed(-1)
while true do
Wait(0) -- безопасно рендерить каждый фрейм
DrawMarker(Config.MarkerType, Config.MarkerSet.x, Config.MarkerSet.y, Config.MarkerSet.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false)
-- do_something - означает, что мы внутри маркера, потому что мы выставили его в другом цикле выше
if CurrentAction == "do_something" then
-- тут можно будет вывести сообщение "Нажмите E"
if IsControlJustPressed(...) then
-- тут твой вызов GetDamage или SetDamage
end
end
end
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment