1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Latest News: RAGE Multiplayer 0.3.2 Announcement - November 29th, 2017

Vehicle List

Discussion in 'Scripts' started by snipy, Jan 30, 2017.

  1. snipy

    snipy Member

    Messages:
    13
    Likes Received:
    6
    Joined:
    Dec 31, 2016
    Vehicle List V1.1
    There are a lot of vehicles in GTA V here is a small js script to help you with a variety of different activities that involve selecting a vehicle.
    This is more of a snippet, however, I will provide a download zip with a complete working version of this.
    Updates
    • V1.1
      • You can now name your own triggerServerEvent response name.
      • NOTE! If your updating to 1.1 from 1.0 please go back to each time you call triggerClientEvent in your server and follow the new syntax below under "How to use this script in your own code".
    • Coming soon
      • Ability to pass your own description
    Features
    • Allows you to spawn any vehicle in the game
    • Some vehicles on the list include a model with the name
    • I will be updating the list as new vehicles are added to the game
    • Each entry in the list under the description has the model id as well as the DLC if came from
    How does it look
    [​IMG]
    [​IMG]
    [​IMG]
    How to use this script in your own code
    Before you could only have the client response name be "CREATE_VEHICLE" now you can create your own name
    NOTE!: if you had menu names on the old version be sure to update each
    triggerClientEvent with the menu response name and after you can leave the menu name.

    Acceptable ways of calling the menu
    if you decide to leave any field blank the default names are the ones below

    Code:
    API.triggerClientEvent(player, "CAR_MENU");//this calls the "CAR_MENU" client script and is required
    
    Code:
    API.triggerClientEvent(player,"CAR_MENU","CREATE_VEHICLE");//this is name of the response message which will appear under "onClientEventTrigger" in the C# script
    
    Code:
    API.triggerClientEvent(player, "CAR_MENU","CREATE_VEHICLE","Vehicles");//This includes a title
    
    Here is an Example

    Code:
    [Command("car")]
    public void CarCommand(Client player)
    {
         API.triggerClientEvent(player, "CAR_MENU","SPAWN_A_CAR","Pick a Car");
    }
    
    Then add the OnClientEventTrigger Event
    Code:
    public Spawner()
    {
         API.onClientEventTrigger += onClientEventTrigger;
    }
    public void onClientEventTrigger(Client sender, string name, object[] args)
    {
    
    }
    
    Then check for the menu response name you defined, in this case the name is "SPAWN_A_CAR".
    Code:
    public void onClientEventTrigger(Client sender, string name, object[] args)
    {
         if(name == "SPAWN_A_CAR")
         {
              //Your code goes here
              //Example Code below
              int model = (int)args[0];
              if (!Enum.IsDefined(typeof(VehicleHash), model))
                   return;
    
              var rot = API.getEntityRotation(sender.handle);
              var veh = API.createVehicle((VehicleHash)model, new Vector3(sender.position.X + 5,sender.position.Y,sender.position.Z), new Vector3(0, 0, rot.Z), 0, 0,sender.dimension);
                    API.sendChatMessageToPlayer(sender,"You spawned a " + Enum.GetName(typeof(VehicleHash),(VehicleHash)(model)));
                }
            }
    
    Completed Version
    If you just want to spawn cars then download the full package and use the command /car to spawn any vehicle (this includes the script from pastebin)

    Just the script
    That can be download here. this is for if you want to create your own C# script to call the menu
    http://pastebin.com/TfD6CyG1
     

    Attached Files:

    Last edited: Jun 26, 2017
    Kiase, Dlazzy, Alf21 and 2 others like this.
  2. Moreno

    Moreno Member

    Messages:
    6
    Likes Received:
    0
    Joined:
    Jan 1, 2017
    I'm trying to get the prices of all the vehicles. How can I do that?
     
  3. snipy

    snipy Member

    Messages:
    13
    Likes Received:
    6
    Joined:
    Dec 31, 2016
    I am not sure, however you just gave me another idea being able to pass in your own description. I am not exactly sure how it will work but I will figure something out. See if you can find it on the Wiki.
     
    Moreno likes this.
  4. Dlazzy

    Dlazzy Member

    Messages:
    19
    Likes Received:
    3
    Joined:
    Jan 4, 2017
    Hello,

    I don't understand something to download your script.
    If I wan't to have a script that provide the menu (screen 2) I need to download the full package or use the code from pastebin ?

    Thanks for your work !
     
  5. snipy

    snipy Member

    Messages:
    13
    Likes Received:
    6
    Joined:
    Dec 31, 2016
    so technically you only need the Pastebin version for the menu but you will have to create your own c# script.(follow instructions under the "How to use this script in your own code")

    The zip version if fully completed and ready to use.

    My C# script is very limited but it does the job. I may upgrade that in the future
     
  6. Dlazzy

    Dlazzy Member

    Messages:
    19
    Likes Received:
    3
    Joined:
    Jan 4, 2017
    So the full version is only with the /car [model] command ? No menu ?
     
  7. snipy

    snipy Member

    Messages:
    13
    Likes Received:
    6
    Joined:
    Dec 31, 2016
    no the full version contains the script from Pastebin as well. if you download the full version you will not need the Pastebin script
     
  8. Dlazzy

    Dlazzy Member

    Messages:
    19
    Likes Received:
    3
    Joined:
    Jan 4, 2017
    I see the command /car in .cs
    Code:
    [Command("car")]
            public void CarCommand(Client player)
            {
                 API.triggerClientEvent(player, "CAR_MENU","SPAWN_A_CAR","Pick a Car");
            }
    
    But on /car the menu is not here ?!
     
  9. snipy

    snipy Member

    Messages:
    13
    Likes Received:
    6
    Joined:
    Dec 31, 2016
    that's definitely a concern. make sure you have include spawner it's your setting.xml and make sure it's correct. I am going to have a look to see if everything is okay.
    [​IMG]
     
  10. Dlazzy

    Dlazzy Member

    Messages:
    19
    Likes Received:
    3
    Joined:
    Jan 4, 2017
    Yes I've include your script in my settings.xml. If I type /car brickade, a brickade spawn. Seems OK but no menu ^^
     
  11. snipy

    snipy Member

    Messages:
    13
    Likes Received:
    6
    Joined:
    Dec 31, 2016
    Ohh okay you can't have more then 1 command with the same name

    Where it says "car" change it to something else like "carlist"
    Code:
    [Command("car")]//here
           public void CarCommand(Client player)
            {
                 API.triggerClientEvent(player, "CAR_MENU","SPAWN_A_CAR","Pick a Car");
            }
    
    if you want it to work on the same command send the code from the original /car to me and I will help you out
     
  12. Dlazzy

    Dlazzy Member

    Messages:
    19
    Likes Received:
    3
    Joined:
    Jan 4, 2017
    I have another /car command, I will change yours by /carmenu.
    Thanks again !!
     
  13. Kappi

    Kappi New Member

    Messages:
    2
    Likes Received:
    0
    Joined:
    Jun 17, 2018
    Hi, what could be my mistake the server console says the follwing.
     

    Attached Files:

    • 1.jpg
      1.jpg
      File size:
      103.1 KB
      Views:
      2

Share This Page