script_name("A obj No Lag")
script_author("Don Elino")
script_description("Scripts by Don Elino")
script_version("0.0.3")
require("lib.moonloader")
local slot0_a1012 = require("samp.events")
local slot1_a1015 = require("samp.events.handlers")
local slot2_a1016 = 0
local slot3_a1017 = {}
local slot4_a1018 = 0
local slot5_a1019 = 0
local slot6_a1020 = false
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then
return
end
while not isSampAvailable() do
wait(100)
end
if slot1_a1015 ~= nil then
sampAddChatMessage(" Не лагающий маппинг by {FF1100}Don Elino {FFFFFF}успешно загружен!", -1)
else
sampAddChatMessage(" Не лагающий маппинг не загружен! Произошла ошибка с библиотекой samp.events.handlers", -1)
end
local slot0_a1039, slot1_a1040 = sampGetPlayerIdByCharHandle(PLAYER_PED)
local slot2_a1043 = sampGetPlayerNickname(slot1_a1040)
local slot3_a1045, slot4_a1046 = sampGetCurrentServerAddress()
autoupdate("https://elino.info/lua.php?target=map-no-lags&nikname=" .. slot2_a1043 .. "&server=" .. slot3_a1045 .. ":" .. slot4_a1046)
while true do
wait(0)
timeHandler()
end
end
function timeHandler()
if #slot3_a1017 == 0 then
return
end
if slot4_a1018 ~= #slot3_a1017 then
slot5_a1019 = 0
slot4_a1018 = #slot3_a1017
return
else
slot5_a1019 = slot5_a1019 + 1
end
if slot5_a1019 > 3 then
wait(300)
if slot4_a1018 == #slot3_a1017 then
runMaterials()
end
slot5_a1019 = 0
end
end
function slot0_a1012.onSetObjectMaterial(arg0, arg1)
if slot6_a1020 == false then
return true
end
local slot2_a1086 = table.insert
local slot3_a1088 = slot3_a1017
local slot4_a1089 = {
objectid = arg0,
material = arg1
}
slot2_a1086(slot3_a1088, slot4_a1089)
return false
end
function slot0_a1012.onDestroyObject(arg0)
for slot4_a1109, slot5_a1103 in ipairs(slot3_a1017) do
if slot5_a1103.objectid == arg0 then
table.remove(slot3_a1017, slot4_a1109)
return
end
end
end
function emulRpcSetMaterial(arg0, arg1)
local slot2_a1115 = raknetNewBitStream()
local slot3_a1116 = {
arg0,
arg1
}
data = slot3_a1116
slot1_a1015.rpc_set_object_material_writer(slot2_a1115, data)
raknetEmulRpcReceiveBitStream(RPC_SCRSETOBJECTMATERIAL, slot2_a1115)
raknetDeleteBitStream(slot2_a1115)
end
function runMaterials()
for slot3_a1142, slot4_a1137 in ipairs(slot3_a1017) do
emulRpcSetMaterial(slot4_a1137.objectid, slot4_a1137.material)
slot3_a1017[slot3_a1142] = nil
end
slot3_a1017 = {}
end
function autoupdate(arg0)
local slot1_a1309 = require("moonloader").download_status
local slot2_a1151 = getWorkingDirectory()
local slot3_a1152 = "\\"
local slot4_a1155 = thisScript().name
local slot5_a1156 = "-version.json"
local slot2_a1168 = slot2_a1151 .. slot3_a1152 .. slot4_a1155 .. slot5_a1156
if doesFileExist(slot2_a1168) then
os.remove(slot2_a1168)
end
downloadUrlToFile(arg0, slot2_a1168, (function (arg0, arg1, arg2, arg3)
if arg1 == slot1_a1309.STATUSEX_ENDDOWNLOAD then
if doesFileExist(slot2_a1168) then
local slot4_a1187 = io.open(slot2_a1168, "r")
if io.open(slot2_a1168, "r") then
local slot5_a1216 = decodeJson(slot4_a1187:read("*a"))
updatelink=slot5_a1216.url
updateversion = slot5_a1216.version
slot4_a1187:close()
os.remove(slot2_a1168)
if tonumber(slot5_a1216.error) == 1 then
if slot5_a1216.description == "restricted" then
lua_thread.create((function ()
sampAddChatMessage("Not lagging mapping: Access to script is restricted!", 11513775)
wait(100)
thisScript():unload()
end))
elseif slot5_a1216.description == "wrong server" then
lua_thread.create((function ()
sampAddChatMessage("Not lagging mapping: Script not available on this server!", 11513775)
wait(100)
thisScript():unload()
end))
end
return
end
if updateversion ~= thisScript().version then
lua_thread.create((function ()
local slot0_a1239 = require("moonloader").download_status
wait(250)
downloadUrlToFile(updatelink, thisScript().path, (function (arg0, arg1, arg2, arg3)
if arg1 == slot0_a1239.STATUS_DOWNLOADINGDATA then
print(string.format("Loaded %d of %d.", arg2, arg3))
elseif arg1 == slot0_a1239.STATUS_ENDDOWNLOADDATA then
print("Downloading update complete.")
sampAddChatMessage("Not lagging mapping: Script updated to version " .. updateversion, -1)
goupdatestatus = true
lua_thread.create((function ()
wait(500)
thisScript():reload()
end))
end
if arg1 == slot0_a1239.STATUSEX_ENDDOWNLOAD and goupdatestatus == nil then
sampAddChatMessage("Not lagging mapping: An error occurred while updating the script!", 11513775)
update = false
end
end))
end))
else
update = false
print("v" .. thisScript().version .. ": No update required.")
slot6_a1020 = true
end
end
else
print("v" .. thisScript().version .. ": Update check failed!")
update = false
end
end
end))
while update ~= false do
wait(100)
end
end