Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local CheckPlysPitch = function(set, pitch)
- local OKs = {}
- if set == nil then
- set = {}
- for i=0,32-1 do
- table.insert(set, i)
- end
- end
- for _,i in pairs(set) do
- local p,y,r = Player.m_angRotation(GetEntity(i))
- WriteConsole("Index#"..tostring(i).." -> Pitch " .. tostring(p) .. "deg\n")
- if pitch < 0 then
- if p < pitch then table.insert(OKs, i) end
- else
- if p > pitch then table.insert(OKs, i) end
- end
- end
- return OKs
- end
- local FindPlayerRecursive = function(down, ang, OKs)
- WriteConsole("\tPlease look "
- .. (down and "DOWN under " or "UP over ")
- .. tostring(ang) .. " degrees. Press SPACE to continue.\n")
- while (not IsKeyDown(VK_SPACE)) do end
- local passed = CheckPlysPitch(OKs, ang)
- if (#passed ~= 0) then
- if (#passed == 1) then
- localidx = passed[1]
- WriteConsole("\tFound local player! Index " .. tostring(localidx) .. "\n")
- recursivestopchk = 0
- else
- recursivestopchk = recursivestopchk + 1
- if (recursivestopchk > 10) then
- localidx = -1
- recursivestopchk = 0
- WriteConsole("\tFailed to find local player!")
- else
- WriteConsole("\tFound multiple indices. Retrying with smaller player set...\n")
- FindPlayerRecursive(not down, -ang, passed)
- end
- end
- end
- end
- --how i use it in the main loop
- if (localidx == -1) then
- WriteConsole("Finding local player index...\n")
- WriteConsole("\tDO NOT PRESS ANY KEYS IN GAME UNLESS INSTRUCTED!\n")
- FindPlayerRecursive(false, -35, nil)
- else
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement