commit 1521752ff57fc508577e50375bbb2053ea3cb043 Author: rubin Date: Mon Jul 27 20:38:44 2026 +0300 initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..e37bcf7 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ + +# **LUA Durak Speed Edition - скрипт слива карт в игре 'дурак' для SAMP-RP** +[![Cкачать](pictures/download.png)](durak_speed_edition.lua) +# [**Cкачать**](durak_speed_edition.lua) + +## **Описание** +- *Команда активации: /durak* \ No newline at end of file diff --git a/durak_speed_edition.lua b/durak_speed_edition.lua new file mode 100644 index 0000000..bce127e --- /dev/null +++ b/durak_speed_edition.lua @@ -0,0 +1,184 @@ +script_name("durak_speed_edition") +script_author("rubin") +script_version("27.07.2026") + +require('sampfuncs') +local clicker = false + +function main() + while not isSampfuncsLoaded() do wait(100) end + repeat wait(0) until isSampAvailable() + + sampRegisterChatCommand("durak", function(param) + clicker = not clicker + sampAddChatMessage((clicker and "ON" or "OFF"), -1) + end) + while true do wait(0) + if clicker then + -- + local result, id = find_textdraw_by_text("beat", 400) + if result then + -- Y 300 + local result2, id2 = find_card() + if result2 then + sampSendClickTextdraw(id2) + wait(100) + sampSendClickTextdraw(id) + wait(100) + end + end + local result, id = find_textdraw_by_text("take", 400) + if result then + wait(100) + sampSendClickTextdraw(id) + end + -- + local result, id = find_textdraw_by_text("TO START PLAYING THE FOO", 0) + if result then + local data = samp_create_sync_data('player') + data.keysData = 16 + data.send() + wait(1000) + end + if sampIsDialogActive() and sampGetDialogCaption():find(" ") then + sampCloseCurrentDialogWithButton(1) + wait(1000) + end + -- + local line1, line2 = find_lines() + if line1 ~= "" and line2 ~= "" then + local _, id = sampGetPlayerIdByCharHandle(PLAYER_PED) + local name = sampGetPlayerNickname(id) + local arr1 = split(line1, "~n~") + local arr2 = split(line2, "~n~") + for k,v in pairs(arr1) do + if v == name then + if arr2[k]:find("X") then + local result, id = find_textdraw_by_text("ready", 0) + if result then + sampSendClickTextdraw(id) + wait(1500) + end + end + end + end + end + end + end +end + +function find_textdraw_by_text(text, yf) + local result, id = false, -1 + for a = 0, 2304 do + if sampTextdrawIsExists(a) then + local texts = sampTextdrawGetString(a) + local x, y = sampTextdrawGetPos(a) + if texts:lower():find(text:lower()) and y > yf then + result = true + id = a + break + end + end + end + return result, id +end + +function find_card() + local text = "white" + local result, id = false, -1 + for a = 0, 2304 do + if sampTextdrawIsExists(a) then + local texts = sampTextdrawGetString(a) + local x, y = sampTextdrawGetPos(a) + if texts:lower():find(text:lower()) and y == 340 then + -- sampAddChatMessage(string.format("%0.2f, %0.2f", x, y)) + result = true + id = a + break + end + end + end + return result, id +end + +function samp_create_sync_data(sync_type, copy_from_player) + local ffi = require 'ffi' + local sampfuncs = require 'sampfuncs' + -- from SAMP.Lua + local raknet = require 'samp.raknet' + require 'samp.synchronization' + + copy_from_player = copy_from_player or true + local sync_traits = { + player = {'PlayerSyncData', raknet.PACKET.PLAYER_SYNC, sampStorePlayerOnfootData}, + vehicle = {'VehicleSyncData', raknet.PACKET.VEHICLE_SYNC, sampStorePlayerIncarData}, + passenger = {'PassengerSyncData', raknet.PACKET.PASSENGER_SYNC, sampStorePlayerPassengerData}, + aim = {'AimSyncData', raknet.PACKET.AIM_SYNC, sampStorePlayerAimData}, + trailer = {'TrailerSyncData', raknet.PACKET.TRAILER_SYNC, sampStorePlayerTrailerData}, + unoccupied = {'UnoccupiedSyncData', raknet.PACKET.UNOCCUPIED_SYNC, nil}, + bullet = {'BulletSyncData', raknet.PACKET.BULLET_SYNC, nil}, + spectator = {'SpectatorSyncData', raknet.PACKET.SPECTATOR_SYNC, nil} + } + local sync_info = sync_traits[sync_type] + local data_type = 'struct ' .. sync_info[1] + local data = ffi.new(data_type, {}) + local raw_data_ptr = tonumber(ffi.cast('uintptr_t', ffi.new(data_type .. '*', data))) + -- copy player's sync data to the allocated memory + if copy_from_player then + local copy_func = sync_info[3] + if copy_func then + local _, player_id + if copy_from_player == true then + _, player_id = sampGetPlayerIdByCharHandle(PLAYER_PED) + else + player_id = tonumber(copy_from_player) + end + copy_func(player_id, raw_data_ptr) + end + end + -- function to send packet + local func_send = function() + local bs = raknetNewBitStream() + raknetBitStreamWriteInt8(bs, sync_info[2]) + raknetBitStreamWriteBuffer(bs, raw_data_ptr, ffi.sizeof(data)) + raknetSendBitStreamEx(bs, sampfuncs.HIGH_PRIORITY, sampfuncs.UNRELIABLE_SEQUENCED, 1) + raknetDeleteBitStream(bs) + end + -- metatable to access sync data and 'send' function + local mt = { + __index = function(t, index) + return data[index] + end, + __newindex = function(t, index, value) + data[index] = value + end + } + return setmetatable({send = func_send}, mt) +end +function find_lines() + local line1, line2 = "", "" + for a = 0, 2304 do + if sampTextdrawIsExists(a) then + local texts = sampTextdrawGetString(a) + local x, y = sampTextdrawGetPos(a) + if x == 530 and y == 198 then + line1 = texts + + end + if x == 599 and y == 198 then + line2 = texts + end + end + end + return line1, line2 +end + +function split(str, delim, plain) + local tokens, pos, plain = {}, 1, not (plain == false) --[[ delimiter is plain text by default ]] + repeat + local npos, epos = string.find(str, delim, pos, plain) + table.insert(tokens, string.sub(str, pos, npos and npos - 1)) + pos = epos and epos + 1 + until not pos + return tokens +end \ No newline at end of file diff --git a/pictures/download.png b/pictures/download.png new file mode 100644 index 0000000..7c13b4a Binary files /dev/null and b/pictures/download.png differ