• [HELP] Simple Prop Protection causing CalcView error
    0 replies, posted
Hi, I've been looking for a script that can deal damage to all props in garrys mod and have found exactly what I'm looking for, how ever it's causing some issues and I'm hoping someone knows why it's not working :D >> Addons >> SPD >> LUA >> AUTORUN >> SERVER >> spd.LUA if !ConVarExists("spd") then CreateConVar("spd", '5', FCVAR_NOTIFY) end if !ConVarExists("spd_fire") then CreateConVar("spd_fire", '2', FCVAR_NOTIFY) end local function SPD_Main_Dmg_Hook(ent, inflictor, attacker, amount) local con_spd_val = GetConVarNumber("spd") --Since we only need to call it once and we are going to use the val twice... --There is a reason for the order of operations --We don't call the function unless we have too (and therefore avoid a useless overhead) if ent and ent.IsValid and (con_spd_val > 0) and ent:IsValid() then if not ent.SPD_Data then ent.SPD_Data = {} end --The reason this is in 2 steps is that I don't want short cut evaluation biting us in the ass --Because both the value nil and the value false equates to false in a boolean check if ent.SPD_Data.Invalid then return elseif (ent.SPD_Data.Invalid == nil) and (not (ent:GetClass() ~= "prop_physics" or ent:Health() == 0)) then ent.SPD_Data.Invalid = true return else ent.SPD_Data.Invalid = false end if not ent.SPD_Data.Health then ent.SPD_Data.Health = ent:GetPhysicsObject():GetMass() end local e_pos = ent:GetPos() local mass = ent:GetPhysicsObject():GetMass() local colmod = ent.SPD_Data.Health / mass ent.SPD_Data.Health = ent.SPD_Data.Health - amount / con_spd_val ent:SetColor(255, 255 * colmod, 255 * colmod, 255) if math.random(1, 100) < GetConVarNumber("spd_fire") then ent:Ignite(10, 20) end if ent.SPD_Data.Health < (mass * 0.5) then ent:GetPhysicsObject():EnableMotion(true) end if (ent.SPD_Data.Health < (mass * 0.25)) and ent:IsConstrained() then local effect = EffectData() effect:SetStart(e_pos) effect:SetOrigin(e_pos + Vector(0, 0, 10)) effect:SetScale(mass) util.Effect("cball_explode", effect) constraint.RemoveAll(ent) end if ent.SPD_Data.Health < 0 then local effect = EffectData() effect:SetStart(e_pos + Vector(0, 0, 10)) -- this was missing pos effect:SetOrigin(e_pos + Vector(0, 0, 10)) effect:SetScale(mass) util.Effect("Explosion", effect) ent:Remove() end end end hook.Add("EntityTakeDamage", "spdEntityTakeDamage", SPD_Main_Dmg_Hook) Info.txt: "AddonInfo" { "name" "Simple Prop Damage" "version" "1" "up_date" "" "author_name" "Ltp0wer and Wizzard" "author_email" "mmmcoke@gmail.com" "author_url" "www.ltp0wer.com" "info" "Simple Prop Damage System" "override" "0" } When someone is killed, after being in a vehicle i get the following error message. ERROR: GAMEMODE:'CalcView' Failed: base/gamemode/cl_init.lua:443: attempt to call method 'GetVehicle' (a nil value) and it loops until you exit the game. I'm using the original sandbox game mode, and the other mods seem to work fine, such as PHX, WireMod and some others. I hope someone knows the cause of this issue and can provide a solution, as it renders this entire script useless. Thank you, Jordan Dyckes (Develio13).
Sorry, you need to Log In to post a reply to this thread.