I’ve been trying to create a derma panel button that spawns an addon (photon and SGM vehicle to be precise). I’ve literally spent the last 6 hours on this. I’ve been searching, googling and found a few things. Keep in mind, it’s not just one addon, it’s ALL of them I can’t figure out. I was able to do this after MANY hours to spawn custom npc and I figured it would be a similar process.
from the developer of the mod: http://forum.facepunch.com/showthread.php?t=1436368 I found this :
local ent = ents.Create("prop_vehicle_jeep") -- all your entity setting up goes here if youWantThisAsAPhotonCar then ent.VehicleTable = list.Get("Vehicles")["photonnameyouwant"] end ent:Spawn()
local ent = ents.Create ("prop_vehicle_jeep") ent:SetModel ("models/sentry/caison_fire.mdl") ent:SetPos(hit) if "Caison Fire Truck" then ent.VehicleTable = list.Get("Vehicles")["Emergency Vehicles"] //have to pull up the correct vehicle for the photon script to work end ent:Spawn()
Right now this is as far as I can get on my own.
local function SpawnVehicle(ply, class) local vehicle = list.Get("Vehicles")[class] if not vehicle then return end local car = ents.Create(vehicle.Class) if not car then return end car:SetModel(vehicle.Model) if vehicle.KeyValues then for k, v in pairs(vehicle.KeyValues) do car:SetKeyValue(k, v) end end car.VehicleName = class car.VehicleTable = vehicle car.Owner = ply local pos = Vector(0,0,0) local ang = Angle(0,0,0) car:SetPos(pos) car:SetAngles(ang) car:Spawn() car:Activate() car:SetCollisionGroup(COLLISION_GROUP_WEAPON) car.ClassOverride = vehicle.Class if vehicle.Members then table.Merge(car, vehicle.Members) end gamemode.Call("PlayerSpawnedVehicle", ply, car) end
With help, I’ve been able to get a long output of the vehicle table that contains some information as a txt file but I do not know what the table names are actually called and where everything goes.
EDIT : Right now I should mention none of these resources are in my gamemode mode directory because they are still in the root folder for garrysmod. That shouldn’t matter correct?