• Getting Car Model From Entity Name
    3 replies, posted
[B]This is SOLVED! Scroll down for the solution![/B] Hi there, Facepunch! I've been trying to figure out how to get the model of a vehicle from its entity name. By entity name, I mean, for example, "sw_forklift_truck". Help would be greatly appreciated! Best Regards and thanks in advance!
you have your models in your addon folder in game.
You could use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/FindByClass]ents.FindByClass[/url] and then use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetModel]Entity:GetModel[/url].
[QUOTE=Sean Bean;52447878]You could use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/FindByClass]ents.FindByClass[/url] and then use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetModel]Entity:GetModel[/url].[/QUOTE] Perfect, thank you so much! :) [editline]8th July 2017[/editline] Actually, this did not work, unfortunately. Let me rephrase my above post. I would like to get the model of a vehicle that is not yet spawned. The vehicle is in the spawnmenu and it has not been spawned. The only bit of data that I have is the vehicle's classname. Here's what I tried: [CODE] for k,v in pairs(Cars) do if ents.FindByClass( v.CarClassName ) then -- run some code end end [/CODE] [editline]8th July 2017[/editline] [B]I solved this![/B] Here's how I did it. I used the following code to get the corresponding model: [CODE]list.Get( "Vehicles" )[v.CarClassName].Model[/CODE]
Sorry, you need to Log In to post a reply to this thread.