Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Slider = {};
- Slider.data = {};
- Slider.states = {};
- Slider.timers = {};
- Slider.targets = {};
- Slider.procces = {};
- Slider.animation = {};
- Slider.key = "h";
- function Slider:shader(vehicle)
- --print(self,vehicle)
- if self.data[vehicle] == nil then
- self.data[vehicle] = DxShader("files/texReplace.fx",0,0,true);
- self.targets[vehicle] = dxCreateRenderTarget(235,50,true)
- self.procces[vehicle] = 0;
- end
- return self.data[vehicle];
- end
- function Slider:work(_,vehicle)
- local shader = Slider:shader(vehicle)
- end
- addEventHandler("onClientRender",root,function()
- for vehicle,shader in pairs(Slider.data) do
- self = Slider
- if isElement(vehicle) then
- if self.states[vehicle] then
- self.procces[vehicle] = self.procces[vehicle] + 15
- else
- self.procces[vehicle] = self.procces[vehicle] - 15
- end
- if Slider.animation[vehicle] then
- dxSetRenderTarget(self.targets[vehicle],true)
- dxDrawRectangle(
- 0,
- 0,
- 235,
- self.procces[vehicle]/2,
- tocolor(0,0,0,255)
- );
- dxSetRenderTarget()
- dxSetShaderValue(shader, "gTexture", self.targets[vehicle])
- engineApplyShaderToWorldTexture(shader, "Nomer", vehicle)
- end
- if self.procces[vehicle] > 110 or self.procces[vehicle] < -1 then
- if self.procces[vehicle] > 110 then
- self.procces[vehicle] = 110
- else
- self.procces[vehicle] = 0
- end
- Slider.animation[vehicle] = false
- else
- vehicle:setData("SliderProcces",self.procces[vehicle])
- Slider.animation[vehicle] = true
- end
- else
- --shader:destroy()
- shader = nil
- end
- end
- end)
- addEventHandler("onClientKey",root,function(key,state)
- if key == Slider.key and state then
- if localPlayer.vehicle and localPlayer.vehicle:getOccupant() == localPlayer then
- if (localPlayer.vehicle:getData("SliderBuyed") or false) then
- local vehicle = localPlayer.vehicle
- if Slider.states[vehicle] == nil then
- Slider.states[vehicle] = true
- else
- Slider.states[vehicle] = not Slider.states[vehicle]
- end
- vehicle:setData("SliderState",Slider.states[vehicle])
- Slider:work(_,vehicle)
- end
- end
- end
- end)
- addEventHandler("onClientElementDataChange",root,function(data,_,value)
- if data == "SliderState" and source.type == "vehicle" then
- Slider.states[source] = value
- if Slider.data[source] == nil then
- Slider:work(_,source)
- end
- end
- if data == "SliderProcces" and source.type == "vehicle" then
- --Slider.procces[source] = value
- end
- end)
- addEventHandler("onClientRestore",root,function()
- for k,vehicle in ipairs(getElementsByType("vehicle")) do
- if isElementStreamedIn(vehicle) then
- --print('Восстановлено')
- Slider.animation[vehicle] = true
- end
- end
- end)
- addEventHandler("onClientElementStreamIn",root,function()
- if source.type == "vehicle" then
- if (source:getData("SliderState") or false) then
- Slider.states[source] = true
- Slider.procces[source] = source:getData("SliderProcces") or 0
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement