Not saving properly - 
Torran -  10.02.2010
pawn Код:
#include <a_samp>
#define FILTERSCRIPT
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
    return 1;
}
public OnFilterScriptExit()
{
    return 1;
}
#endif
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/sethousepos", cmdtext, true, 10) == 0)
    {
      new file[256];
    new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        new File:properties = fopen("/properties.cfg", io_write);
    format(file, sizeof file, "HousePos: %d\n,%d\n,%d\n",x, y, z);
        {   fwrite(properties, file); }
    fclose(properties);
        return 1;
    }
    return 0;
}
 
Thats my code: This is properties.cfg
Код:
HousePos: 1122473179
,-1033036543
,1070202880
 And well how do i get it to read from that file and set the players position?
Also if i was to example: [houseeterx],[houseentery][houseeterz][houseexitx][houseexity][houseexitz]
How would i get it to read which bits housexit, and which bit is house enter,
edit: sorry about the name it was originally for the coords not saving properly but i have fixed that
Re: Not saving properly - 
Joe Staff -  10.02.2010
a fast method would be to use sscanf and use spaces inbetween the parameters instead of commas.
Re: Not saving properly - 
Torran -  10.02.2010
How would i get it to read the X, Y, Z positions and set the players pos to that?
And also how would i get it to recgonize whats HouseExit and HouseEnter
Re: Not saving properly - 
MadeMan -  10.02.2010
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/sethousepos", cmdtext, true) == 0)
    {
        new file[256];
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        new File:properties = fopen("/properties.cfg", io_write);
        format(file, sizeof file, "%f,%f,%f",x, y, z);
        fwrite(properties, file);
        fclose(properties);
        return 1;
    }
    return 0;
}
 
Loading part. Haven't tested but should work.
pawn Код:
new Float:x, Float:y, Float:z;
new file[256];
new File:properties = fopen("/properties.cfg", io_read);
fread(properties, file);
sscanf(file, "p,fff", x, y, z);
fclose(properties);
SetPlayerPos(playerid, x, y, z);
 
Re: Not saving properly - 
Torran -  10.02.2010
Ok,
One more question:
If a player buys a hotel room.
And it saves to hotelguests.cfg
It will save, Room number and players name,
But how would i get it to read the players name
Re: Not saving properly - 
MadeMan -  10.02.2010
Use sscanf
https://sampwiki.blast.hk/wiki/Sscanf
https://sampwiki.blast.hk/wiki/Fast_Commands
http://forum.sa-mp.com/index.php?topic=145539.0
pawn Код:
sscanf(file, "p,is", room, playername);
 
Re: Not saving properly - 
Torran -  10.02.2010
Ive not a clue how to use sscanf,
Even if i read about it,
I wouldnt be able to learn unless there was a tutorial for this specific bit, But there aint
Re: Not saving properly - 
MadeMan -  10.02.2010
pawn Код:
sscanf(file, "p,is", room, playername);
 
file - the string you read from file
"i" - number, in this case hotel room
"s" - string, in this case player's name
https://sampwiki.blast.hk/wiki/Fast_Commands - this is a tutorial how to use sscanf with commands.
Re: Not saving properly - 
Torran -  10.02.2010
Er ok so where would i put that code?
Re: Not saving properly - 
MadeMan -  10.02.2010
Quote:
| 
					Originally Posted by Torran 
 Er ok so where would i put that code? | 
 Where you want to load the info from file.