Saving CreateObject() in a .txt file? -
Shetch - 25.06.2015
I have decided to make an in-game map editor which would load/save projects in the scriptfiles folder. It would save player created maps in the same format as they are used in scripts.
For example:
Код:
CreateObject(param, param, param, param...);
CreateObject(param, param, param, param...);
CreateObject(param, param, param, param...);
CreateObject(param, param, param, param...);
CreateObject(param, param, param, param...);
I was wondering what file saving include would be best to use for this? Is it possible with INI saving includes?
Re: Saving CreateObject() in a .txt file? -
Jonny5 - 25.06.2015
pawn Код:
// example SaveToFile("objs.txt","CreateObject(param, param, param, param...);");
stock SaveToFile(path[],text[]){
new File:handle = fopen(path, io_append);
if(handle)
{
new sOut[1024];
format(sOut,1024,"%s\r\n",text);
fwrite(handle,sOut);
fclose(handle);
return 1;
}
return 0;
}
you could use format first for the text[] argument and save that way.
this function will append to the file each time it is called,
if no file is created it will first create it.,
Re: Saving CreateObject() in a .txt file? -
Shetch - 25.06.2015
Quote:
Originally Posted by Jonny5
pawn Код:
// example SaveToFile("objs.txt","CreateObject(param, param, param, param...);");
stock SaveToFile(path[],text[]){ new File:handle = fopen(path, io_append); if(handle) { new sOut[1024]; format(sOut,1024,"%s\r\n",text); fwrite(handle,sOut); fclose(handle); return 1; } return 0; }
|
How would I go about loading the saved objects? I'm new to SA-MP's default file functions...
Re: Saving CreateObject() in a .txt file? -
Jonny5 - 25.06.2015
personally i would use sqlite or mysql
but to read a file you use fread
https://sampwiki.blast.hk/wiki/Fread
Re: Saving CreateObject() in a .txt file? -
Shetch - 25.06.2015
Yea, I was thinking of using MySQL, but the map editor I expect to be used by mappers and they wouldn't bother installing XAMPP or any other MySQL private server software just to use a map editor, you know.
Thanks anyways!
Re: Saving CreateObject() in a .txt file? -
Jonny5 - 25.06.2015
sqlite is native to samp.
heres what mine look like
http://pastebin.com/sidc9w16
its from 2012 but it will give you an idea
mine was not really a map editor,
youd have to add code to make projects
good luck with it.