13.10.2016, 13:15 
	(
 Last edited by BurnZ; 16/10/2016 at 09:11 AM.
)
	
	How to make use of Grand Larceny vehicles
[TUTORIAL]
-------------------------------------------------------------------------------------------------------------------------------------
Hello people! How are you? This is my first ever tutorial, don't be so hard on me!
I noticed no one has made a tutorial on how to actually properly load and make use of the vehicles in the default Grand Larceny game mode.
This is a simple tutorial to show you how!
-------------------------------------------------------------------------------------------------------------------------------------
Step 1:
Go to your pawno/include folder and copy any .inc file. Paste it and it should show filename - copy.inc. Now, open that file and delete everything inside it.
Why? Because later on, I will provide a stock. LoadStaticVehiclesFromFile something used in the Grand Larceny game mode. The stock which I provided above makes LoadStaticVehiclesFromFile usable outside of Grand Larceny.
Step 2:
Rename the file to loadvehicles and replace the contents with this:
[TUTORIAL]
-------------------------------------------------------------------------------------------------------------------------------------
Hello people! How are you? This is my first ever tutorial, don't be so hard on me!
I noticed no one has made a tutorial on how to actually properly load and make use of the vehicles in the default Grand Larceny game mode.
This is a simple tutorial to show you how!
-------------------------------------------------------------------------------------------------------------------------------------
Step 1:
Go to your pawno/include folder and copy any .inc file. Paste it and it should show filename - copy.inc. Now, open that file and delete everything inside it.
Why? Because later on, I will provide a stock. LoadStaticVehiclesFromFile something used in the Grand Larceny game mode. The stock which I provided above makes LoadStaticVehiclesFromFile usable outside of Grand Larceny.
Step 2:
Rename the file to loadvehicles and replace the contents with this:
PHP Code:
stock LoadStaticVehiclesFromFile(const filename[])
{
    new File:file_ptr;
    new line[256];
    new var_from_line[64];
    new vehicletype;
    new Float:vSpawnX;
    new Float:vSpawnY;
    new Float:vSpawnZ;
    new Float:SpawnRot;
    new Color1, Color2;
    new index;
    new vehicles_loaded;
    file_ptr = fopen(filename,filemode:io_read);
    if(!file_ptr) return 0;
    vehicles_loaded = 0;
    while(fread(file_ptr,line,256) > 0)
    {
        index = 0;
        // Read type
          index = token_by_delim(line,var_from_line,',',index);
          if(index == (-1)) continue;
          vehicletype = strval(var_from_line);
           if(vehicletype < 400 || vehicletype > 611) continue;
          // Read X, Y, Z, Rotation
          index = token_by_delim(line,var_from_line,',',index+1);
          if(index == (-1)) continue;
          vSpawnX = floatstr(var_from_line);
          index = token_by_delim(line,var_from_line,',',index+1);
          if(index == (-1)) continue;
          vSpawnY = floatstr(var_from_line);
          index = token_by_delim(line,var_from_line,',',index+1);
          if(index == (-1)) continue;
          vSpawnZ = floatstr(var_from_line);
          index = token_by_delim(line,var_from_line,',',index+1);
          if(index == (-1)) continue;
          SpawnRot = floatstr(var_from_line);
          // Read Color1, Color2
          index = token_by_delim(line,var_from_line,',',index+1);
          if(index == (-1)) continue;
          Color1 = strval(var_from_line);
          index = token_by_delim(line,var_from_line,';',index+1);
          Color2 = strval(var_from_line);
          AddStaticVehicleEx(vehicletype,vSpawnX,vSpawnY,vSpawnZ,SpawnRot,Color1,Color2,180); // respawn 3 minutes
        vehicles_loaded++;
    }
    fclose(file_ptr);
    printf("Loaded %d vehicles from: %s",vehicles_loaded,filename);
    return vehicles_loaded;
}
stock token_by_delim(const string[], return_str[], delim, start_index)
{
    new x=0;
    while(string[start_index] != EOS && string[start_index] != delim) {
        return_str[x] = string[start_index];
        x++;
        start_index++;
    }
    return_str[x] = EOS;
    if(string[start_index] == EOS) start_index = (-1);
    return start_index;
} 
Step 3:
Go to your game mode and add this:
Go to your game mode and add this:
PHP Code:
#include <loadvehicles> 
Step 4:
Under OnGameModeInit, add LoadStaticVehiclesFromFile("vehicles/file.txt");
I will show all possible vehicle loads below.
Step 5:
Start your server!
-------------------------------------------------------------------------------------------------------------------------------------
There are 19 possible LoadStaticVehicle files
You can tell what the vehicles will be loaded with the file names.
Under OnGameModeInit, add LoadStaticVehiclesFromFile("vehicles/file.txt");
I will show all possible vehicle loads below.
Step 5:
Start your server!
-------------------------------------------------------------------------------------------------------------------------------------
There are 19 possible LoadStaticVehicle files
You can tell what the vehicles will be loaded with the file names.
PHP Code:
//Possible Vehicle Loads
LoadStaticVehiclesFromFile("vehicles/bone.txt");
LoadStaticVehiclesFromFile("vehicles/flint.txt");
LoadStaticVehiclesFromFile("vehicles/ls_airport.txt");
LoadStaticVehiclesFromFile("vehicles/ls_gen_inner.txt");
LoadStaticVehiclesFromFile("vehicles/ls_gen_outer.txt");
LoadStaticVehiclesFromFile("vehicles/ls_law.txt");
LoadStaticVehiclesFromFile("vehicles/lv_airport.txt");
LoadStaticVehiclesFromFile("vehicles/lv_gen.txt");
LoadStaticVehiclesFromFile("vehicles/lv_law.txt");
LoadStaticVehiclesFromFile("vehicles/pilots.txt");
LoadStaticVehiclesFromFile("vehicles/red_county.txt");
LoadStaticVehiclesFromFile("vehicles/sf_airport.txt");
LoadStaticVehiclesFromFile("vehicles/sf_gen.txt");
LoadStaticVehiclesFromFile("vehicles/sf_law.txt");
LoadStaticVehiclesFromFile("vehicles/sf_train.txt");
LoadStaticVehiclesFromFile("vehicles/tierra.txt");
LoadStaticVehiclesFromFile("vehicles/trains.txt");
LoadStaticVehiclesFromFile("vehicles/trains_platform.txt");
LoadStaticVehiclesFromFile("vehicles/whetstone.txt"); 
-------------------------------------------------------------------------------------------------------------------------------------
That is pretty much how simple it is! Have fun!
	That is pretty much how simple it is! Have fun!




