Не знаю в чём проблема, спрва снизу должно появиться окошко, в котором будет написано Carhide OFF/On, но не работает
Клиент
local x, y = guiGetScreenSize()
local a_carhide = false
local b_carhide = false
function create_fade()
gui_cr_fade = {
fon = guiCreateStaticImage(x-165, y-102, 70, 24, 'img/f_b_2.png', false),
txt_1 = guiCreateLabel(x-157, y-98, x, y, "Hide: ", false),
txt_2 = guiCreateLabel(x-126, y-98, x, y, "OFF", false)
}
guiSetFont(gui_cr_hide.txt_1, 'default-bold-small')
guiSetFont(gui_cr_hide.txt_2, 'default-bold-small')
guiLabelSetColor(gui_cr_hide.txt_1, 255, 255, 255)
guiLabelSetColor(gui_cr_hide.txt_2, 255, 0, 0)
guiSetAlpha(gui_cr_hide.txt_1, tonumber(0.5))
guiSetAlpha(gui_cr_hide.txt_2, tonumber(0.5))
guiSetVisible(gui_cr_hide, true)
triggerServerEvent("check_a_carhide_s", getLocalPlayer(), carhide)
end
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()), function()
working = false
fileDelete("client.lua")
end
)
-----------------------------
--Getting state from server--
-----------------------------
function workingSetTrue(style)
if (style == 1) or (style == true) then
working = true
else
working = false
end
end
-----------------------------
--Bind keys to change state--
-----------------------------
function changeState(key,state)
local antilagState = getElementData(getLocalPlayer(),"carfade")
if (key == "F2") and (state == "down") then
if (antilagState == false) then
outputChatBox("Hidden cars Enabled",255,255,255,true)
guiSetText(gui_cr_fade.txt_2, "ON")
guiLabelSetColor(gui_cr_hide.txt_2, 0, 255, 0)
b_carhide = true
setElementData(getLocalPlayer(),"carfade",true)
if (working == true) then
antilagStart()
end
else
outputChatBox("Hidden cars Disabled",255,255,255,true)
guiSetText(gui_cr_fade.txt_2, "OFF")
guiLabelSetColor(gui_cr_hide.txt_2, 255, 0, 0)
b_carhide = false
antilagStop()
setElementData(getLocalPlayer(),"carfade,false)
end
end
end
bindKey("F2","down", changeState)
-----------------
--Start antilag--
-----------------
function antilagStart()
for key, players in ipairs(getElementsByType("player")) do
local cars = getPedOccupiedVehicle(players)
if (players ~= getLocalPlayer()) then
setElementDimension(players,1)
if (cars) then
setElementDimension(cars,1)
end
end
end
end
----------------
--Stop antilag--
----------------
function antilagStop()
for i, v in ipairs(getElementsByType("player")) do
local cars = getPedOccupiedVehicle(v)
if (v ~= getLocalPlayer()) then
setElementDimension(v,0)
if (cars) then
setElementDimension(cars,0)
end
end
end
end
---------------
--Call client--
---------------
function callClientFunction(funcname, ...)
local arg = { ... }
if (arg[1]) then
for key, value in next, arg do arg[key] = tonumber(value) or value end
end
loadstring("return "..funcname)()(unpack(arg))
end
addEvent("onServerCallsClientFunction", true)
addEventHandler("onServerCallsClientFunction", resourceRoot, callClientFunction)
Сервер
-Check if map is DM to enable antilag system--
-----------------------------------------------
function checkMapType(f)
if string.find(getMapName(), "[DM]", 1, true) then
callClientFunction(getRootElement(),"workingSetTrue",true)
DM = true
else
DM = false
callClientFunction(getRootElement(),"workingSetTrue",false)
callClientFunction(getRootElement(),"antilagStop")
end
end
addEvent("onMapStarting")
addEventHandler("onMapStarting",getRootElement(),checkMapType)
addEvent( "onRaceStateChanging", true )
addEventHandler( "onRaceStateChanging", getRootElement(),
function(newState)
if newState == "Running" then
if DM == true then
for i,pla in ipairs(getElementsByType("player")) do
if (getElementData(pla,"Antilag") == true) then
callClientFunction(pla,"antilagStart")
end
end
end
end
end
)
-------------------------------------
--Disable antilag for wasted player--
-------------------------------------
function onPlayerWasted()
callClientFunction(source,"antilagStop")
callClientFunction(source,"workingSetTrue",false)
end
addEventHandler("onPlayerWasted",getRootElement(f), onPlayerWasted)
-----------------------------------------
--Disable antilag if someone got hunter--
-----------------------------------------
function disableOnHunter(num,style,modelID)
if style == "vehiclechange" then
if modelID == 425 then
callClientFunction(source,"workingSetTrue",false)
callClientFunction(source,"antilagStop")
end
end
end
addEvent("onPlayerPickUpRacePickup")
addEventHandler("onPlayerPickUpRacePickup",getRootElement(),disableOnHunter)
---------------
--Call client--
---------------
function callClientFunction(client, funcname, ...)
local arg = { ... }
if (arg[1]) then
for key, value in next, arg do
if (type(value) == "number") then arg[key] = tostring(value) end
end
end
-- If the clientside event handler is not in the same resource, replace 'resourceRoot' with the appropriate element
triggerClientEvent(client, "onServerCallsClientFunction", resourceRoot, funcname, unpack(arg or {}))
end