How to save and load from file -
CAR - 21.10.2009
I know, I must search first, but I've a problem with searching:
[img width=1024 height=599]/imageshack/img21/5819/sampnotallowed.jpg[/img]
I want to do in-game /addcar and then comes AddStaticVehicle in a file. (Cars.txt)
I know something to put
pawn Код:
new Float:GetX, Float:GetY, Float:GetZ, Float:GetA, string[256], auto;
GetPlayerPos(playerid, Float:GetX, Float:GetY, Float:GetZ);
GetPlayerFacingAngle(playerid, Float:GetA);
auto = GetVehicleModel(GetVehicleID(playerid));
format(string, sizeof(string), "AddStaticVehicle(%d, %f, %f, %f, %f, 0, 0);", auto, Float:GetX, Float:GetY, Float:GetZ, Float:GetA);
With dini I can't use I think because then you must have a name for it: Car=AddStaticVehicle(...);
And when you want the next car, then the first car is deleted...
I don't want that.
How can I save lines like AddStaticVehicle in a file and load it in OnGameModeInit()
Please help me
Re: How to save and load from file -
pagie1111 - 21.10.2009
SAMP Debug. Use /save ingame.
Re: How to save and load from file -
CAR - 21.10.2009
Yes I know but I don't want that, I want to make it in a file: /scriptfiles/cars.txt
And then it loads in: OnGameModeInit()
How to do that?
Just like a In-Game Object maker or something, then it saves also anywhere isn't it?
But how can I do that?
Re: How to save and load from file -
saiberfun - 21.10.2009
gawsh like in the topic i made this mornin'(which got deleted and i didnt get a mesage aboutr why which id want to kno!)
u can use
http://www.******.com/cse/home?cx=01...69:munac565hug
to search around X_X
Re: How to save and load from file -
CAR - 21.10.2009
Thanks for how to know to search
I now have this:
pawn Код:
new StringInF[256], carid, Float:CX, Float:CY, Float:CZ, Float:CA;
carid = GetVehicleModel(GetVehicleID(playerid));
GetPlayerPos(playerid, Float:CX, Float:CY, Float:CZ);
GetPlayerFacingAngle(playerid, Float:CA);
format(StringInF, sizeof(StringInF), "AddStaticVehicle(%d, %f, %f, %f, %f, 0, 0);", carid, Float:CX, Float:CY, Float:CZ, Float:CA);
But now my questions;
how to save in a file
(no names; like dini)
how to load all lines in the file in: public OnGameModeInit()
Re: How to save and load from file -
saiberfun - 21.10.2009
Quote:
Originally Posted by CAR
Thanks for how to know to search
I now have this:
pawn Код:
new StringInF[256], carid, Float:CX, Float:CY, Float:CZ, Float:CA; carid = GetVehicleModel(GetVehicleID(playerid)); GetPlayerPos(playerid, Float:CX, Float:CY, Float:CZ); GetPlayerFacingAngle(playerid, Float:CA); format(StringInF, sizeof(StringInF), "AddStaticVehicle(%d, %f, %f, %f, %f, 0, 0);", carid, Float:CX, Float:CY, Float:CZ, Float:CA);
But now my questions;
how to save in a file (no names; like dini)
how to load all lines in the file in: public OnGameModeInit()
|
ever tried wiki?
https://sampwiki.blast.hk/wiki/File_Functions
Re: How to save and load from file -
CAR - 21.10.2009
Yes, I use it much :P
Now I must do:
pawn Код:
public OnGameModeInit()
{
File:cars=fopen("cars.txt", io_read);
}
isn't it?
Re: How to save and load from file -
CAR - 21.10.2009
Quote:
Originally Posted by Y_Leѕѕ
Quote:
Originally Posted by Y_Leѕѕ
Look in the modes which come with the 0.3 server.
|
Did you just miss this entire post?
|
I think so, where can I find that?
(because the command didn't work)
Re: How to save and load from file -
CAR - 21.10.2009
Maybe stupid of me...
I don't understand you anymore
Re: How to save and load from file -
dice7 - 21.10.2009
Open the file with oi_write or io_append mode (read the wiki for differences), write with fwrite, then close with fclose. To read, you'll need something like sscanf so you can dismantle the string to the integers/floats you want. Also, use something like '|' or ',' between integers/floats when you write so you can extract the data then with the help of that delimiter
https://sampwiki.blast.hk/wiki/Fopen
https://sampwiki.blast.hk/wiki/Scripting...ions_Old#fread
https://sampwiki.blast.hk/wiki/Scripting...ons_Old#fwrite
https://sampwiki.blast.hk/wiki/Scripting...ons_Old#fclose
https://sampwiki.blast.hk/wiki/Fast_Commands#sscanf
https://sampwiki.blast.hk/wiki/Sscanf_code