[Lua] Get closest driver id.

HappyFace

Новичок
Автор темы
3
0
Версия MoonLoader
.026-beta
Hello, how do i should make an script that gets closest Driver id (and skin id ), right now i have only closest player id, and how to
 

YarikVL

Известный
Проверенный
4,750
1,815
Hello, how do i should make an script that gets closest Driver id (and skin id ), right now i have only closest player id, and how to
Lua:
local x, y, z = getCharCoordinates(PLAYER_PED)
local buffer, nearestdriver, nearestdriver_id, nearestdriver_nick
for _, v in ipairs(getAllChars()) do
    local result, id = sampGetPlayerIdByCharHandle(v)
    if result and v ~= PLAYER_PED then
        local distance = getDistanceBetweenCoords3d(x, y, z, getCharCoordinates(v))
        if buffer == nil or distance < buffer and isCharInAnyCar(v) and v == getDriverOfCar(storeCarCharIsInNoSave(v)) then
            buffer, nearestdriver, nearestdriver_id, nearestdriver_nick = distance, v, id, sampGetPlayerNickname(id)
        end
    end
end
nearestdriver - ped
nearestdriver_id - ID
nearestdriver_nick - Nick
print(getCharModel(nearestdriver)) - output skin id
nil - if in stream zone nobody there
 
  • Влюблен
Реакции: HappyFace