- 20
- 9
сделайте код, чтобы корректно работал без radius, либо чтобы он был внутри кода, т.к. в будущем точки будут почти друг у друга, из-за чего радиусы могут пересекаться и код скореее всего будет работать некоректно
Код:
require "lib.moonloader"
local radius = 3.0
local playerPoint = {}
local points = {
{ x = 1684.5678, y = -1245.2345, z = 18.5000 },
{ x = 1118.0000, y = 140.0000, z = 10.0000 },
{ x = -1970.4321, y = 200.7890, z = 45.3000 },
{ x = 800.0000, y = 2000.0000, z = 20.0000 },
{ x = 2450.1234, y = 1800.5678, z = 10.8750 },
{ x = -2730.0000, y = 500.0000, z = -5.0000 },
{ x = -2200.0000, y = 570.0000, z = 1000.0000 },
{ x = 1850.1111, y = -1550.2222, z = 13.5469 },
{ x = -100.0000, y = -100.0000, z = 0.0000 },
{ x = -400.0000, y = 2000.0000, z = 50.0000 },
}
function main()
repeat wait(500) until isSampAvailable()
local myId = sampGetPlayerIdByCharHandle(PLAYER_PED)
while true do
wait(300)
for playerId = 0, 1000 do
if sampIsPlayerConnected(playerId) and playerId ~= myId then
local result, ped = sampGetCharHandleBySampPlayerId(playerId)
if result and doesCharExist(ped) then
local px, py, pz = getCharCoordinates(ped)
local nick = sampGetPlayerNickname(playerId)
playerPoint[playerId] = playerPoint[playerId] or {}
for i, point in ipairs(points) do
playerPoint[playerId][i] = playerPoint[playerId][i] or false
local dist = getDistanceBetweenCoords3d(px, py, pz,point.x, point.y, point.z)
if dist <= radius then
if not playerPoint[playerId][i] then
playerPoint[playerId][i] = true
sampAddChatMessage(
string.format("[info] игрок %s подошёл к позиции #%d",nick,i),-1)
end
else
playerPoint[playerId][i] = false
end
end
end
end
end
end
end