SA-MP Forums Archive
[Tutorial] Pre-Tuned Car Spawns - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Pre-Tuned Car Spawns (/showthread.php?tid=448855)



Pre-Tuned Car Spawns - Aerotactics - 06.07.2013

Pre-Tuned Car Spawns

By Aerotactics


Whether you're 'brand new' to SAMP, or want to learn a new trick, this tutorial should answer your questions and explain the process and the script. While this is an easy process, it is a bit time consuming.

Requirements:
-SAMP.............................http://www.sa-mp.com/download.php
-a SAMP server.................^^Same link^^
-Multi Theft Auto (MTA).....http://www.mtavc.com/ (just click download)

If you need help starting a server, you can find it at https://sampwiki.blast.hk/wiki/Windows_Server. It's easier than it looks.

As you can see, my preferred map editor is MTA. This tutorial will explain the process using the MTA mapping tool. I know there's other tools out there, but I started using MTA before I even knew SAMP existed. Since I became comfortable with it, I used it to continue mapping in SAMP. To all the people who don't want to hear "MTA", you should be talking to the creator of convertffs.com, as I believe he intended the use of MTA as a 'Third Party Tool', and that's what I use it as. I did try to use one of those other programs, but I didn't understand how to use it, because it was different from MTA's map editor.

You may want to run through the mapping tutorial and get comfortable with the camera controls before continuing, but it isn't too hard to understand.

Step 1


First off, we are going to open MTA and enter the map editor. From here, we will start a new map and spawn our first car. In this demonstration, I will only be making one car, but you can make as many cars as you'd like. I am going to spawn a Sultan in the middle of Grove Street. This will be my tuner for this tutorial.



By double-clicking on the car, you can edit the parts and colors in this window; however, MTA car colors and SAMP colors differ entirely, so I will wait until after converting to choose my colors, which we will do after we finish our car. If you would like to add a Paintjob to your car, look at this link to see if your car has one. https://sampwiki.blast.hk/wiki/Paintjob



Step 2


Once you are finished, save the map, and exit out of MTA. Right-click the MTA icon, and choose "Open file location".
When your folder appears, click "server", "mods", "deathmatch", "resources", then find your map. Open it, then open the text document with the same name. If your computer asks, open it with Notepad.

Copy the script, and go to http://convertffs.com/ (don't exit out of the script document, but you can exit anything else). Paste the script into the box and click convert. This will convert it to SAMP (partially).

Step 3


We are now going to write a filterscript for the car (or cars). Copy the converted script from 'convertffs' and go to your SAMP server folder and open Pawno in the Pawno folder. Go to 'File', then 'New'. This will create a new blank script. You won't need most of this, so we are going to remove everything we don't need, so it looks like this (be sure to uncomment the line "#define filterscript" at the very top, otherwise our car won't appear) :
pawn Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

#include <a_samp>

public OnGameModeInit()
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}
Now, paste your converted script under "OnGameModeInit(...)". Be sure to leave the "return 1" there so that we don't get errors. Also be sure that your script lines up with the "return 1". And we are also going to define our cars. Directly above "OnGameModeInit(...)", we will type "new (name of car here);". Be sure that you have that semicolon there. It is like a period ".", telling the game to go to the next line. The name of the car can be anything you want, I'm just going to call it Tcar. If you have more than one tuner, you will need to make a new define with another name, like "new Tcar2;".
pawn Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

#include <a_samp>

new Tcar;

public OnGameModeInit()
{
    AddStaticVehicle(560,2485.6999500,-1667.9000200,13.1000000,0.0000000,111,103); //Sultan
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}
Step 4


Now we will tell the game what our new cars are, and give them some parts. In front of the car script "AddStaticVehicle(...)" we will type "Tcar=" to tell the game that this is our car. On the next car, you would type "Tcar2=" and so on.
pawn Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

#include <a_samp>

new Tcar;

public OnGameModeInit()
{
    Tcar=AddStaticVehicle(560,2485.6999500,-1667.9000200,13.1000000,0.0000000,111,103); //Sultan
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}
So now we need to add the parts back on since the converter doesn't support this yet. Go to your MTA script (I hope you still have it open) and look for your car script. It should look like this, and the parts we are looking for are the codes under "upgrades='...'":
HTML Code:
    <vehicle id="vehicle (Sultan) (2)" paintjob="2" interior="0" alpha="255" model="560" plate="PQ05 V12" dimension="0" posX="2485.69995" posY="-1667.90002" posZ="13.1" rotX="0" rotY="0" rotZ="0" upgrades="1138,1026,1033,1010,1082,1141,1169" color="111,103,95,151,149,146,0,0,0,0,0,0"></vehicle>
Keep this section in mind. Now, under each car spawn script, we will add the script "AddVehicleComponent(vehicleid, part);" For each part we have. This one has 7 parts. It will look like this:
pawn Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

#include <a_samp>

new Tcar;

public OnGameModeInit()
{
    Tcar=AddStaticVehicle(560,2485.6999500,-1667.9000200,13.1000000,0.0000000,111,103); //Sultan
    AddVehicleComponent(Tcar, 1138);
    AddVehicleComponent(Tcar, 1026);
    AddVehicleComponent(Tcar, 1033);
    AddVehicleComponent(Tcar, 1010);
    AddVehicleComponent(Tcar, 1082);
    AddVehicleComponent(Tcar, 1141);
    AddVehicleComponent(Tcar, 1169);
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}
Since my car also has a Paintjob, we will also add the script "ChangeVehiclePaintjob(vehicleid, Paintjob);" and add the paintjob to the car.
pawn Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

#include <a_samp>

new Tcar;

public OnGameModeInit()
{
    Tcar=AddStaticVehicle(560,2485.6999500,-1667.9000200,13.1000000,0.0000000,111,103); //Sultan
    AddVehicleComponent(Tcar, 1138);
    AddVehicleComponent(Tcar, 1026);
    AddVehicleComponent(Tcar, 1033);
    AddVehicleComponent(Tcar, 1010);
    AddVehicleComponent(Tcar, 1082);
    AddVehicleComponent(Tcar, 1141);
    AddVehicleComponent(Tcar, 1169);
    ChangeVehiclePaintjob(Tcar, 2);
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}
Step 5


Our Cars are almost done! The last thing we have to do is make the parts reappear on the car after it respawns. This is very simple. Just copy all of your vehicle code under "OnVehicleSpawn(...)" and remove the vehicle part.

pawn Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

#include <a_samp>

new Tcar;

public OnGameModeInit()
{
    Tcar=AddStaticVehicle(560,2485.6999500,-1667.9000200,13.1000000,0.0000000,111,103); //Sultan
    AddVehicleComponent(Tcar, 1138);
    AddVehicleComponent(Tcar, 1026);
    AddVehicleComponent(Tcar, 1033);
    AddVehicleComponent(Tcar, 1010);
    AddVehicleComponent(Tcar, 1082);
    AddVehicleComponent(Tcar, 1141);
    AddVehicleComponent(Tcar, 1169);
    ChangeVehiclePaintjob(Tcar, 2);
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    //Sultan
    AddVehicleComponent(Tcar, 1138);
    AddVehicleComponent(Tcar, 1026);
    AddVehicleComponent(Tcar, 1033);
    AddVehicleComponent(Tcar, 1010);
    AddVehicleComponent(Tcar, 1082);
    AddVehicleComponent(Tcar, 1141);
    AddVehicleComponent(Tcar, 1169);
    ChangeVehiclePaintjob(Tcar, 2);
    return 1;
}
As I said before, if you want to change the vehicle colors, the color IDs are the last 2 numbers in the vehicle spawn. In this tutorial it is "111,103". You can find new color codes here https://sampwiki.blast.hk/wiki/Vehicle_Color_IDs, just replace the codes with your new colors.
pawn Code:
Tcar=AddStaticVehicle(560,2485.6999500,-1667.9000200,13.1000000,0.0000000,32,79); //Sultan
Goto "Build", then "Compile". If you followed this tutorial correctly, you shouldn't get any errors. Open your server folder, and go to "server.cfg (config)". Next to filterscripts, add the name of your car filterscript. Save and Exit, and run "SAMP-Server" and enjoy your new cars!



Re: Pre-Tuned Car Spawns - Ryan_Bowe - 06.07.2013

....


Re: Pre-Tuned Car Spawns - Pottus - 06.07.2013

MTA this is SAMP.......


Re: Pre-Tuned Car Spawns - Ryan_Bowe - 06.07.2013

....


Re: Pre-Tuned Car Spawns - Pottus - 06.07.2013

But this is SAMP not MTA, it can be done just as easily in SAMP.


Re: Pre-Tuned Car Spawns - Aerotactics - 06.07.2013

Quote:
Originally Posted by [uL]Pottus
View Post
But this is SAMP not MTA, it can be done just as easily in SAMP.
I know there's other tools out there, but I started using MTA before I even knew SAMP existed. Since I became comfortable with it, I used it to continue mapping in SAMP. To all the people who don't want to hear "MTA", you should be talking to the creator of convertffs.com, as I believe he intended the use of MTA as a 'Third Party Tool', and that's what I use it as. I did try to use one of those other programs, but I didn't understand how to use it, because it was different from MTA's map editor.

EDIT: Without adding another comment, I just wanted to say that I saw a similar tutorial has only been done once before, but that tutorial had a timer and some other bits that were useless and confusing, and didn't tell how to map the car, nor tell the process. It only explained pieces of script.

I hope a few people get some use out of my tutorial. I wish I had it when I was learning.


Re: Pre-Tuned Car Spawns - DaRk_RaiN - 06.07.2013

Good job.


Re: Pre-Tuned Car Spawns - Aerotactics - 06.07.2013

Quote:
Originally Posted by DaRk_RaiN
View Post
Good job.
Thanks for your opinion!


Re: Pre-Tuned Car Spawns - Inverse - 07.07.2013

Nice job! You explained it well.


Re: Pre-Tuned Car Spawns - Aerotactics - 07.07.2013

Quote:
Originally Posted by Inverse
View Post
Nice job! You explained it well.
Thank you! That's what I was hoping for.