Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define MAX_COCHES (100)
- new cochesitos[MAX_COCHES];
- // leer el archivo
- new File:archivo = fopen("coches/cars.cfg", io_read), datos[200], autos;
- if(archivo){
- while(fread(archivo, datos)){
- _StripNewLine(datos);
- new Float:coord[4], model;
- if(!sscanf(datos, "p<,>dffff", model, coord[0],coord[1],coord[2], coord[4])){
- cochesitos[autos] = AddStaticVehicleEx(model, coord[0],coord[1],coord[2], coord[4], -1, -1, 99999);
- }
- autos++;
- }
- fclose(archivo);
- }
- // guardar en archivo
- new File:archivo = fopen("coches/cars.cfg", io_write), datos[200];
- if(archivo){
- for(new vehicleid=0; vehicleid<MAX_VEHICLES; vehicleid++) {
- if(IsValidVehicle(vehicleid)){
- for(new autos=0; autos<sizeof(cochesitos); autos++){
- if(vehicleid == cochesitos[autos]){
- new Float:coord[4], model;
- model = GetVehicleModel(cochesitos[autos]);
- GetVehiclePos(cochesitos[autos], coord[0],coord[1],coord[2]);
- GetVehicleZAngle(cochesitos[autos], coord[4]);
- format(datos,sizeof(datos),"%d,%f,%f,%f,%f\r\n", model,coord[0],coord[1],coord[2], coord[4]);
- fwrite(archivo, datos);
- DestroyVehicle(cochesitos[autos]);
- }
- }
- }
- }
- fclose(archivo);
- }
- stock _StripNewLine(string[]) {//dini
- new len = strlen(string);
- if (string[0]==0) return ;
- if ((string[len - 1] == '\n') || (string[len - 1] == '\r')) {
- string[len - 1] = 0;
- if (string[0]==0) return ;
- if ((string[len - 2] == '\n') || (string[len - 2] == '\r')) string[len - 2] = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement