AddCSLuaFile() local SligWolf_Addons = SligWolf_Addons if not SLIGWOLF_ADDON then SligWolf_Addons.AutoLoadAddon(function() end) return end local CONSTANTS = SligWolf_Addons.Constants local LIBEntities = SligWolf_Addons.Entities local LIBCoupling = SligWolf_Addons.Coupling local LIBPosition = SligWolf_Addons.Position local LIBPhysics = SligWolf_Addons.Physics local LIBTracer = SligWolf_Addons.Tracer local LIBCamera = SligWolf_Addons.Camera local hornSnd = SLIGWOLF_ADDON:GetSoundScriptName("horn") local dumpsterMdl = "models/sligwolf/garbagetruck/dumpster.mdl" local function GetDumpster(veh, vat) if not IsValid(veh) then return nil, nil end local fork = LIBEntities.GetChild(veh, "Prop_Fork") if not IsValid(fork) then return nil, nil end local vec_a = LIBPosition.VectorToLocalToWorld(fork, Vector(0, 125, -15)) local vec_b = LIBPosition.VectorToLocalToWorld(fork, Vector(0, 140, -15)) local trace = LIBTracer.Tracer(fork, vec_a, vec_b) local dumpster = trace.Entity if not IsValid(dumpster) then local dumpsterOnForkWeld = vat.dumpsterOnFork if IsValid(dumpsterOnForkWeld) then dumpsterOnForkWeld:Remove() end return nil, nil end if dumpster:GetModel() ~= dumpsterMdl then return nil, nil end local phys = dumpster:GetPhysicsObject() if not LIBPhysics.IsValidPhysObject(phys) then return nil, nil end return dumpster, phys end SLIGWOLF_ADDON:RegisterKeySettings("Cam_01", KEY_PAD_1, 0.25, "Extra Camera Left", "") SLIGWOLF_ADDON:RegisterVehicleOrder("Cam_01", nil, function(self, ply, veh) if not veh.sligwolf_is_garbagetruck then return end local ent = LIBEntities.GetChild(veh, "Camera_C3") LIBCamera.ToggleCamera(ent, ply) end) SLIGWOLF_ADDON:RegisterKeySettings("Cam_02", KEY_PAD_2, 0.25, "Extra Camera Front", "") SLIGWOLF_ADDON:RegisterVehicleOrder("Cam_02", nil, function(self, ply, veh) if not veh.sligwolf_is_garbagetruck then return end local ent = LIBEntities.GetChild(veh, "Camera_C4") LIBCamera.ToggleCamera(ent, ply) end) SLIGWOLF_ADDON:RegisterKeySettings("Cam_03", KEY_PAD_3, 0.25, "Extra Camera Right", "") SLIGWOLF_ADDON:RegisterVehicleOrder("Cam_03", nil, function(self, ply, veh) if not veh.sligwolf_is_garbagetruck then return end local ent = LIBEntities.GetChild(veh, "Camera_C1") LIBCamera.ToggleCamera(ent, ply) end) SLIGWOLF_ADDON:RegisterKeySettings("Cam_04", KEY_PAD_4, 0.25, "Extra Camera Back", "") SLIGWOLF_ADDON:RegisterVehicleOrder("Cam_04", nil, function(self, ply, veh) if not veh.sligwolf_is_garbagetruck then return end local ent = LIBEntities.GetChild(veh, "Camera_C2") LIBCamera.ToggleCamera(ent, ply) end) SLIGWOLF_ADDON:RegisterKeySettings("Cam_05", KEY_PAD_5, 0.25, "Extra Camera Fork", "") SLIGWOLF_ADDON:RegisterVehicleOrder("Cam_05", nil, function(self, ply, veh) if not veh.sligwolf_is_garbagetruck then return end local ent = LIBEntities.GetChild(veh, "Camera_C5") LIBCamera.ToggleCamera(ent, ply) end) SLIGWOLF_ADDON:RegisterKeySettings("Horn", KEY_R, 1.25, "Horn", "") SLIGWOLF_ADDON:RegisterVehicleOrder("Horn", nil, function(self, ply, veh) if not veh.sligwolf_is_garbagetruck then return end veh:EmitSound(hornSnd) end) SLIGWOLF_ADDON:RegisterKeySettings("Light", KEY_F, 0.25, "Headlight", "") SLIGWOLF_ADDON:RegisterVehicleOrder("Light", nil, function(self, ply, veh) if not veh.sligwolf_is_garbagetruck then return end local mainVehicle = LIBCoupling.GetTrailerMainVehicle(veh) if not IsValid(mainVehicle) then return end local trailerData = LIBCoupling.GetTrailerData(mainVehicle) trailerData.lightState = not trailerData.lightState veh:EmitSound(CONSTANTS.sndClick) self:LightsUpdateGlows(mainVehicle) end) SLIGWOLF_ADDON:RegisterKeySettings("IndicLeft", KEY_2, 0.25, "Indicator Left", "") SLIGWOLF_ADDON:RegisterVehicleOrder("IndicLeft", nil, function(self, ply, veh) if not veh.sligwolf_is_garbagetruck then return end local mainVehicle = LIBCoupling.GetTrailerMainVehicle(veh) if not IsValid(mainVehicle) then return end local trailerData = LIBCoupling.GetTrailerData(mainVehicle) if trailerData.indicatorHazzard then return end trailerData.indicatorDelay = 0 trailerData.indicatorR = false trailerData.indicatorL = not trailerData.indicatorL trailerData.indicatorState = trailerData.indicatorL self:LightsUpdateGlows(mainVehicle) end) SLIGWOLF_ADDON:RegisterKeySettings("IndicRight", KEY_3, 0.25, "Indicator Right", "") SLIGWOLF_ADDON:RegisterVehicleOrder("IndicRight", nil, function(self, ply, veh) if not veh.sligwolf_is_garbagetruck then return end local mainVehicle = LIBCoupling.GetTrailerMainVehicle(veh) if not IsValid(mainVehicle) then return end local trailerData = LIBCoupling.GetTrailerData(mainVehicle) if trailerData.indicatorHazzard then return end trailerData.indicatorDelay = 0 trailerData.indicatorR = not trailerData.indicatorR trailerData.indicatorL = false trailerData.indicatorState = trailerData.indicatorR self:LightsUpdateGlows(mainVehicle) end) SLIGWOLF_ADDON:RegisterKeySettings("IndicWarn", KEY_1, 0.25, "Warning Indicator", "") SLIGWOLF_ADDON:RegisterVehicleOrder("IndicWarn", nil, function(self, ply, veh) if not veh.sligwolf_is_garbagetruck then return end local mainVehicle = LIBCoupling.GetTrailerMainVehicle(veh) if not IsValid(mainVehicle) then return end local trailerData = LIBCoupling.GetTrailerData(mainVehicle) trailerData.indicatorDelay = 0 trailerData.indicatorHazzard = not trailerData.indicatorHazzard trailerData.indicatorState = trailerData.indicatorHazzard trailerData.indicatorL = trailerData.indicatorHazzard trailerData.indicatorR = trailerData.indicatorHazzard if trailerData.indicatorHazzard then trailerData.indicatorL = true trailerData.indicatorR = true end self:LightsUpdateGlows(mainVehicle) end) SLIGWOLF_ADDON:RegisterKeySettings("ForkGrab", KEY_4, 0.25, "Grab / Release Dumpster", "") SLIGWOLF_ADDON:RegisterVehicleOrder("ForkGrab", nil, function(self, ply, veh) if not veh.sligwolf_is_garbagetruck then return end local vat = self:GetEntityTable(veh) local fork = LIBEntities.GetChild(veh, "Prop_Fork") local ent, phys = GetDumpster(veh, vat) self:GrabDumpster(fork, veh, vat, ply, ent, phys) end) SLIGWOLF_ADDON:RegisterKeySettings("ForkUp", KEY_5, 0, "Move Fork Up", "") SLIGWOLF_ADDON:RegisterVehicleOrder("ForkUp", function(self, ply, veh) if not veh.sligwolf_is_garbagetruck then return end local vat = self:GetEntityTable(veh) if not vat.dumpsterOnFork then return end local _, phys = GetDumpster(veh, vat) if not IsValid(phys) then return end phys:SetVelocity(Vector(0, 0, 125)) self:SoundEdit(vat.sndFork, 4, 120, 0, 1, 0) end, nil, function(self, ply, veh) if not veh.sligwolf_is_garbagetruck then return end local vat = self:GetEntityTable(veh) self:SoundEdit(vat.sndFork, 5, 0, 0, 0, 0) end) SLIGWOLF_ADDON:RegisterKeySettings("ForkDown", KEY_6, 0, "Move Fork Down", "") SLIGWOLF_ADDON:RegisterVehicleOrder("ForkDown", function(self, ply, veh) if not veh.sligwolf_is_garbagetruck then return end local vat = self:GetEntityTable(veh) if not vat.dumpsterOnFork then return end local _, phys = GetDumpster(veh, vat) if not IsValid(phys) then return end phys:SetVelocity(Vector(0, 0, -125)) self:SoundEdit(vat.sndFork, 4, 120, 0, 1, 0) end, nil, function(self, ply, veh) if not veh.sligwolf_is_garbagetruck then return end local vat = self:GetEntityTable(veh) self:SoundEdit(vat.sndFork, 5, 0, 0, 0, 0) end) return true