ULX

Author Topic: [Request] Spawn Vehicle Plugin  (Read 5285 times)

0 Members and 1 Guest are viewing this topic.

Offline PAL-18

  • Full Member
  • ***
  • Posts: 142
  • Karma: 1
[Request] Spawn Vehicle Plugin
« on: January 12, 2013, 05:07:57 PM »
I'm no coder so i can't do this myself, but can anyone make this:

A command that when used (eg. !car) that spawns a vehicle for the player who uses it.  Just 1 vehicle should spawn and if they use it again, then their old vehicle is despawned and the new one replaces it.  There should also be a timeout of like 1 minute where they cant use it again (to prevent spamming).

P.S. I know this can be done in sandbox with the Gmod GUI, but im using a gamemode that doesnt allow spawning of props and such.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: [Request] Spawn Vehicle Plugin
« Reply #1 on: January 13, 2013, 12:47:58 PM »
What kind of vehicle?

Offline PAL-18

  • Full Member
  • ***
  • Posts: 142
  • Karma: 1
Re: [Request] Spawn Vehicle Plugin
« Reply #2 on: January 13, 2013, 02:22:55 PM »
Airboat or jeep.  When its used again, it replaces the previously spawned vehicle.

Here's what the vehicle entities look like in text form:

{
"model" "models/buggy.mdl"
"origin" "0 0 0"
"VehicleLocked" "0"
"actionScale" "1"
"vehiclescript" "scripts/vehicles/jeep_test.txt"
"screenspacefade" "0"
"solid" "6"
"fadescale" "1"
"fademaxdist" "0"
"fademindist" "-1"
"maxdxlevel" "0"
"mindxlevel" "0"
"disableshadows" "0"
"skin" "0"
"angles" "0 0 0"
"classname" "prop_vehicle_jeep"
}

{
"model" "models/airboat.mdl"
"origin" "0 0 0"
"VehicleLocked" "0"
"actionScale" "1"
"vehiclescript" "scripts/vehicles/airboat.txt"
"screenspacefade" "0"
"solid" "6"
"fadescale" "1"
"fademaxdist" "0"
"fademindist" "-1"
"maxdxlevel" "0"
"mindxlevel" "0"
"disableshadows" "0"
"skin" "0"
"angles" "0 0 0"
"classname" "prop_vehicle_airboat"
}

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President

Offline PAL-18

  • Full Member
  • ***
  • Posts: 142
  • Karma: 1
Re: [Request] Spawn Vehicle Plugin
« Reply #4 on: June 17, 2013, 10:54:05 PM »
Hey Pres,

I was wondering you can make a variation of this plugin?  One that spawns a few types of npcs:

npc_headcrab_black
npc_metropolice
npc_stalker

Good short spawn names for the above would be:

!npc headcrab
!npc police
!npc stalker

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: [Request] Spawn Vehicle Plugin
« Reply #5 on: June 18, 2013, 06:16:52 AM »
Pal, though I've not looked at code to know (and been so long I forget), if a vehicle entitiy is spawned the same way as a npc entity, perhaps his function would be a good chance to learn on your own.
:)
Best way I ever learned was by looking at others code when I wanted to do something similar.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: [Request] Spawn Vehicle Plugin
« Reply #6 on: June 18, 2013, 08:02:29 AM »
I could do this, sure. The code wouldn't take too much modifying, and I could make it dynamic so that you could add new npcs to a table and it'll allow you to spawn them that way. I could also add a parameter for weapon and player affiliation of you want.

let me know what you want it to do.

Offline PAL-18

  • Full Member
  • ***
  • Posts: 142
  • Karma: 1
Re: [Request] Spawn Vehicle Plugin
« Reply #7 on: June 18, 2013, 02:50:48 PM »
That would be AWESOME.  Many Thanks! <3

It would be great if there were an optional configurable setting that spawns the npc a few feet in the air (some big ones like the helicopter and combine dropship spawn in the ground and cant move around).

P.S. I tried myself, but i can't wrap my mind around programming schema.
« Last Edit: June 18, 2013, 02:52:35 PM by PAL-18 »

Offline PAL-18

  • Full Member
  • ***
  • Posts: 142
  • Karma: 1
Re: [Request] Spawn Vehicle Plugin
« Reply #8 on: June 18, 2013, 02:54:37 PM »
Pal, though I've not looked at code to know (and been so long I forget), if a vehicle entitiy is spawned the same way as a npc entity, perhaps his function would be a good chance to learn on your own.
:)
Best way I ever learned was by looking at others code when I wanted to do something similar.

I tried and crashed and burned.  That's why i made the reply.

In fact, a few years ago i even took a dedicated C++ programming program at college and 3 weeks into it i had a burn out because i couldnt keep up/understand things.

@Pres, can you make it work in any gamemode like the rest of ULX?  The vehicle script doesnt work in TTT and every other gamemode (i can still spawn ents with the rcon command though).
« Last Edit: June 18, 2013, 09:05:07 PM by PAL-18 »