• What is a null entity?
    3 replies, posted
Well, I am getting this error upon joining the game with a car addon installed. [CODE][ERROR] addons/pg cars/lua/autorun/speedometer_egoista_sgm.lua:82: Tried to use a NULL entity! 1. GetPos - [C]:-1 2. unknown - addons/pg cars/lua/autorun/speedometer_egoista_sgm.lua:82 Timer Failed! [SGM_UpdateSpeedometers_egoista][@addons/pg cars/lua/autorun/speedometer_egoista_sgm.lua (line 80)] [/CODE] It says "tried to use a null entity!" What is a null entity and how do I fix this issue? Here is the speedometer_egoista_sgm.lua [CODE]surface.CreateFont( "SGMSpeedometer_egoista", { size = 48, weight = 1000, antialias = true, additive = false, font = "Arial", }) local SpeedometerData = { ["models/sentry/egoista.mdl"] = { mphpos = Vector(12.32, -26, 43.8), mphang = Angle(80,0,0), mphscale = 0.1, mphcolor = Color(0,0,0,0), kmhpos = Vector(0, -37.1, 46.2), kmhang = Angle(105,0,0), kmhscale = 0.02, kmhcolor = Color(255,255,255,255), }, } local maxdistance = 500 local NearbyVehicles = {} local function DrawSpeedometer() for _, vehicle in pairs(NearbyVehicles) do if not IsValid(vehicle) then return end local data = SpeedometerData[vehicle:GetModel()] if not data then return end local velo = vehicle:GetVelocity():Length() local kmh = math.Round((velo / 10.9361329722) * 0.75) local mph = math.Round((velo / 17.6) * 0.75) local carpos = vehicle:GetPos() local carang = vehicle:GetAngles() surface.SetFont("SGMSpeedometer_egoista") if data.mphpos then local mphang = carang * 1 local mphpos = carpos + (mphang:Forward() * data.mphpos.x) + (mphang:Right() * data.mphpos.y) + (mphang:Up() * data.mphpos.z) mphang:RotateAroundAxis(mphang:Forward(), data.mphang.p) mphang:RotateAroundAxis(mphang:Up(), data.mphang.y) mphang:RotateAroundAxis(mphang:Right(), data.mphang.r) cam.Start3D2D(mphpos, mphang, data.mphscale) draw.SimpleText( mph, "SGMSpeedometer_egoista", 0, 0, data.mphcolor, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) cam.End3D2D() end if data.kmhpos then local kmhang = carang * 1 local kmhpos = carpos + (kmhang:Forward() * data.kmhpos.x) + (kmhang:Right() * data.kmhpos.y) + (kmhang:Up() * data.kmhpos.z) kmhang:RotateAroundAxis(kmhang:Forward(), data.kmhang.p) kmhang:RotateAroundAxis(kmhang:Up(), data.kmhang.y) kmhang:RotateAroundAxis(kmhang:Right(), data.kmhang.r) cam.Start3D2D(kmhpos, kmhang, data.kmhscale) draw.SimpleText( kmh, "SGMSpeedometer_egoista", 0, 0, data.kmhcolor, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) cam.End3D2D() end end end hook.Add("PostDrawTranslucentRenderables", "SGM_DrawSpeedometers_egoista", DrawSpeedometer) timer.Create("SGM_UpdateSpeedometers_egoista", 1, 0, function() local pos = LocalPlayer():GetPos() NearbyVehicles = {} for _, ent in pairs(ents.FindByClass("prop_vehicle_jeep")) do if pos:Distance(ent:GetPos()) < maxdistance then table.insert(NearbyVehicles, ent) end end end)[/CODE] Also, what is the best way to learn GLua? Or lua? I really need to learn it! Any help is appreciated. Thanks!
1. A null entity is an entity that doesnt exist, its erroring because lua is trying to point to a specific entity but it cant. 2. I really hope that isnt a paid addon 3. wiki.garrysmod.com
[QUOTE=Exploderguy;47480920]1. A null entity is an entity that doesnt exist, its erroring because lua is trying to point to a specific entity but it cant. 2. I really hope that isnt a paid addon 3. wiki.garrysmod.com[/QUOTE] It's a car off the workshop, how would I fix this problem? [editline]8th April 2015[/editline] Also, not sure if this does anything, but I found this in my lua/autorun/server Only appeared after I installed the cars.. local Blacklist = { ["STEAM_0:0:52470286"] = { "models/sentry/veneno.mdl", "models/sentry/veneno_new.mdl", "models/sentry/laferrari.mdl", "models/sentry/p1_new.mdl", "models/sentry/c7_new.mdl", }, } hook.Add("CanPlayerEnterVehicle", "SGMProCodar", function(ply, vehicle) local blockedmodels = Blacklist[ply:SteamID()] if blockedmodels and table.HasValue(blockedmodels, vehicle:GetModel()) then return false end end)
[QUOTE=ThatDesire;47480941]It's a car off the workshop, how would I fix this problem? [editline]8th April 2015[/editline] Also, not sure if this does anything, but I found this in my lua/autorun/server Only appeared after I installed the cars.. local Blacklist = { ["STEAM_0:0:52470286"] = { "models/sentry/veneno.mdl", "models/sentry/veneno_new.mdl", "models/sentry/laferrari.mdl", "models/sentry/p1_new.mdl", "models/sentry/c7_new.mdl", }, } hook.Add("CanPlayerEnterVehicle", "SGMProCodar", function(ply, vehicle) local blockedmodels = Blacklist[ply:SteamID()] if blockedmodels and table.HasValue(blockedmodels, vehicle:GetModel()) then return false end end)[/QUOTE] Apparently this guy [url]http://steamcommunity.com/id/monstergaminghd/[/url] can't use the cool cars
Sorry, you need to Log In to post a reply to this thread.