Save/load Objects
#1

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!
Reply
#2

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
Reply
#3

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

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.
Reply
#5

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
Reply
#6

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


Forum Jump:


Users browsing this thread: 1 Guest(s)