SA-MP Forums Archive
Just a simple question :3 - 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: Just a simple question :3 (/showthread.php?tid=371484)



Just a simple question :3 - Guitar - 23.08.2012

Hello,

So, I've got this for saving players' accounts:

pawn Код:
forward SavePlayerStats(playerid);
public SavePlayerStats(playerid)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"Starter",PlayerInfo[playerid][pStarter]);
    INI_WriteInt(File,"Zombie",PlayerInfo[playerid][pZombie]);
    INI_WriteInt(File,"Score",GetPlayerScore(playerid));
    INI_Close(File);
    /*new str[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(str, sizeof(str), "%s got his account saved successfuly.", name);
    SendClientMessageToAll(0x4958761, str);*/

    print("\n----------------------------------");
    print(" Players' accounts saved! On SavePlayerStats");
    print("----------------------------------\n");
    return 1;
}


Can I do this for a target?

pawn Код:
SavePlayerStats(targetid);
?? And will it save the player's stats?


Re: Just a simple question :3 - ZBits - 23.08.2012

Why do you want Target fif if playerid is working?


Re: Just a simple question :3 - HuSs3n - 23.08.2012

ofc you can
and you dont have to change 'playerid' to 'targetid' in SavePlayerStats(playerid) callback


Re: Just a simple question :3 - ZBits - 23.08.2012

pawn Код:
forward SavePlayerStats(targetid);
public SavePlayerStats(targetid)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"Starter",PlayerInfo[playerid][pStarter]);
    INI_WriteInt(File,"Zombie",PlayerInfo[playerid][pZombie]);
    INI_WriteInt(File,"Score",GetPlayerScore(playerid));
    INI_Close(File);
    /*new str[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(str, sizeof(str), "%s got his account saved successfuly.", name);
    SendClientMessageToAll(0x4958761, str);*/

    print("\n----------------------------------");
    print(" Players' accounts saved! On SavePlayerStats");
    print("----------------------------------\n");
    return 1;
}
as Hussan said


Re: Just a simple question :3 - scottyishere - 23.08.2012

pawn Код:
forward SavePlayerStats(targetid);
public SavePlayerStats(targetid)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"Starter",PlayerInfo[playerid][pStarter]);
    INI_WriteInt(File,"Zombie",PlayerInfo[playerid][pZombie]);
    INI_WriteInt(File,"Score",GetPlayerScore(playerid));
    INI_Close(File);
    /*new str[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(str, sizeof(str), "%s got his account saved successfuly.", name);
    SendClientMessageToAll(0x4958761, str);*/

    print("\n----------------------------------");
    print(" Players' accounts saved! On SavePlayerStats");
    print("----------------------------------\n");
    return 1;
}
That's wrong, will give errors.

You can keep the original one and use SavePlayerStats(ANYINTVARIABLE);

You can replace ANYINTVARIABLE with any playerid variable, no need to modify or duplicate the original function.


Re: Just a simple question :3 - Guitar - 23.08.2012

So it works? like this
pawn Код:
SavePlayerStats(targetid);
? Because, I don't want to keep restarting my server, players will think that it has bugs and quit.


Re: Just a simple question :3 - scottyishere - 23.08.2012

Quote:
Originally Posted by Guitar
Посмотреть сообщение
So it works? like this
pawn Код:
SavePlayerStats(targetid);
? Because, I don't want to keep restarting my server, players will think that it has bugs and quit.
Yes.


Re: Just a simple question :3 - HuSs3n - 23.08.2012

Quote:
Originally Posted by Domnic Toretto
Посмотреть сообщение
pawn Код:
forward SavePlayerStats(targetid);
public SavePlayerStats(targetid)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"Starter",PlayerInfo[playerid][pStarter]);
    INI_WriteInt(File,"Zombie",PlayerInfo[playerid][pZombie]);
    INI_WriteInt(File,"Score",GetPlayerScore(playerid));
    INI_Close(File);
    /*new str[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(str, sizeof(str), "%s got his account saved successfuly.", name);
    SendClientMessageToAll(0x4958761, str);*/

    print("\n----------------------------------");
    print(" Players' accounts saved! On SavePlayerStats");
    print("----------------------------------\n");
    return 1;
}
as Hussan said
thats wrong
and i didnt say that

Quote:
Originally Posted by Guitar
Посмотреть сообщение
So it works? like this
pawn Код:
SavePlayerStats(targetid);
? Because, I don't want to keep restarting my server, players will think that it has bugs and quit.
yes it will work