• Spawning Addon Cars
    9 replies, posted
Here's my Car Dealer function [lua] include('shared.lua') include('sh_player.lua') include("gamemode/init.lua") function CarDealer() local Jeep local DFrame1 DFrame1 = vgui.Create('DFrame') DFrame1:SetSize(427, 327) DFrame1:Center() DFrame1:SetTitle('Car Dealer') DFrame1:SetDeleteOnClose(false) DFrame1:MakePopup() Jeep = vgui.Create('SpawnIcon', DFrame1) Jeep:SetPos(5, 25) Jeep:SetToolTip('Drive around in style with this.. Crappy jeep') Jeep.DoClick = function( Jeep ) surface.PlaySound( "ui/buttonclickrelease.wav" ) RunConsoleCommand("SpawnJeep", 1) end Jeep:SetModel("models/buggy.mdl") chat.AddText(Color(155,255,128), "Car Dealer: ",Color(155,255,255), "Welcome to my junk yard! How may i help you?" ) end usermessage.Hook("CarNPCUsed", CarDealer) [/lua] It was made to spwan the jeep (Duhhh) But it didnt seem to work ether... But i want to have it spawn cutom cars that i added into the servers addon folder.. How would i do this? PS:The tool tip doesn't seem to work ether.. :/
[code]spawnvehicle = ents.Create("prop_vehicle_jeep") spawnvehicle:SetModel("models/Mustang.mdl") spawnvehicle:SetKeyValue("vehiclescript", "scripts/vehicles/Mustang_test.txt") spawnvehicle:SetPos(player:GetEyeTrace().HitPos) spawnvehicle:Spawn()[/code]
[QUOTE=Busymonkey;23922693][code]spawnvehicle = ents.Create("prop_vehicle_jeep") spawnvehicle:SetModel("models/Mustang.mdl") spawnvehicle:SetKeyValue("vehiclescript", "scripts/vehicles/Mustang_test.txt") spawnvehicle:SetPos(player:GetEyeTrace().HitPos) spawnvehicle:Spawn()[/code][/QUOTE] Thats not what i asked for... I want to spawn custom cars that i downloaded from gmod.org..
[QUOTE=gameguysz;23929651]Thats not what i asked for... I want to spawn custom cars that i downloaded from gmod.org..[/QUOTE] It is what you asked for. You download the Jeep from garrysmod.org, you got the models, sounds ect. You just place all in the correct directory, which most goes in gamemode/content directory. Above he is giving you what you asked for.
[QUOTE=Cartguy;23930087]It is what you asked for. You download the Jeep from garrysmod.org, you got the models, sounds ect. You just place all in the correct directory, which most goes in gamemode/content directory. Above he is giving you what you asked for.[/QUOTE] Well here is my spawnjeep function that is called when the player presses the buy car button [lua] function SpawnJeep( ply ) //setpos -2589.514404 6447.980469 -363.968750;setang 36.903870 -1.365985 0.000000 if ply:Money_Get() >= 100 then ply:Money_Take(100) local vehicle = ents.Create("prop_vehicle_jeep") ent:SetKeyValue("vehiclescript","scripts/vehicles/jeep_test.txt") ent:SetModel("models/buggy.mdl") ent:SetPos(Vector(-2590,6448,-365)) ent:SetAngles(Vector(37, 0, 0)) ent:Spawn() else LocalPlayer:ChatPrint(Color(150,255,128), "Car Dealer: ",Color(150,255,255), "I don't think you can aford this" ) end end concommand.Add("SpawnJeep",SpawnJeep) [/lua] Now i added the folder into the content section of my gamemode, now it looks like this [lua] function SpawnJeep( ply ) //setpos -2589.514404 6447.980469 -363.968750;setang 36.903870 -1.365985 0.000000 if ply:Money_Get() >= 100 then ply:Money_Take(100) local vehicle = ents.Create("prop_vehicle_jeep") ent:SetModel("content\Fueled Mod Vehicle Pack\models\lambo\lambo.mdl") ent:SetKeyValue("vehiclescript","content\Fueled Mod Vehicle Pack\scripts\vehicles\lambo.txt") ent:SetPos(Vector(-2590,6448,-365)) ent:SetAngles(Vector(37, 0, 0)) ent:Spawn() else LocalPlayer:ChatPrint(Color(150,255,128), "Car Dealer: ",Color(150,255,255), "I don't think you can aford this" ) end end concommand.Add("SpawnJeep",SpawnJeep) [/lua]
[QUOTE=gameguysz;23930546]Well here is my spawnjeep function that is called when the player presses the buy car button [lua] function SpawnJeep( ply ) //setpos -2589.514404 6447.980469 -363.968750;setang 36.903870 -1.365985 0.000000 if ply:Money_Get() >= 100 then ply:Money_Take(100) local vehicle = ents.Create("prop_vehicle_jeep") ent:SetKeyValue("vehiclescript","scripts/vehicles/jeep_test.txt") ent:SetModel("models/buggy.mdl") ent:SetPos(Vector(-2590,6448,-365)) ent:SetAngles(Vector(37, 0, 0)) ent:Spawn() else LocalPlayer:ChatPrint(Color(150,255,128), "Car Dealer: ",Color(150,255,255), "I don't think you can aford this" ) end end concommand.Add("SpawnJeep",SpawnJeep) [/lua] Now i added the folder into the content section of my gamemode, now it looks like this [lua] function SpawnJeep( ply ) //setpos -2589.514404 6447.980469 -363.968750;setang 36.903870 -1.365985 0.000000 if ply:Money_Get() >= 100 then ply:Money_Take(100) local vehicle = ents.Create("prop_vehicle_jeep") ent:SetModel("content\Fueled Mod Vehicle Pack\models\lambo\lambo.mdl") ent:SetKeyValue("vehiclescript","content\Fueled Mod Vehicle Pack\scripts\vehicles\lambo.txt") ent:SetPos(Vector(-2590,6448,-365)) ent:SetAngles(Vector(37, 0, 0)) ent:Spawn() else LocalPlayer:ChatPrint(Color(150,255,128), "Car Dealer: ",Color(150,255,255), "I don't think you can aford this" ) end end concommand.Add("SpawnJeep",SpawnJeep) [/lua][/QUOTE] Change your [b]content\Fueled Mod Vehicle Pack[/b] folder so that the folder has no spaces in it, then change so in the code Example: content\Fueled_Mod_Vehicle_Pack
[QUOTE=Cartguy;23930721]Change your [B]content\Fueled Mod Vehicle Pack[/B] folder so that the folder has no spaces in it, then change so in the code Example: content\Fueled_Mod_Vehicle_Pack[/QUOTE] Other then that it should work? Thanks :)
You dont need to add it into "content" of your gamemode. If it's an addon, just put it in the servers addons folder. Much easier.
[QUOTE=Busymonkey;23935063]You dont need to add it into "content" of your gamemode. If it's an addon, just put it in the servers addons folder. Much easier.[/QUOTE] We'll i know that, i just find this way easier that's all
Yet you have to rename the folders and stuff, but hey - whatever floats your boat.
Sorry, you need to Log In to post a reply to this thread.