SA-MP Forums Archive
Save - Load Objects - [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: Save - Load Objects - [FILES] (/showthread.php?tid=121966)



Save - Load Objects - [FILES] - pagie1111 - 19.01.2010

In all good development of Awa-Map. I am working on a feature that you can save a map. And it will save it in a format that the server can load and apply to the server when a player comes and loads that map.

Can I please get some suggestions on how to do this?

You will get credits if you are the person who helped me get this feature working 100% - bug free


Re: Save - Load Objects - [FILES] - dice7 - 19.01.2010

Here's the grandlarc example with vehicles

pawn Code:
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;
}



Re: Save - Load Objects - [FILES] - X-Zone - 19.01.2010

Quote:
Originally Posted by {Awaran};
In all good development of Awa-Map. I am working on a feature that you can save a map. And it will save it in a format that the server can load and apply to the server when a player comes and loads that map.

Can I please get some suggestions on how to do this?

You will get credits if you are the person who helped me get this feature working 100% - bug free
get 100 % bug free?Sorry but it's not possible . Every game mode lacks somewhere.


Re: Save - Load Objects - [FILES] - pagie1111 - 19.01.2010

Any one know the lowest modelid and the highest modelid for objects?


Re: Save - Load Objects - [FILES] - pagie1111 - 19.01.2010

Quote:
Originally Posted by Seif_
Quote:
Originally Posted by {Awaran};
Any one know the lowest modelid and the highest modelid for objects?
Look through the MEd.
MEd? lol.


Re: Save - Load Objects - [FILES] - pagie1111 - 19.01.2010

Didn't help me