LUA Как получить айди ближайшего игрока?

SKIP_CRMP

Участник
Автор темы
93
8
Версия SA-MP
  1. 0.3.7-R3
Как получить айди ближайшего игрока в самп?
 

корбус

Известный
434
108
а как же
Lua:
function getClosestPlayerId()
    local closestId = -1
    mydist = 30
    local x, y, z = getCharCoordinates(PLAYER_PED)
    for i = 0, 999 do
        local streamed, pedID = sampGetCharHandleBySampPlayerId(i)
        if streamed and getCharHealth(pedID) > 0 and not sampIsPlayerPaused(pedID) then
            local xi, yi, zi = getCharCoordinates(pedID)
            local dist = getDistanceBetweenCoords3d(x, y, z, xi, yi, zi)
            if dist <= mydist then
                mydist = dist
                closestId = i
            end
        end
    end
    return closestId
end

используй
getClosestPlayerId()