SlonPvpru

[DRP] Factory-Clicker

Jun 7th, 2020
983
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.54 KB | None | 0 0
  1. -- https://vk.com/mdx_ahk?w=wall-167523533_1294
  2.  
  3. local memory = require('memory')
  4. local hook = require('lib.samp.events');
  5.  
  6. local ignore = {19481, 1316, 1999, 18980, 14397, 2633, 1698, 19445, 19065};
  7.  
  8. local items = {
  9.     beam = {count = 1, ids = {2960}},
  10.     wood = {count = 1, ids = {11701}},
  11.     mount = {count = 7, ids = {1547, 18641, 19811, 19569}}
  12. };
  13.  
  14. local data = {
  15.  
  16.     enable = false,
  17.     count = 0,
  18.  
  19.     last = {
  20.         update = os.clock(), item
  21.     }
  22. };
  23.  
  24. local textdraws = {normal, defective};
  25.  
  26. local font = renderCreateFont("Arial", 7, 4)
  27.  
  28. local function indexOf(obj, value)
  29.     local index = -1;
  30.  
  31.     for i = 1, #obj do
  32.         if (obj[i] == value) then
  33.             return i;
  34.         end
  35.     end
  36.  
  37.     return index;
  38. end
  39.  
  40. local function wbg(state)
  41.     if state then
  42.         memory.setuint8(7634870, 1); memory.setuint8(7635034, 1);
  43.         memory.fill(7623723, 144, 8); memory.fill(5499528, 144, 6);
  44.     else
  45.         memory.setuint8(7634870, 0); memory.setuint8(7635034, 0);
  46.         memory.hex2bin('5051F1500838500', 7623723, 8);
  47.         memory.hex2bin('0F847B010000', 5499528, 6);
  48.     end
  49. end;
  50.  
  51. function main()
  52.  
  53.     assert(isSampLoaded(), 'SA:MP is not loaded')
  54.     assert(isSampfuncsLoaded(), 'samp.events requires SAMPFUNCS')
  55.  
  56.     while not isSampAvailable() do wait(0) end;
  57.  
  58.     while true do wait(0)
  59.        
  60.         if (data.enable and os.clock() - data.last.update >= 0.5) then
  61.             print("работаем")
  62.             print('check', data.last.item, data.count)
  63.             if (data.count == items[data.last.item].count) then
  64.                 sampSendClickTextdraw(textdraws['normal']);
  65.             else
  66.                 sampSendClickTextdraw(textdraws['defective']);
  67.             end;
  68.  
  69.             data.enable = false;
  70.             data.count = 0;
  71.         end
  72.  
  73.     end
  74. end
  75.  
  76. function hook.onCreateObject(id, obj)
  77.  
  78.     if (locateCharAnyMeans2d(PLAYER_PED,obj.position.x,obj.position.y, 1.65, 10, true)) then
  79.         for k, v in pairs(items) do
  80.             if (indexOf(v.ids, obj.modelId) ~= -1) then
  81.                 data.enable = true;
  82.                 data.last.item = k;
  83.             end
  84.         end
  85.         data.count = data.count + 1;
  86.         data.last.update = os.clock();
  87.     end
  88.  
  89. end
  90.  
  91. function hook.onShowTextDraw(id, data)
  92.  
  93.     if (data.text == 'START') then
  94.         wbg(true)
  95.         lua_thread.create(function(id) wait(10) sampSendClickTextdraw(id - 1) end, id);
  96.     end
  97.  
  98.     if (data.text:match('~h~(%w+)')) then
  99.         textdraws[data.text:match('~h~(%w+)')] = id - 4;
  100.     end
  101.  
  102. end
Advertisement
Add Comment
Please, Sign In to add comment