Области для проверки кто в них находится

perkinson

Известный
Автор темы
15
2
Версия MoonLoader
.026-beta
Как создать некую область относительно игрока что-бы проверять кто в ней находится? Тоесть: к примеру, проверять кто находится перед или за игроком.
 
Последнее редактирование:

qdIbp

Автор темы
Проверенный
1,392
1,151
Lua:
local font_flag = require('moonloader').font_flag
local my_font = renderCreateFont('Verdana', 12, font_flag.BOLD + font_flag.SHADOW)

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

    while true do wait(0)
            local per,zad = 0, 0
            for id = 0, 1000 do
                local res, hn = sampGetCharHandleBySampPlayerId(id)
                if res then
                    local xx,yy,zz = getCharCoordinates(hn)
                    local x,y,z = getCharCoordinates(playerPed)
                    --if getDistanceBetweenCoords2d(x,y, xx,yy) <= 5 then
                        if getCharHeading(playerPed) >= 0 and getCharHeading(playerPed) <= 90 then
                            if x < xx and y < yy or x < xx and y > yy then zad = zad + 1
                            elseif x > xx and y > yy or x > xx and y < yy then per = per + 1
                          
                            else
                                sampAddChatMessage('xz',-1)
                            end
                        elseif getCharHeading(playerPed) >= 90 and getCharHeading(playerPed) <= 180 then
                            if x < xx and y < yy or x > xx and y < yy then zad = zad + 1
                            elseif x < xx and y > yy or x > xx and y > yy then per = per + 1
                          
                            else
                                sampAddChatMessage('xz',-1)
                            end         
                        elseif getCharHeading(playerPed) >= 180 and getCharHeading(playerPed) <= 270 then
                            if x < xx and y < yy or x < xx and y > yy then per = per + 1
                            elseif x > xx and y > yy or x > xx and y < yy then zad = zad + 1
                            else
                                sampAddChatMessage('xz',-1)
                            end     
                        elseif getCharHeading(playerPed) >= 270 and getCharHeading(playerPed) <= 360 then
                            if x < xx and y < yy or x > xx and y < yy then per = per + 1
                            elseif x < xx and y > yy or x > xx and y > yy then zad = zad + 1
                          
                            else
                                sampAddChatMessage('xz',-1)
                            end 
                      
                        end
                    --end
                end
            end
            renderFontDrawText(my_font, 'Перед тобой: '..per..'\nЗа тобой: '..zad, 10, 400, 0xFFFFFFFF)
    end
end