Loading car .txt's -
SKAzini - 28.06.2012
Is there any way I can load those car spawn .txt's located in "\scriptfiles\vehicles" without typing CreateVehicle( infront of them, and put them in my gamemode?
Re: Loading car .txt's -
iGetty - 28.06.2012
pawn Код:
#include "../scriptfiles/vehicles"
It's something along that line.
Re: Loading car .txt's -
SKAzini - 28.06.2012
Код:
expression has no effect
As those .txt's doesnt have CreateVehicle before the Model ID,
pawn Код:
415,-2089.7454,-85.3183,34.9356,0.0900,36,1 ;
415,-2076.7393,-84.4259,34.8911,357.8584,116,1 ;
504,-2091.6350,-106.7603,35.1125,179.5832,45,29 ;
560,-2396.2222,-594.7454,132.3533,123.1677,33,0 ;
411,-2414.5781,-586.8558,132.3755,215.3865,112,1 ;
Re: Loading car .txt's -
iGetty - 28.06.2012
Here:
pawn Код:
//Remove the include.
new total_vehicles_from_files = 0;
public OnGameModeInit()
{
// SPECIAL
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");
printf("Total vehicles from files: %d",total_vehicles_from_files);
}
Re: Loading car .txt's -
SKAzini - 28.06.2012
I need the LoadStaticVehiclesFromFile stock..
Re: Loading car .txt's -
iGetty - 28.06.2012
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,%.2f,%.2f,%.2f,%.4f,%d,%d",vehicletype,SpawnX,SpawnY,SpawnZ,SpawnRot,Color1,Color2);
AddStaticVehicleEx(vehicletype,SpawnX,SpawnY,SpawnZ,SpawnRot,Color1,Color2,(30*60)); // respawn 30 minutes
/*new numplate_test[32+1];
format(numplate_test,32,"GRLC{44AA33}%d",vid);
SetVehicleNumberPlate(vid, numplate_test);*/
vehicles_loaded++;
}
fclose(file_ptr);
printf("Loaded %d vehicles from: %s",vehicles_loaded,filename);
return vehicles_loaded;
}
Re: Loading car .txt's -
SKAzini - 28.06.2012
Код:
undefined symbol "token_by_delim"
Changed to,
pawn Код:
index = total_vehicles_from_files(line,var_from_line,',',index);
Had,
Код:
invalid function call, not a valid address
Re: Loading car .txt's -
vyper - 28.06.2012
Include this :
pawn Код:
#include "../include/gl_common.inc"
and use this :
pawn Код:
new total_vehicles_from_files = 0;
public OnGameModeInit()
{
// SPECIAL
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");
printf("Total vehicles from files: %d",total_vehicles_from_files);
}
Re: Loading car .txt's -
SKAzini - 28.06.2012
Thanks, using,
pawn Код:
#include "../include/gl_common.inc"
new VehiclesFiles = 0;
public OnGameModeInit()
{
VehiclesFiles += LoadStaticVehiclesFromFile("vehicles/sf_gen.txt");
VehiclesFiles += LoadStaticVehiclesFromFile("vehicles/sf_airport.txt");
VehiclesFiles += LoadStaticVehiclesFromFile("vehicles/sf_law.txt");
VehiclesFiles += LoadStaticVehiclesFromFile("vehicles/sf_train.txt");
printf("Total vehicles spawned (from files): %d",VehiclesFiles);
return 1;
}