Need help spawning a workshop vehicle

I have tried searching through the first few pages of google and couldn’t seem to find something that wasn’t apparently outdated. If anyone can link me to a tutorial or explain how to spawn workshop entities on the map it would be much appreciated.

So far all I have is this included in my init file:
[LUA]function GM:InitPostEntity()
local Car=ents.Create(“sierralowtdm”)
Car:SetPos(Vector(-3718.287354, 12658.525391, 217.026047))
Car:SetAngles(Angle(6.226459, -177.686066, -0.000160))
Car:Spawn()
end[/LUA]

And I get this error:
Attempted to create unknown entity type sierralowtdm!
[ERROR] gameodes/!?/gamemode/init.lua:9001: Tried to use a NULL entity!
1. SetPos - [C]:-1
2. unknown - gamemodes/!?/gamemode/init.lua:9001

“sierralowtdm” it’s not a valid entity name, that’s why this won’t spawn

Thanks for the reply.

How can I get the valid entity name? I am trying to spawn a vehicle from the GMC TDM cars pack.

spawn the vehicle, look at this, and write in console

ent_setname asdf

This will print in the console the name

Ok, so I put that in console and I got this:
Set the name of prop_vehicle_jeep to asdf
So I’m not sure what to do now. Just replacing “sierralowtdm” with “prop_vehicle_jeep” obviously won’t work. I would also need to put the path for the individual model, script file, ect. The problem is that there is no paths to those things because I am trying to spawn the vehicle from a gma workshop file. Please reply if you know how this can be done, or if I actually have to extract the files from the gma format to spawn the vehicle (would kind of defeat the purpose of workshop).

That’s pretty bad, i don’t have idea how TDM cars works…

Surely there is a way? Someone must know how to do this.

The guy who built tdm cars…It’s a car entity with new different models and configurations that only the author would know how to make it by code

My question isn’t just specific to TDM cars. How do you spawn entities that you add to the server via workshop?

There must be a way to do this. For example, if you want to give someone a weapon from inside of a gma file, you just put Give:ply(“weapon_m9k_m3”) or something like that. You don’t have to extract the files from the gma file, upload them to the server, and go through all that headache. Surely some hero will come with a solution?

To spawn a TDM car, you just spawn “prop_vehicle_jeep”, set the Model, Position, Angle, SetKeyValue “vehiclescript” to the script.txt provided by TDM, Spawn and Activate it.

Example:


concommand.Add( "spawnvehicle", function( _p, _cmd, _args )
	local _v = ents.Create( "prop_vehicle_jeep" ); -- Type of vehicle to spawn.

	// Just in case the entity creation was unsuccessful.
	if ( !IsValid( _v ) ) then return; end

	_v:SetPos( _p:GetEyeTrace( ).HitPos + Vector( 0, 0, 50 ) ); -- Set vehicle position to spawn where we are looking, but off the ground 50 units ( where 16 units = 1 foot ).
	_v:SetAngles( _p:GetAngles( ) + Angle( 0, 90, 0 ) ); -- Vehicles are rotated 90, so Left or so is typically their "Front"...
	_v:SetModel( "models/tdmcars/blah.mdl" );
	-- _v:SetSkin( 1 ); -- Optional, set the active skin.. For TDM it is usually 0-15 / 1-16..
	_v:SetKeyValue( "vehiclescript", "scripts/vehicles/jeep.txt" );
	_v:Spawn( );
	_v:Activate( ); -- Activate needed for some vehicles such as prop_vehicle_airboat or it'll crash the server


To spawn other entities, you can use ents.Create to spawn them in the world. You can use Player:Give to give a weapon entity, etc etc…

If you want to list all files inside of a GMA file so you know which model to use, etc… You can list them using file.Find( “*”, title_of_workshop_item );
I made a tool that does this… Example: https://dl.dropboxusercontent.com/u/26074909/tutoring/_file_structure/addon_info_CLIENT.txt
https://dl.dropboxusercontent.com/u/26074909/tutoring/_file_structure/addon_info_SERVER.txt

It’ll be released soon on my dev-base… Basically it lists all files, and gives a brief overview ( maps, models, etc )…

But, because you’re having trouble finding model names, and other file-names without extracting… This may help you… The function to return a list of files: https://dl.dropboxusercontent.com/u/26074909/tutoring/_utilities/release/_get_addon_files.lua.html

it is used ( a newer / updated version will be released in fileio; but the file-list generator uses the addon table ):


for k, v in pairs( engine.GetAddons( ) ) do
	local _files = fileio:GenerateAddonFileList( v );
	local _info = fileio:GenerateAddonInfoList( _files );
end

I knew it, I just had to believe! Thanks hero, the truck has been spawned!