Creating a vehicle with multiple seats?

Hey I was wondering if it was possible to make a vehicle with seats as follows in CSGO (or any other engine for that matter) :

-driver (cannot use guns or vehicle turret)
-passenger (can only use held guns)
-gunner (can only use vehicle turret)

I have a model ready to go, and have been reading what little documentation I can find on the subject, but I’ve got little information on how to attach seats or apply rules to them…

Honestly, normal HL2 script files (.txt’s) wont cut it. This is something you will need some good skills in LUA creation, and even then, it will only be good in Garry’s Mod

I tried importing Wolf’s leopard tank in to gmod once…

Why is this in mapping? This is a modelling question.

Using Sourcemod I was able to get a drivable vehicle with passengers, but they couldn’t use weapons. However, there might be a way to implement weapons.

There’s a picture of it here:

The technique is to create a vehicle model and then once its skeleton is set up you import the CS:GO skeleton into the vehicle and put it in the driver’s seat. Using $bonemerge in the .qc lets the skeleton of a spawned ragdoll model sit inside the vehicle and hold the wheel. Here is a sample .qc for a CS:GO car with this functionality:


$cd "C:\Source Stuff\Modeling\Car Project
atalya_mustang"
$modelname "natalya/vehicles/natalyas_mustang_csgo.mdl"
$model "Body" "natalya_mustang_csgo.smd"
$model "Wheels" "n_m_wheels.smd"
$poseparameter vehicle_wheel_fl_height 0.00 1.00
$poseparameter vehicle_wheel_fr_height 0.00 1.00
$poseparameter vehicle_wheel_rl_height 0.00 1.00
$poseparameter vehicle_wheel_rr_height 0.00 1.00
$poseparameter vehicle_steer -1.00 1.00
$poseparameter vehicle_wheel_fl_spin -180.00 180.00 360.00
$poseparameter vehicle_wheel_fr_spin -180.00 180.00 360.00
$poseparameter vehicle_wheel_rl_spin -180.00 180.00 360.00
$poseparameter vehicle_wheel_rr_spin -180.00 180.00 360.00
$cdmaterials "models
atalya\vehicles\"
$texturegroup skinfamilies
{
	{"new_colour_0.vmt" "plate_00.vmt" "new_colour_0.vmt"}
	{"new_colour_1.vmt" "plate_01.vmt" "new_colour_1.vmt"}
	{"new_colour_2.vmt" "plate_02.vmt" "new_colour_2.vmt"}
	{"new_colour_3.vmt" "plate_03.vmt" "new_colour_3.vmt"}
	{"new_colour_4.vmt" "plate_04.vmt" "new_colour_4.vmt"}
	{"new_colour_5.vmt" "plate_05.vmt" "new_colour_5.vmt"}
	{"new_colour_6.vmt" "plate_06.vmt" "new_colour_6.vmt"}
	{"new_colour_7.vmt" "plate_00.vmt" "new_colour_7.vmt"}
	{"new_colour_9.vmt" "plate_01.vmt" "new_colour_9.vmt"}
	{"new_colour_0.vmt" "plate_07.vmt" "new_colour_0.vmt"}
}
$hboxset "default"

$attachment "vehicle_driver_eyes" "car.view" 2.00 4.00 0.00 rotate -0 0 -90
$attachment "vehicle_feet_passenger0" "car.col" 4.00 14.00 -18.40 rotate -0 0 -90
$attachment "vehicle_feet_passenger1" "car.col" 4.00 14.00 18.40 rotate -0 0 -90
$attachment "vehicle_driver_exit" "car.col" -15.00 0.00 -80.00 rotate -0 0 -90
$attachment "vehicle_passenger_exit" "car.col" -15.00 0.00 80.00 rotate -0 0 -90
$attachment "wheel_fl" "car.wheel_fl" 0.00 0.00 0.00 rotate 0.00 0.00 0.00
$attachment "wheel_fr" "car.wheel_fr" 0.00 0.00 0.00 rotate 0.00 0.00 0.00
$attachment "wheel_rr" "car.wheel_rr" 0.00 0.00 0.00 rotate 0.00 0.00 0.00
$attachment "wheel_rl" "car.wheel_rl" 0.00 0.00 0.00 rotate 0.00 0.00 0.00
$attachment "raytrace_fl" "car.col" 5.25 75.00 11.25 rotate 0.00 0.00 0.00
$attachment "raytrace_fr" "car.col" 5.25 75.00 -11.25 rotate 0.00 0.00 0.00
$attachment "raytrace_rr" "car.col" -5.25 75.00 11.25 rotate 0.00 0.00 0.00
$attachment "raytrace_rl" "car.col" -5.25 75.00 -11.25 rotate 0.00 0.00 0.00
$attachment "exit1" "car.col" -15.00 0.00 -70.00 rotate -0 0 -90
$attachment "exhaust1" "car.col" -118.00 7.00 30.00 rotate 0 0 0
$attachment "exhaust2" "car.col" -118.00 7.00 -30.00 rotate 0 0 0
$attachment "engine" "car.col" 80.00 25.00 0.00 rotate -90 -90 0
$attachment "light_fl" "car.col" 104.00 25.00 -36.00 rotate -0 -4.2 0
$attachment "light_fr" "car.col" 104.00 25.00 36.00 rotate -0 -4.2 0
$attachment "light_rl" "car.col" -116.00 35.00 -30.00 rotate -0 -180 -180
$attachment "light_rr" "car.col" -116.00 35.00 30.00 rotate -0 -180 -180
$attachment "n_gun" "ValveBiped.Bip01_R_Hand" -0.00 0.00 0.00 rotate -0.00 -0.00 0.00
$attachment "n_l_hand" "ValveBiped.Bip01_L_Hand" -0.00 0.00 0.00 rotate -0.00 -0.00 0.00
$attachment "n_r_foot" "ValveBiped.Bip01_R_Foot" -0.00 0.00 0.00 rotate -0.00 -0.00 0.00
$attachment "n_l_foot" "ValveBiped.Bip01_L_Foot" -0.00 0.00 0.00 rotate -0.00 -0.00 0.00
$attachment "n_head" "ValveBiped.Bip01_Head1" -0.00 0.00 0.00 rotate -0.00 -0.00 0.00
$attachment "vehicle_3rd" "car.col" -256.00 88.00 0.00 rotate -0 -0 -90


$bonemerge	"ValveBiped.Bip01_Pelvis"
$bonemerge	"ValveBiped.Bip01_L_Thigh"
$bonemerge	"ValveBiped.Bip01_L_Calf"
$bonemerge	"ValveBiped.Bip01_L_Foot"
$bonemerge	"ValveBiped.Bip01_L_Toe0"
$bonemerge	"ValveBiped.Bip01_R_Thigh"
$bonemerge	"ValveBiped.Bip01_R_Calf"
$bonemerge	"ValveBiped.Bip01_R_Foot"
$bonemerge	"ValveBiped.Bip01_R_Toe0"
$bonemerge	"ValveBiped.Bip01_Spine"
$bonemerge	"ValveBiped.Bip01_Spine1"
$bonemerge	"ValveBiped.Bip01_Spine2"
$bonemerge	"ValveBiped.Bip01_Spine4"
$bonemerge	"ValveBiped.Bip01_Neck1"
$bonemerge	"ValveBiped.Bip01_Head1"
$bonemerge	"ValveBiped.forward"
$bonemerge	"ValveBiped.Bip01_L_Clavicle"
$bonemerge	"ValveBiped.Bip01_L_UpperArm"
$bonemerge	"ValveBiped.Bip01_L_Forearm"
$bonemerge	"ValveBiped.Bip01_L_Hand"
$bonemerge	"ValveBiped.Bip01_R_Clavicle"
$bonemerge	"ValveBiped.Bip01_R_UpperArm"
$bonemerge	"ValveBiped.Bip01_R_Forearm"
$bonemerge	"ValveBiped.Bip01_R_Hand"
$bonemerge	"ValveBiped.Bip01_R_Finger0"
$bonemerge	"ValveBiped.Bip01_R_Finger01"
$bonemerge	"ValveBiped.Bip01_R_Finger1"
$bonemerge	"ValveBiped.Bip01_R_Finger11"
$bonemerge	"ValveBiped.Bip01_R_Finger2"
$bonemerge	"ValveBiped.Bip01_R_Finger21"
$bonemerge	"ValveBiped.Bip01_R_Finger3"
$bonemerge	"ValveBiped.Bip01_R_Finger31"
$bonemerge	"ValveBiped.Bip01_R_Finger4"
$bonemerge	"ValveBiped.Bip01_R_Finger41"
$bonemerge	"ValveBiped.Bip01_L_Finger0"
$bonemerge	"ValveBiped.Bip01_L_Finger01"
$bonemerge	"ValveBiped.Bip01_L_Finger1"
$bonemerge	"ValveBiped.Bip01_L_Finger11"
$bonemerge	"ValveBiped.Bip01_L_Finger2"
$bonemerge	"ValveBiped.Bip01_L_Finger21"
$bonemerge	"ValveBiped.Bip01_L_Finger3"
$bonemerge	"ValveBiped.Bip01_L_Finger31"
$bonemerge	"ValveBiped.Bip01_L_Finger4"
$bonemerge	"ValveBiped.Bip01_L_Finger41"
$bonemerge "ValveBiped.weapon_bone"
$bonemerge "ValveBiped.weapon_bone_RHand"
$bonemerge "ValveBiped.weapon_bone_LHand"
$bonemerge "ValveBiped.weapon_bone_Clip"


$surfaceprop "metal"
$keyvalues  { vehicle_exit { "vehicle_driver_exit" "upright" "vehicle_passenger_exit" "upright"  } }
$illumposition 0 30 0

// These specify the various animations which are referred to below
$animation idle_anim "natalyas_mustang_csgo_idle.smd"

$animation spin_anim000 "natalyas_mustang_csgo_idle.smd"   subtract idle_anim 0


// These are all the animations for the tire rotation
$animation spin_anim_fr120 "spin_fr_120" subtract idle_anim 0
$animation spin_anim_fr240 "spin_fr_240" subtract idle_anim 0
$animation spin_anim_fl120 "spin_fl_120" subtract idle_anim 0
$animation spin_anim_fl240 "spin_fl_240" subtract idle_anim 0
$animation spin_anim_rl120 "spin_rl_120" subtract idle_anim 0
$animation spin_anim_rl240 "spin_rl_240" subtract idle_anim 0
$animation spin_anim_rr120 "spin_rr_120" subtract idle_anim 0
$animation spin_anim_rr240 "spin_rr_240" subtract idle_anim 0



// These are the animations for the wheel suspension
$animation jump_anim_fr0 "lift_fr" subtract idle_anim 0
$animation jump_anim_fl0 "lift_fl" subtract idle_anim 0
$animation jump_anim_rr0 "lift_rr" subtract idle_anim 0
$animation jump_anim_rl0 "lift_rl" subtract idle_anim 0

// This is the main sequence upon which everything else is based
$sequence idle idle_anim fps 30 ACT_IDLE 2 rotate 0.00

// These are the three animations for the steering
$animation steer_anim0 "steer_0" subtract idle_anim 0
$animation steer_anim1 "steer_1" subtract idle_anim 0
$animation steer_anim_n "natalyas_mustang_csgo_idle" subtract idle_anim 0


// This is the blended sequence which describes how to rotate the front right wheel
$sequence wheel_fr_spin spin_anim000 fps 30  {
  blend vehicle_wheel_fr_spin -180 180
  blendwidth 4
  delta
  autoplay
  spin_anim_fr240 spin_anim_fr120 spin_anim000
}

// This is the blended sequence which describes how to rotate the front left wheel
$sequence wheel_fl_spin spin_anim000 fps 30 {
  blend vehicle_wheel_fl_spin -180 180
  blendwidth 4
  delta
  autoplay
  spin_anim_fl240 spin_anim_fl120 spin_anim000
}

// This is the blended sequence which describes how to rotate the rear left wheel
$sequence wheel_rl_spin spin_anim000 fps 30  {
  blend vehicle_wheel_rl_spin -180 180
  blendwidth 4
  delta
  autoplay
  spin_anim_rl240 spin_anim_rl120 spin_anim000
}

// This is the blended sequence which describes how to rotate the rear right wheel
$sequence wheel_rr_spin spin_anim000 fps 30  {
  blend vehicle_wheel_rr_spin -180 180
  blendwidth 4
  delta
  autoplay
  spin_anim_rr240 spin_anim_rr120 spin_anim000
}


// This is the blended sequence which describes how to steer the front wheels
$sequence steer {
  blend vehicle_steer -1 1
  blendwidth 3
  delta
  autoplay
  steer_anim0 steer_anim_n steer_anim1
}


// This is the blended sequence which describes how to bounce the right front wheel
$sequence wheel_fr_suspension jump_anim_fr0 fps 30  {
  blend vehicle_wheel_fr_height 0 1
  blendwidth 2
  delta
  autoplay
  spin_anim000
}

// This is the blended sequence which describes how to bounce the left front wheel
$sequence wheel_fl_suspension jump_anim_fl0 fps 30  {
  blend vehicle_wheel_fl_height 0 1
  blendwidth 2
  delta
  autoplay
  spin_anim000
}

// This is the blended sequence which describes how to bounce the right rear wheel
$sequence wheel_rr_suspension jump_anim_rr0 fps 30  {
  blend vehicle_wheel_rr_height 0 1
  blendwidth 2
  delta
  autoplay
  spin_anim000
}

// This is the blended sequence which describes how to bounce the left rear wheel
$sequence wheel_rl_suspension jump_anim_rl0 fps 30  {
  blend vehicle_wheel_rl_height 0 1
  blendwidth 2
  delta
  autoplay
  spin_anim000
}


$sequence exit1 "natalyas_mustang_csgo_idle.smd" fps 30

$collisionmodel "phymodel.smd" {

	$concave
	$mass 1220.0
	$inertia 1.00
	$damping 0.00
	$rotdamping 0.00
}


The .qc needs an update after the September 15, 2015 valve update to CS:GO because they changed the skeleton bone names, but you can see where they were listed in here.

In a Source Mod plugin include this code:


public OnThink(entity)
{
	new Driver = GetEntPropEnt(entity, Prop_Send, "m_hPlayer");
	if (IsValidEntity(ViewEnt[entity]))
	{
		if (Driver > 0)
		{
			if(IsClientInGame(Driver) && IsPlayerAlive(Driver))
			{
				SetEntProp(entity, Prop_Data, "m_nNextThinkTick", 1);
				SetEntPropFloat(entity, Prop_Data, "m_flTurnOffKeepUpright", 1.0);
		
				SetClientViewEntity(Driver, ViewEnt[entity]);
				Driving[Driver] = true;
	
	
				new t = cars_type[entity];
				if (car_driver_view[t] == 1)
				{
					if (Cars_Driver_Prop[entity] == -1)
					{
						new prop = CreateEntityByName("prop_physics_override");
						if(IsValidEntity(prop))
						{
							new String:model[128];
							GetClientModel(Driver, model, sizeof(model));
							DispatchKeyValue(prop, "model", model);
							DispatchKeyValue(prop, "skin","0");
							
							ActivateEntity(prop);
							DispatchSpawn(prop);
                                        
							new enteffects = GetEntProp(prop, Prop_Send, "m_fEffects");  
							
							enteffects |= 1;	/* This is EF_BONEMERGE */
							enteffects |= 16;	/* This is EF_NOSHADOW */
							enteffects |= 64;	/* This is EF_NORECEIVESHADOW */
							enteffects |= 128;	/* This is EF_BONEMERGE_FASTCULL */
							enteffects |= 512;	/* This is EF_PARENT_ANIMATES */

							SetEntProp(prop, Prop_Send, "m_fEffects", enteffects);

							new String:car_ent_name[128];
							GetTargetName(entity,car_ent_name,sizeof(car_ent_name));
                    
							SetVariantString(car_ent_name);
							AcceptEntityInput(prop, "SetParent", prop, prop, 0);
							SetVariantString("vehicle_driver_eyes");
							AcceptEntityInput(prop, "SetParentAttachment", prop, prop, 0);	
							Cars_Driver_Prop[entity] = prop;
						}
					}
				}
				else Cars_Driver_Prop[entity] = -1;
			}
		}
	}
-- rest of vehicle think code --
}


You can pull working code from Rally Race:

(Go to last page for most recent version.)

Because of the CS:GO update on September 15 I don’t have any car models with proper skeletons so there are no viewmodels for CS:GO cars, but this is just a modelling issue. If you make some cars in the manner described you can get it working again.

Now, Passengers…

Different story here. What I had done for CS:S, and this SHOULD work on CS:GO was I made a very simple model of a tiny box with a player skeleton in a sort-of seated position and I would spawn that as a vehicle and bonemerge a ragdoll of a player model into the seat and parent the seat to an attachment inside the car. That’s how the Jeep in the earlier link worked. I didn’t get guns working, but I think they could be made to work somehow. A gun turret anyway, I’m not sure about how to let players lean out the window and fire their own guns.