script_name("Autopost")
script_author("Carti_Carter")
local is_active = false
function main()
while not isSampAvailable() do wait(0) end
sampRegisterChatCommand("autopost", toggle_autopost)
sampAddChatMessage("{00FF00}Autopost script loaded. Type /autopost to toggle.", -1)
while true do
wait(0)
if is_active then
wait(200000) -- 200 seconds
if is_active then
pressKey(0x4E) -- Virtual Key Code for "N"
wait(50)
releaseKey(0x4E)
sampAddChatMessage("{00FF00}Pressed 'N' automatically.", -1)
end
end
end
end
function toggle_autopost()
is_active = not is_active
local status = is_active and "enabled" or "disabled"
sampAddChatMessage("{FFFF00}Autopost is now " .. status, -1)
end
function pressKey(key)
lua_thread.create(function()
require("sampfuncs")
require("moonloader")
local ffi = require("ffi")
ffi.cdef[[
void keybd_event(unsigned char bVk, unsigned char bScan, unsigned long dwFlags, unsigned long dwExtraInfo);
]]
ffi.C.keybd_event(key, 0, 0, 0)
end)
end
function releaseKey(key)
lua_thread.create(function()
local ffi = require("ffi")
ffi.cdef[[
void keybd_event(unsigned char bVk, unsigned char bScan, unsigned long dwFlags, unsigned long dwExtraInfo);
]]
ffi.C.keybd_event(key, 0, 2, 0)
end)
end