I really just don't get it...
Using SCars and DerpInv. Whenever I try to get a SCar out of my Inventory, it throws me this:
[CODE]
[ERROR] addons/drpinv/lua/autorun/server/drpinv.lua:785: attempt to index local 'newVehicle' (a nil value)
1. unknown - addons/drpinv/lua/autorun/server/drpinv.lua:785
2. unknown - lua/includes/modules/concommand.lua:69
[/CODE]
Have a look at the function;
[CODE]
local ent = ents.Create(newVehicle.Class) --This is the Line 785
if not ent then return "" end
ent:SetModel(newVehicle.Model)
if newVehicle.KeyValues then
for k, v in pairs(newVehicle.KeyValues) do
ent:SetKeyValue(k, v)
end
end
[/CODE]
Could someone help me out? I know SCars are spawned in a special way, but still I dont get it.
The table newVehicle is nil, is defined maybe locally inside another function? I think we're going to need more code.
Heres the whole Vehicle Function/Hook
[CODE]
--- vehicles ---
local function dropvehicle(ply, cmd, args)
local item = tonumber(args[1])
if !item or ply.inv.vehicles[item] == nil then
if shouldlog:GetBool() then
print("[DrpInv]: " .. ply:Nick() .. " hat versucht unzulässiges Fahrzeug " .. item .. " zu benutzen!")
end
return
end
local pos = ply:EyePos()
local tracedata = {}
tracedata.start = pos
tracedata.endpos = pos+(ply:GetForward()*150)
tracedata.filter = ply
local tr = util.TraceLine(tracedata)
local info = vehicle_list[ply.inv.vehicles[item].model]
local newVehicle = list.Get("Vehicles")[info.realname]
local ent = ents.Create(newVehicle.Class)
if not ent then return "" end
ent:SetModel(newVehicle.Model)
if newVehicle.KeyValues then
for k, v in pairs(newVehicle.KeyValues) do
ent:SetKeyValue(k, v)
end
end
local Angles = ply:GetAngles()
Angles.pitch = 0
Angles.roll = 0
Angles.yaw = Angles.yaw + 180
ent:SetAngles(Angles)
ent:SetPos(tr.HitPos + tr.HitNormal*10)
ent.VehicleName = info.realname
ent.VehicleTable = newVehicle
ent:CPPISetOwner(ply)
ent:Spawn()
ent:Activate()
ent.SID = ply.SID
ent.ClassOverride = newVehicle.Class
if newVehicle.Members then
table.Merge(ent, newVehicle.Members)
end
ent:Own(ply)
gamemode.Call("PlayerSpawnedVehicle", ply, ent) -- VUMod compatability
if shouldlog:GetBool() then
print("[DrpInv]: " .. ply:Nick() .. " spawnte Fahrzeug: " .. ply.inv.vehicles[item].realname .. "!")
end
ply.inv._size = ply.inv._size - 1
ply:RemoveVehicle(item)
end
concommand.Add("drp_dropvehicle", dropvehicle)
[/CODE]
So, this is the only function where this "NewVehicle" comes to use.
Also, I got this Error when someone tries to take in a SCar
[CODE]
[ERROR] addons/drpinv/lua/autorun/server/drpinv.lua:795: attempt to index local 'newVehicle' (a nil value)
1. unknown - addons/drpinv/lua/autorun/server/drpinv.lua:795
2. unknown - lua/includes/modules/concommand.lua:69
[/CODE]
This is the function:
[CODE]
for i=1,4 do
local Passenger_ent = ent:GetPassenger(i)
if not Passenger_ent then
Passenger_ent = nil
end
if not Passenger_ent == nil then
Passenger_ent:ExitVehicle( )
end
end
[/CODE]
PUSH
Still need help though ;/
PUSH
Sorry, you need to Log In to post a reply to this thread.