script_name("extraMessages")
script_version_number("0.3.1")
script_description("Divides one long message into two short messages. Upgrade Advance-RP SMS system")
script_author("AppleThe")
local sampev = require 'lib.samp.events'
commands = {"f", "r", "t", "n", "w", "s"}
bi = false
function sampev.onSendCommand(msg)
if bi then bi = false; return end
local cmd, msg = msg:match("/(%S*) (.*)")
if msg == nil then return end
-- cmd = cmd:lower()
--Ðàöèÿ, ðàäèî, ÎÎÑ ÷àò, øåïîò, êðèê (ñ ïîääåðæêîé ïåðåíîñà ÎÎÑ-ñêîáîê)
for i, v in ipairs(commands) do if cmd == v then
local length = msg:len()
if msg:sub(1, 2) == "((" then
msg = string.gsub(msg:sub(4), "%)%)", "")
if length > 80 then divide(msg, "/" .. cmd .. " (( ", " ))"); return false end
else
if length > 80 then divide(msg, "/" .. cmd .. " ", ""); return false end
end
end end
--ÐÏ êîìàíäû
if cmd == "me" or cmd == "do" then
local length = msg:len()
if length > 75 then divide(msg, "/" .. cmd .. " ", "", "ext"); return false end
end
--SMS
if cmd == "sms" then
local msg = "{}" .. msg
local number, _msg = msg:match("{}(%d+) (.*)")
local msg = msg:sub(3)
if _msg == nil then -- åñëè íîìåð íå óêàçàí, èùåòñÿ áëèæàéøåå ïîëó÷åííîå/îòïðàâëåííîå ñîîáùåíèå
for i = 1, 99 do -- íîìåð áåðåòñÿ èç íåãî
local test = sampGetChatString(i):match("SMS: .* | .*: (.*)")
if test ~= nil then number = string.match(test, ".* %[.*%.(%d+)%]") end
end
else msg = _msg end
if number == nil then return end
local length = msg:len()
-- long SMS
if length > 66 then divide(msg, "/sms " .. number .. " ", "", "sms"); return false end
-- short SMS
if length < 66 then bi = true; sampSendChat("/sms " .. number .. " " .. msg); return false end
end
end
function sampev.onServerMessage(color, text)
if color == -65281 and text:find(" %| Ïîëó÷àòåëü: ") then
return {bit.tobit, text} -- return {bit.tobit(0xFFCC00FF), text}
end
end
function sampev.onSendChat(msg) -- IC ÷àò
if bi then bi = false; return end
local length = msg:len()
if length > 90 then
divide(msg, "", "")
return false
end
end
function divide(msg, beginning, ending, doing) -- ðàçäåëåíèå ñîîáùåíèÿ msg íà äâà
if doing == "sms" then limit = 57 else limit = 72 end
-- -- -- ÂÅÐÑÈß Ñ ÏÐÈÎÐÈÒÅÒÎÌ ÒÅÊÑÒÀ ÄËß ÏÅÐÂÎÃÎ ÑÎÎÁÙÅÍÈß (ÕÓÅÒÀ) -- -- --
-- local one, two = string.match(msg:sub(limit), "(%S*) (.*)")
-- if one == nil then one = "" end
-- local one, two = msg:sub(1, limit - 1) .. one .. "...", "..." .. two
-- ÂÅÐÑÈß Ñ ÏÐÈÎÐÈÒÅÒÎÌ ÒÅÊÑÒÀ ÄËß ÂÒÎÐÎÃÎ ÑÎÎÁÙÅÍÈß (ÇÁÑ ÍÎ ÍÅ ÐÀÁÎÒÀÅÒ) --
-- local one, two = string.match(msg:sub(1, msg:len() - limit), "(.*) (.*)")
-- if two == nil then two = "" end
-- local one, two = one .. "...", "..." .. two .. msg:sub(msg:len() - limit + 1, msg:len())
-- ÂÅÐÑÈß Ñ ÏÐÈÎÐÈÒÅÒÎÌ ÒÅÊÑÒÀ ÄËß ÂÒÎÐÎÃÎ ÑÎÎÁÙÅÍÈß (ÏÎÊÀ ×ÒÎ ÐÀÁÎÒÀÅÒ) --
local one, two = string.match(msg:sub(1, limit), "(.*) (.*)")
if two == nil then two = "" end
local one, two = one .. "...", "..." .. two .. msg:sub(limit + 1, msg:len())
bi = true; sampSendChat(beginning .. one .. ending)
if doing == "ext" then
beginning = "/do "
if two:sub(-1) ~= "." then two = two .. "." end
end
bi = true; sampSendChat(beginning .. two .. ending)
end
function main()
if not isCleoLoaded() or not isSampfuncsLoaded() or not isSampLoaded() then return end
while not isSampAvailable() do wait(100) end
if not sampGetCurrentServerName():find("Advance RolePlay") then return end
wait(-1)
end