script_name("jReconnect")
script_description("/jrec (sec) - Обычный реконнект. /jrecn - Реконнект со сменой ника")
script_version("v.1")
script_author("{FF5F5F}teekyuu")
script_dependencies("SAMPFUNCS, SAMP")
require("lib.moonloader")
require("config.jRconfig")
function main()
while not isSampAvailable() do
wait(1000)
end
if jstart == 1 then
sampAddChatMessage("* [lua]: {0088ff}jReconnect. [ /jrec (sec) | /jrecn ] {FF5F5F}[ by teekyuu ]", 0xC1C1C1)
end
if jstart == 2 then
sampfuncsLog("{C1C1C1}* [lua]: {0088ff}jReconnect. [ /jrec (sec) | /jrecn ] {FF5F5F}[ by teekyuu ]")
end
sampRegisterChatCommand("jrec", jrec)
sampRegisterChatCommand("jrecn", jrecn)
sampSetClientCommandDescription("jrec", "(sec) {0088ff}- Реконнект. Без секунд - моментальный реконнект. {ffffff}*{0088ff}")
sampSetClientCommandDescription("jrecn", "(name) {0088ff}- Реконнект со сменой ника. {ffffff}*{0088ff}")
while true do
wait(0)
if reconid == true then
printString(string.format("Reconnect ~g~%d ~w~seconds", rid), --[[int]] 3000)
_, myId = sampGetPlayerIdByCharHandle(PLAYER_PED)
Nickname = sampGetPlayerNickname(myId)
sampSetLocalPlayerName(Nickname)
rti = rid * 1000
wait(rti)
ip, p = sampGetCurrentServerAddress()
sampConnectToServer(ip, p)
recon = false
reconid = false
end
if recon == true then
printString("Reconnect ~g~now", --[[int]] 3000)
sampSetLocalPlayerName(rname)
jti = jtime * 1000
wait(jti)
ip, p = sampGetCurrentServerAddress()
sampConnectToServer(ip, p)
recon = false
reconid = false
end
if isKeyDown(VK_SHIFT) and isKeyDown(VK_R) and not sampIsChatInputActive() and not sampIsDialogActive() then
recon = true
end
end
end
function jrec(param)
rid = string.match(param, '(%d+)')
if rid ~= nil then
reconid = true
else
recon = true
end
end
function jrecn(param)
local rname = string.match(param, '%s*(.+)')
if rname ~= nil then
sampSetLocalPlayerName(rname)
recon = true
else
sampAddChatMessage("[ Мысли ]: Реконнект со сменой ника [ /jrecn Nick ]", 0xC1C1C1)
end
end