SA-MP Forums Archive
Save/load Objects - 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)
+--- Thread: Save/load Objects (/showthread.php?tid=320417)



Save/load Objects - Dawntide - 22.02.2012

Hello,

So i want to save and load ingame created objects, they should load on server start and save when ever I place a new object.

Can someone tell me how to do that?

thanks in advance!


Re: Save/load Objects - Madd Kat - 22.02.2012

Well its not a simple tell you,

There is some basic concepts to know,
Ill try to help

How are you planing to save the data?
You bsicly have three options
Database using mysql
Ini file using yini or dini
Or a raw text file.

If you look at the gl gamemode there is a
Example loading cars from raw files.

To save you should look at the wiki for the file functions,

If your open to any of the ways i can show you how i do it in my GM
Im using. Ycmd, sscanf, file functions from the wiki
to save and load,

Hths


AW: Save/load Objects - Dawntide - 23.02.2012

Yes, would be nice. I tried it with file functions before, but i failed. I would appreciate it if you could show and explain.


Re: Save/load Objects - Ballu Miaa - 23.02.2012

U know what? I just Copied all the CreateObject code's from my GM and made a new include with the name "myobjects". You can save it on notepad by doing /inc extension in the end of the name.

and add #include <myobjects>

Under OnGameModeInIt.


Re: Save/load Objects - park4bmx - 23.02.2012

well to save and load the objects is not really a simple job.
but the first thing you wil have to do is:
pawn Code:
//create a variable with the MAX_OBJECTS , the maximum objects you want
new PlayerObject[MAX_PLAYERS][MAX_OBJECTS];

//Then with every single object yo create save its Id with the variable.
new Obj = CreateObject(playerid,//so on...
PlayerObject[playerid][1]= Obj;//this will be saved in the first slot ID
this is not a good example becouse you need the X,Y,Z but i cant explain it better on my phone :X
also you will need to loob throught all the slots to see if its empty so u can save the obj id on it.

Why you need the variable?
well if you will want to remove the objects in game two i would say that you can just point to an Slot and it will destroy its ID


AW: Save/load Objects - Dawntide - 23.02.2012

So how i can get the X,Y,Z and the object ID as variable and save/load it.