how can i use the vehicles from the scriptfiles
#1

in this folder C:\Program Files\Rockstar Games\GTA San Andreas\scriptfiles\vehicles

for my gamemode



thanks in advance
Reply
#2

Quote:
Originally Posted by johnathon956
in this folder C:\Program Files\Rockstar Games\GTA San Andreas\scriptfiles\vehicles

for my gamemode



thanks in advance
Add this anywhere in your script.

pawn Код:
stock LoadStaticVehiclesFromFile(const filename[])
{
    new File:file_ptr;
    new line[256];
    new var_from_line[64];
    new vehicletype;
    new Float:SpawnX;
    new Float:SpawnY;
    new Float:SpawnZ;
    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;
        SpawnX = floatstr(var_from_line);

        index = token_by_delim(line,var_from_line,',',index+1);
        if(index == (-1)) continue;
        SpawnY = floatstr(var_from_line);

        index = token_by_delim(line,var_from_line,',',index+1);
        if(index == (-1)) continue;
        SpawnZ = 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);

        //printf("%d,%d,%f,%f,%f,%f,%d,%d",total_vehicles_from_files+vehicles_loaded+1,vehicletype,SpawnX,SpawnY,SpawnZ,SpawnRot,Color1,Color2);

        AddStaticVehicleEx(vehicletype,SpawnX,SpawnY,SpawnZ,SpawnRot,Color1,Color2,(30*60)); // respawn 30 minutes
        vehicles_loaded++;
    }

    fclose(file_ptr);
    printf("Loaded %d vehicles from: %s",vehicles_loaded,filename);
    return vehicles_loaded;
}
Then in OnGameModeInit add this:
pawn Код:
total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/trains.txt");
    total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/pilots.txt");

    // LAS VENTURAS
   total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_law.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_airport.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_gen.txt");
 
  // SAN FIERRO
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_law.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_airport.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_gen.txt");
 
  // LOS SANTOS
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_law.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_airport.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_gen_inner.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_gen_outer.txt");
 
  // OTHER AREAS
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/whetstone.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/bone.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/flint.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/tierra.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/red_county.txt");
- Code from GrandLarc gamemode.
Reply
#3

Quote:
Originally Posted by Carlton
Quote:
Originally Posted by johnathon956
in this folder C:\Program Files\Rockstar Games\GTA San Andreas\scriptfiles\vehicles

for my gamemode



thanks in advance
Add this anywhere in your script.

pawn Код:
stock LoadStaticVehiclesFromFile(const filename[])
{
    new File:file_ptr;
    new line[256];
    new var_from_line[64];
    new vehicletype;
    new Float:SpawnX;
    new Float:SpawnY;
    new Float:SpawnZ;
    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;
        SpawnX = floatstr(var_from_line);

        index = token_by_delim(line,var_from_line,',',index+1);
        if(index == (-1)) continue;
        SpawnY = floatstr(var_from_line);

        index = token_by_delim(line,var_from_line,',',index+1);
        if(index == (-1)) continue;
        SpawnZ = 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);

        //printf("%d,%d,%f,%f,%f,%f,%d,%d",total_vehicles_from_files+vehicles_loaded+1,vehicletype,SpawnX,SpawnY,SpawnZ,SpawnRot,Color1,Color2);

        AddStaticVehicleEx(vehicletype,SpawnX,SpawnY,SpawnZ,SpawnRot,Color1,Color2,(30*60)); // respawn 30 minutes
        vehicles_loaded++;
    }

    fclose(file_ptr);
    printf("Loaded %d vehicles from: %s",vehicles_loaded,filename);
    return vehicles_loaded;
}
Then in OnGameModeInit add this:
pawn Код:
total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/trains.txt");
    total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/pilots.txt");

    // LAS VENTURAS
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_law.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_airport.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_gen.txt");
 
  // SAN FIERRO
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_law.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_airport.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_gen.txt");
 
  // LOS SANTOS
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_law.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_airport.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_gen_inner.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_gen_outer.txt");
 
  // OTHER AREAS
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/whetstone.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/bone.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/flint.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/tierra.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/red_county.txt");
- Code from GrandLarc gamemode.
lol i knew it would be simple im just a noob at scripting :P
Reply
#4

Код:
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(30) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(31) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(44) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(44) : error 017: undefined symbol "token_by_delim"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(47) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(50) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(50) : error 017: undefined symbol "token_by_delim"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(54) : error 017: undefined symbol "token_by_delim"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(58) : error 017: undefined symbol "token_by_delim"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(62) : error 017: undefined symbol "token_by_delim"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(67) : error 017: undefined symbol "token_by_delim"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(71) : error 017: undefined symbol "token_by_delim"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(76) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(252) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(252) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(253) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(256) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(256) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(257) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(257) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(258) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(261) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(262) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(263) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(266) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(267) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(268) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(269) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(272) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(273) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(274) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(275) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(276) : error 017: undefined symbol "total_vehicles_from_files"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


24 Errors.
Reply
#5

Quote:
Originally Posted by johnathon956
Код:
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(30) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(31) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(44) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(44) : error 017: undefined symbol "token_by_delim"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(47) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(50) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(50) : error 017: undefined symbol "token_by_delim"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(54) : error 017: undefined symbol "token_by_delim"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(58) : error 017: undefined symbol "token_by_delim"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(62) : error 017: undefined symbol "token_by_delim"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(67) : error 017: undefined symbol "token_by_delim"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(71) : error 017: undefined symbol "token_by_delim"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(76) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(252) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(252) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(253) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(256) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(256) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(257) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(257) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(258) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(261) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(262) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(263) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(266) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(267) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(268) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(269) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(272) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(273) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(274) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(275) : error 017: undefined symbol "total_vehicles_from_files"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\Untitled.pwn(276) : error 017: undefined symbol "total_vehicles_from_files"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


24 Errors.
Remove the LoadStaticVehicleFromFile code, and under #include <a_samp> add this:
pawn Код:
#include "../include/gl_common.inc"
Reply
#6

still didnt work GRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR RRRRRRRRRRR
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)