Вы находитесь на странице: 1из 2

script_name('Egg finder')

script_version("0.2")
script_author("DarkTX")

local sampev = require 'lib.samp.events'


local vector3d = require 'lib.vector3d'

local pickups = {} -- ������� ������� � ���� ������


local eggs = {19804} -- ID ������� ���������� ���

function main()
repeat wait(100) until isSampAvailable() -- �������� �� ������������� SAMP`�

while true do -- ����������� ����, ��������� ������ ����


wait(0) -- ���������� ��������, ����� ����
local resX, resY = getScreenResolution() -- �������� ���������� ������.
������ � ���� ����� �� ������ ����� ��������� � ����������.
local myPosX, myPosY, myPosZ = getCoordinates(PLAYER_PED) -- ��������
���� ����������
for k in pairs(pickups) do -- ���������� ������� � ��������
for d in pairs(eggs) do -- ���������� ������� � ������� �������
if pickups[k][2] == eggs[d] then -- ���� ����� ������ �����
�� ���� �������
if isPointOnScreen(pickups[k][4], pickups[k][5],
pickups[k][6], 0) then -- ��������, �������� �� ���� ����� � �������� ������ ������
x, y = convert3DCoordsToScreen(pickups[k][4],
pickups[k][5], pickups[k][6]) -- ������������ ���������� �� �������� ���� �
�������� ����������
renderDrawLine(resX / 2, resY / 2 + 200, x, y,
2.0, #ff0000) -- ������������ ���� �� ������ ��������� �� ���������, ����������
����
end
end
end
end
end

wait(-1)
end

function sampev.onCreatePickup(id, model, pickupType, position) -- ��� ���������


���������� � �������� ������
local posX, posY, posZ = position:get() -- �������� ��� ������ (� ������
���������� vector3d, ������ ��������� � ������)
table.insert(pickups, {id, model, pickupType, posX, posY, posZ}) -- ��������
���� ����� � ���� �������
for k in pairs(eggs) do -- ���������� ������� � ������� ������� �������
if model == eggs[k] then -- ���� ��������� ����� ����� �������� ������
local myPosX, myPosY, myPosZ = getCoordinates(PLAYER_PED) --
�������� ���� ����������
sampAddChatMessage("�� �������� ����, �����������. ��������: " ..
math.ceil(getDistance(myPosX, myPosY, myPosZ, posX, posY, posZ)) .. "�.", 0xE500FF)
-- ���������, ����� ���������
placeWaypoint(posX, posY, posZ) -- ������ ����� �� �����
break -- ���������� ����, ��� ��� ����� � ������� ����������
end
end
end

function sampev.onDestroyPickup(id) -- ��� ��������� �� �������� ������


for k in pairs(pickups) do -- ���������� ������� �������
if pickups[k][1] == id then -- ���� ������� ������������
table.remove(pickups, k) -- ������ ����� �� �������
break -- ���������� ����, ��� ��� ����� � ������� ����������
end
end
end

function getCoordinates(player) -- ������ �������� ��������� ���������� ����


if isCharInAnyCar(player) then -- ���� ����� � ������
local car = storeCarCharIsInNoSave(player) -- �������� ��������� �� ���
������
return getCarCoordinates(car)
else
return getCharCoordinates(player)
end
end

function getDistance(x1, y1, z1, x2, y2, z2)


local distance = math.sqrt(((x1 - x2) ^ 2) + ((y1 - y2) ^ 2) + ((z1 - z2) ^
2)) -- ���������� ��������� ����� �������
return distance
end

Вам также может понравиться