SA-MP Forums Archive
How to load info from files? - 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: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to load info from files? (/showthread.php?tid=123574)



How to load info from files? - Torran - 26.01.2010

How do i load things from files, For example: vehicles, Or whatever


Re: How to load info from files? - Nakash - 26.01.2010

Quote:
Originally Posted by Torran
How do i load things from files, For example: vehicles, Or whatever
"The Godfather" gamemode shows it.


Re: How to load info from files? - Torran - 26.01.2010

Not like that, Like grand larcency or whatever its called


Re: How to load info from files? - bajskorv123 - 26.01.2010

I agree, it would be much easier to load vehicles from a file (Like an include file) then putting all the rows in your script because it takes soo much space if you have many cars...


Re: How to load info from files? - Torran - 26.01.2010

Quote:
Originally Posted by [NWA
Hannes ]
I agree, it would be much easier to load vehicles from a file (Like an include file) then putting all the rows in your script because it takes soo much space if you have many cars...
No i mean like the Grand Larcency gamemode or whatever its called,
It loads vehicle spawns from, Vehicles.txt or w/e


Re: How to load info from files? - bajskorv123 - 26.01.2010

Nvm, Someone help us


Re: How to load info from files? - Micko9 - 26.01.2010

Quote:
Originally Posted by Torran
Quote:
Originally Posted by [NWA
Hannes ]
I agree, it would be much easier to load vehicles from a file (Like an include file) then putting all the rows in your script because it takes soo much space if you have many cars...
No i mean like the Grand Larcency gamemode or whatever its called,
It loads vehicle spawns from, Vehicles.txt or w/e
nah

want easyer spawn makeing try this : Search on ******.com.. or wait il find it ah there Debug Mode- VERRY USEFUL use /v
spawn a veh with a name find the names at the internet and drive the vehicle where u want it to be and TADA! u saved it how? type in /debug dump
after to save all vehs

now
remember : you must restart the server and add into your gamemode the txt from DEBUG-DUMP.txt ( in scriptfiles ) + clear the DEBUG-DUMP.txt becouse if you do not restart the server - BOOM it will save the same veh again watch yourself lol


however its a great script


Re: How to load info from files? - Torran - 26.01.2010

Thats useless compared to what we want,
Il have a look in the GL gamemode and find it, Then post it here


Re: How to load info from files? - bajskorv123 - 26.01.2010

I dont know but, a command or something that loads vehicles from like scriptfiles/vehicles/lv_airport.txt?


Re: How to load info from files? - Torran - 26.01.2010

This is what i want, And i find it:

EDITED:

pawn Код:
//Top of script
new total_vehicles_from_files=0;

//OnGameModeInit
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");

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;
}
Will edit with the rest so no errors/warnings - EDITED IT