Just a simple question :3
#1

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

Why do you want Target fif if playerid is working?
Reply
#3

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

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

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

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

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

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)