Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- https://vk.com/mdx_ahk?w=wall-167523533_1294
- local memory = require('memory')
- local hook = require('lib.samp.events');
- local ignore = {19481, 1316, 1999, 18980, 14397, 2633, 1698, 19445, 19065};
- local items = {
- beam = {count = 1, ids = {2960}},
- wood = {count = 1, ids = {11701}},
- mount = {count = 7, ids = {1547, 18641, 19811, 19569}}
- };
- local data = {
- enable = false,
- count = 0,
- last = {
- update = os.clock(), item
- }
- };
- local textdraws = {normal, defective};
- local font = renderCreateFont("Arial", 7, 4)
- local function indexOf(obj, value)
- local index = -1;
- for i = 1, #obj do
- if (obj[i] == value) then
- return i;
- end
- end
- return index;
- end
- local function wbg(state)
- if state then
- memory.setuint8(7634870, 1); memory.setuint8(7635034, 1);
- memory.fill(7623723, 144, 8); memory.fill(5499528, 144, 6);
- else
- memory.setuint8(7634870, 0); memory.setuint8(7635034, 0);
- memory.hex2bin('5051F1500838500', 7623723, 8);
- memory.hex2bin('0F847B010000', 5499528, 6);
- end
- end;
- function main()
- assert(isSampLoaded(), 'SA:MP is not loaded')
- assert(isSampfuncsLoaded(), 'samp.events requires SAMPFUNCS')
- while not isSampAvailable() do wait(0) end;
- while true do wait(0)
- if (data.enable and os.clock() - data.last.update >= 0.5) then
- print("работаем")
- print('check', data.last.item, data.count)
- if (data.count == items[data.last.item].count) then
- sampSendClickTextdraw(textdraws['normal']);
- else
- sampSendClickTextdraw(textdraws['defective']);
- end;
- data.enable = false;
- data.count = 0;
- end
- end
- end
- function hook.onCreateObject(id, obj)
- if (locateCharAnyMeans2d(PLAYER_PED,obj.position.x,obj.position.y, 1.65, 10, true)) then
- for k, v in pairs(items) do
- if (indexOf(v.ids, obj.modelId) ~= -1) then
- data.enable = true;
- data.last.item = k;
- end
- end
- data.count = data.count + 1;
- data.last.update = os.clock();
- end
- end
- function hook.onShowTextDraw(id, data)
- if (data.text == 'START') then
- wbg(true)
- lua_thread.create(function(id) wait(10) sampSendClickTextdraw(id - 1) end, id);
- end
- if (data.text:match('~h~(%w+)')) then
- textdraws[data.text:match('~h~(%w+)')] = id - 4;
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment