Raised This Month: $ Target: $400
 0% 

[CS:S] Passenger support for Drivable Vehicles


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NatalyaAF
Senior Member
Join Date: Dec 2008
Old 06-03-2011 , 13:55   [CS:S] Passenger support for Drivable Vehicles
Reply With Quote #1





http://pastebin.com/FSMfHmsq

This is basically all the code needed for passenger support in drivable vehicles. This code is incomplete and does not constitute an individual plugin.

How passengers work in CS:S and possibly HL2DM vehicles:

- You spawn a car
- If the car was made by me or someone else willing to put a bonemerge-able valve skeleton into it then the plugin detects when someone hops in.
- When someone is in the car it gets the player model they are using and spawns a prop_physics_override of it, then parents it to the car, and sets its parent attachment to something (doesn't matter what) and the prop will become bonemerged with the car's player skeleton so they appear to sit in the driver's seat and it is awesome.
- Passenger seats are basically the same as cars but they in turn are parented to the car itself. They are prop_vehicle_driveable but we make them not able to drive and they are small models that you aren't supposed to see with the valve player skeleton so basically you spawn this object and a player can sit in it with the same process as for the car, but then it gets parented to the right attachment within the car so it looks like you're a passenger.

Sample car config file:

PHP Code:
//Configure your menu here
"Cars"
{
    
//Name of the item to appear in the menu
    
"Chevrolet Impala"
    
{
        
"price"            "15000"
            "type"            "impala"
            "val_1"            "6"
            "val_2"            "1"
        "model"            "models/natalya/vehicles/impala_v2.mdl"
        "script"            "scripts/vehicles/impala.txt"
        "vip"                "0"
        "gas_tank"            "17"
        "mpg"                "22"
        "siren"            "0"
        "lights"            "1"
        "police_lights"        "0"
        "view"            "1"
        "driver"            "1"
        "0"                "White"
        "1"                "Red"
        "2"                "Black"
        "3"                "Beige"
        "4"                "Green"
        "5"                "Cobalt"
        "passengers"            "3"
        "p1_model"            "models/natalya/vehicles/chair_impala.mdl"
        "p1_attachment"            "seat_fr"
        "p2_model"            "models/natalya/vehicles/chair_impala.mdl"
        "p2_attachment"            "seat_rr"
        "p3_model"            "models/natalya/vehicles/chair_impala.mdl"
        "p3_attachment"            "seat_rl"
    
}
    
"Toyota Tacoma"
    
{
        
"price"            "18000"
            "type"            "tacoma"
            "val_1"            "8"
            "val_2"            "1"
        "model"            "models/natalya/vehicles/tacoma_v2.mdl"
        "script"            "scripts/vehicles/tacoma.txt"
        "vip"                "0"
        "gas_tank"            "17"
        "mpg"                "16"
        "siren"            "0"
        "lights"            "1"
        "police_lights"        "0"
        "view"            "1"
        "driver"            "1"
        "0"                "Lt Green"
        "1"                "White"
        "2"                "Dark Red"
        "3"                    "Pale Tan"
        "4"                "Dk Green"
        "5"                "Black"
        "6"                "Tan"
        "7"                "Blue"
        "passengers"            "3"
        "p1_model"            "models/natalya/vehicles/chair_tacoma_right2.mdl"
        "p1_attachment"            "vehicle_feet_passenger1"
        "p2_model"            "models/natalya/vehicles/chair_tacoma_rear.mdl"
        "p2_attachment"            "vehicle_feet_passenger1"
        "p3_model"            "models/natalya/vehicles/chair_tacoma_rear2.mdl"
        "p3_attachment"            "vehicle_feet_passenger0"
    
}
    
"Police Impala"
    
{
            
"price"            "30000"
            "type"            "impala_police"
            "val_1"            "6"
            "val_2"            "1"
        "model"            "models/natalya/vehicles/police_impala_v2.mdl"
        "script"            "scripts/vehicles/impala_police.txt"
        "vip"                "0"
        "gas_tank"            "17"
        "mpg"                "20"
        "siren"            "1"
        "lights"            "1"
        "police_lights"        "1"
        "view"            "1"
        "driver"            "1"
        "0"                "GSU Police"
        "1"                "White"
        "2"                "B & W"
        "3"                "FC Police"
        "4"                "California Highway Patrol"
        "5"                "NYPD"
        "passengers"            "3"
        "p1_model"            "models/natalya/vehicles/chair_impala.mdl"
        "p1_attachment"            "seat_fr"
        "p2_model"            "models/natalya/vehicles/chair_impala.mdl"
        "p2_attachment"            "seat_rr"
        "p3_model"            "models/natalya/vehicles/chair_impala.mdl"
        "p3_attachment"            "seat_rl"
    
}
    
"S197 Mustang"
    
{
            
"price"            "30000"
            "type"            "s197_mustang"
            "val_1"            "8"
            "val_2"            "1"
        "model"            "models/natalya/vehicles/s197_mustang_v2.mdl"
        "script"            "scripts/vehicles/s197.txt"
        "vip"                "0"
        "gas_tank"            "16"
        "mpg"                "20"
        "siren"            "0"
        "lights"            "1"
        "police_lights"        "0"
        "view"            "1"
        "driver"            "1"
        "0"                "Teal Blue"
        "1"                "Grey/White"
        "2"                "Grey/Orange"
        "3"                "Dark Red"
        "4"                "Plain White"
        "5"                "Plain Blue"
        "6"                "Black"
        "7"                "Vibrant Blue"
        "passengers"            "1"
        "p1_model"            "models/natalya/vehicles/chair_s197_right2.mdl"
        "p1_attachment"            "vehicle_feet_passenger1"
    
}
    
"Mustang GT"
    
{
            
"price"            "60000"
            "type"            "mustang"
            "val_1"            "8"
            "val_2"            "1"
        "model"            "models/vehicles/ep1/mustang_gt_redux.mdl"
        "script"            "scripts/vehicles/mustang.txt"
        "vip"                "1"
        "gas_tank"            "16"
        "mpg"                "16"
        "siren"            "0"
        "lights"            "1"
        "police_lights"        "0"
        "view"            "1"
        "driver"            "1"
        "0"                "Black"
        "1"                "White"
        "2"                "Red"
        "3"                "Orange"
        "4"                "Yellow"
        "5"                "Green"
        "6"                "Blue"
        "7"                "Violet"
        "passengers"            "1"
        "p1_model"            "models/natalya/vehicles/chair_gt_right.mdl"
        "p1_attachment"            "vehicle_feet_passenger0"
    
}
    
"Mini Cooper"
    
{
            
"price"            "60000"
            "type"            "mini"
            "val_1"            "16"
            "val_2"            "1"
        "model"            "models/vehicles/ep1/mini_v2.mdl"
        "script"            "scripts/vehicles/mini.txt"
        "vip"                "1"
        "gas_tank"            "14"
        "mpg"                "22"
        "siren"            "0"
        "police_lights"        "0"
        "lights"            "1"
        "view"            "1"
        "driver"            "1"
        "0"                "White + CK"
        "1"                "Black + White"
        "2"                "Red + White"
        "3"                "Orange + CK"
        "4"                "Yellow + Stripes"
        "5"                "Lime + White"
        "6"                "Green + Stripes"
        "7"                "Turquoise + White"
        "8"                "Light Blue + CK"
        "9"                "Blue + Union Jack"
        "10"                "Purple + CK"
        "11"                "Sky Blue + Stripes"
        "12"                "Green + Union Jack"
        "13"                "Grey + White"
        "14"                "Dark Red + Stripes"
        "15"                "Red + Union Jack"
        "passengers"            "3"
        "p1_model"            "models/natalya/vehicles/chair_mini_passenger.mdl"
        "p1_attachment"            "vehicle_feet_passenger1"
        "p2_model"            "models/natalya/vehicles/chair_mini_rear.mdl"
        "p2_attachment"            "vehicle_feet_passenger1"
        "p3_model"            "models/natalya/vehicles/chair_mini_rear.mdl"
        "p3_attachment"            "vehicle_feet_passenger0"
    
}
    
"Dirt Bike"
    
{
            
"price"        "3000"
            "type"        "dirtbike"
        "model"        "models/natalya/vehicles/dirtbike.mdl"
        "script"        "scripts/vehicles/dirtbike.txt"
            "val_1"            "8"
            "val_2"            "1"
        "0"        "White"
        "1"        "Black"
        "2"        "Red"
        "3"        "Orange"
        "4"        "Yellow"
        "5"        "Green"
        "6"        "Blue"
        "7"        "Purple"
        "vip"                "0"
        "gas_tank"            "3"
        "mpg"                "50"
        "siren"            "0"
        "police_lights"        "0"
        "lights"            "1"
        "view"            "1"
        "driver"            "1"
        "passengers"        "0"
    

I hope this helps someone.


__________________
Talk to me on Steam: natalyaaf
See my website for downloads: www.lady-natalya.info

Natalya: killing someone while they make a plugin
Natalya: perfect analogy
Natalya: for the mayan apocalypse

Last edited by NatalyaAF; 06-03-2011 at 14:04.
NatalyaAF is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 06-03-2011 , 14:43   Re: [CS:S] Passenger support for Drivable Vehicles
Reply With Quote #2

THAT LOOKS AWESOME!
I love how much detail you spent with the fuel and stuff
Currently trying to build a plugin around it. Lot's of stuff is missing, so looks like i'm going to have to read all your arrays and rebuild them myself :/

Would you mind sharing your
  • LeaveVehicle
  • ViewToggle
  • Reset_Car_Selection
  • SetCarOwnership
functions and maybe the Horn_Time timer callback either? I'd love to test this out! Do you've got a server up and running this plugin?
__________________
Peace-Maker is offline
NatalyaAF
Senior Member
Join Date: Dec 2008
Old 06-03-2011 , 19:11   Re: [CS:S] Passenger support for Drivable Vehicles
Reply With Quote #3

Quote:
Originally Posted by Peace-Maker View Post
THAT LOOKS AWESOME!
I love how much detail you spent with the fuel and stuff
Currently trying to build a plugin around it. Lot's of stuff is missing, so looks like i'm going to have to read all your arrays and rebuild them myself :/

Would you mind sharing your
  • LeaveVehicle
  • ViewToggle
  • Reset_Car_Selection
  • SetCarOwnership
functions and maybe the Horn_Time timer callback either? I'd love to test this out! Do you've got a server up and running this plugin?

PHP Code:
LeaveVehicle(client)
{
    new 
Float:Null[3] = {0.00.00.0};
    new 
Float:ExitAng[3];
    
    new 
vehicle GetEntPropEnt(clientProp_Send"m_hVehicle");
    if (
IsValidEntity(vehicle))
    {
        
GetEntPropVector(vehicleProp_Data"m_angRotation"ExitAng);
        
ExitAng[0] = 0.0;
        
ExitAng[1] += 90.0;
        
ExitAng[2] = 0.0;
    
        
SDKCall(hLeaveVehicleclientNullNull);
    
        
TeleportEntity(clientNULL_VECTORExitAngNULL_VECTOR);
        
SetClientViewEntity(clientclient);

        new 
car_index g_CarIndex[vehicle];    
        new 
max g_CarLightQuantity[car_index];
        if (
max 0)
        {
            
decl light;
            
light g_CarLights[car_index][0];
            if (
IsValidEntity(light))
            {
                
AcceptEntityInput(light"HideSprite");
            }
            
light g_CarLights[car_index][1];
            if (
IsValidEntity(light))
            {
                
AcceptEntityInput(light"HideSprite");
            }
            if (
max 2)
            {
                
light g_CarLights[car_index][2];
                if (
IsValidEntity(light))
                {
                    
AcceptEntityInput(light"HideSprite");
                }
                
light g_CarLights[car_index][3];
                if (
IsValidEntity(light))
                {
                    
AcceptEntityInput(light"HideSprite");
                }

    
/*            AcceptEntityInput(g_CarLights[car_index][6], "LightOff");
                AcceptEntityInput(g_CarLights[car_index][7], "LightOff"); */
            
}
        }
    }
    if (
vehicle 0)
    {
        if (
IsValidEntity(Cars_Driver_Prop[vehicle]))
        {
            
AcceptEntityInput(Cars_Driver_Prop[vehicle],"Kill");
            
Cars_Driver_Prop[vehicle] = -1;
        }
    }
    
SetEntProp(clientProp_Send"m_ArmorValue"armour[client], );
    
Driving[client] = false;
    
drivers_car[client] = -1;
}
public 
ViewToggle(carclient)
{
    new 
cars_type[car];
    if (!
car_view_enabled[t])
    {
        return;
    }
    if(
CarView[client] == true)
    {
        
CarView[client] = false;
        
SetVariantString("vehicle_driver_eyes");
        
AcceptEntityInput(client"SetParentAttachment");    
        return;
    }
    if(
CarView[client] == false)
    {
        
CarView[client] = true;
        
SetVariantString("vehicle_3rd");
        
AcceptEntityInput(client"SetParentAttachment");    
        return;
    }

Reset_Car_Selection has to do with resetting some of the arrays used when selecting your car and its colour in the car menu. It probably isn't helpful but here it is:

PHP Code:
stock Reset_Car_Selection(client)
{
    
selected_car[client] = -1;
    
selected_car_stowed[client] = -1;
    
selected_car_skin[client] = -1;
    
selected_car_type[client] = -1;
    
selected_car_fuel[client] = -1.0;
    
selected_car_name[client] = "FUCK_YOU";
    
selected_car_index[client] = -1;

SetCarOwnership deals with letting players lock or unlock their car by hitting shift (slow-walk or +speed) while looking at the car, but this is handled by another plugin.

Umm, basically you want to know exactly how the cars will be used on your server before you start to try to add this stuff. For example, Rally Race uses a lot of the features but does not use passenger support because you're racing the other players instead of driving your friends around.
__________________
Talk to me on Steam: natalyaaf
See my website for downloads: www.lady-natalya.info

Natalya: killing someone while they make a plugin
Natalya: perfect analogy
Natalya: for the mayan apocalypse
NatalyaAF is offline
KidMan186
Junior Member
Join Date: Mar 2011
Old 06-03-2011 , 14:51   Re: [CS:S] Passenger support for Drivable Vehicles
Reply With Quote #4

Thanks alot, this will really help!

Her RP server ip is: 75.102.34.142:27017.
KidMan186 is offline
alexip121093
Senior Member
Join Date: Dec 2009
Location: Hong Kong
Old 06-10-2011 , 10:42   Re: [CS:S] Passenger support for Drivable Vehicles
Reply With Quote #5

Someone make a plugin and post here using these Snippets or implement in vehiclemod?
__________________
alexip121093 is offline
Send a message via MSN to alexip121093
Mitchell
~lick~
Join Date: Mar 2010
Old 06-24-2011 , 18:57   Re: [CS:S] Passenger support for Drivable Vehicles
Reply With Quote #6

Quote:
Originally Posted by alexip121093 View Post
Someone make a plugin and post here using these Snippets or implement in vehiclemod?
Ive tried but failed. Its difficult using two different people's codes and putting them together.
Mitchell is offline
NatalyaAF
Senior Member
Join Date: Dec 2008
Old 07-02-2011 , 18:15   Re: [CS:S] Passenger support for Drivable Vehicles
Reply With Quote #7

Its just because you need to make a menu system from which to spawn the car, or some retarded console command... sm_car "modelname" "skin"
__________________
Talk to me on Steam: natalyaaf
See my website for downloads: www.lady-natalya.info

Natalya: killing someone while they make a plugin
Natalya: perfect analogy
Natalya: for the mayan apocalypse
NatalyaAF is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 07-04-2011 , 10:21   Re: [CS:S] Passenger support for Drivable Vehicles
Reply With Quote #8

Quote:
Originally Posted by NatalyaAF View Post
Its just because you need to make a menu system from which to spawn the car, or some retarded console command... sm_car "modelname" "skin"
Yes, i don't have the time or patients..
Does this code alow you to see the player sitting in the car too?

P.S. that's my exact command..

Last edited by Mitchell; 07-04-2011 at 10:26.
Mitchell is offline
KnifeLemon
Member
Join Date: Oct 2012
Location: South Korea
Old 01-06-2014 , 02:45   Re: [CS:S] Passenger support for Drivable Vehicles
Reply With Quote #9

u can provide me OnPlayerRunCmd?

i with this code, People can not ride

i cant this code seat on chair..

sorry my bad english

Quote:
"1"
{
"name" "Toyota Tacoma"
"model" "models/natalya/vehicles/tacoma_v3.mdl"
"script" "scripts/vehicles/tacoma.txt"
"skin_min" "0"
"skin_max" "7"
"0" "Light Green"
"1" "White"
"2" "Dark Red"
"3" "Sand"
"4" "Dark Green"
"5" "Black"
"6" "Tan"
"7" "Light Blue"
"vip" "0"
"view" "1"
"lights" "2"
"police_lights" "0"
"siren" "0"
"driver" "1"
"passengers" "3"
"p1_model" "models/natalya/vehicles/chair_tacoma_right2.mdl"
"p1_attachment" "car_seat_rr"
"p2_model" "models/natalya/vehicles/chair_tacoma_rear.mdl"
"p2_attachment" "car_seat_fl"
"p3_model" "models/natalya/vehicles/chair_tacoma_rear2.mdl"
"p3_attachment" "car_seat_fr"
}
__________________
MY s-low.net Model !

http://s-low.net/forum/viewforum.php...57326b47f0de50

my wordpress model download center

http://knifelemon.wordpress.com/

MY Youtube .CH : http://www.youtube.com/knifelemon
Steam Profile : KnifeLemon ProFile
Skype : knifelemon

Last edited by KnifeLemon; 01-06-2014 at 02:48.
KnifeLemon is offline
Send a message via Skype™ to KnifeLemon
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:37.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode