Скрипт для быстрого слива карт игры в дурака SRP Для прохождения заданий
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
durak-speed-edition/durak_speed_edition.lua

184 lines
6.4 KiB

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