SA-MP Forums Archive
Looping Through All Accounts - 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: Looping Through All Accounts (/showthread.php?tid=410054)



Looping Through All Accounts - -=Dar[K]Lord=- - 24.01.2013

Guys I have stuck with another problem i.e. Looping through all accounts . See basicly i want to loop through all accounts so that we can reset the players account when they are not online but i dont know how to make a loop to Accounts.I Cannot remove every players account i just want to reset their accounts which means that the score , money they have will be "0".

Please Help.

Additional info:-
I Use Y_INI to save accounts .

EDIT:- I need this command so that when the players are not online then also we can reset their account


Re: Looping Through All Accounts - Threshold - 24.01.2013

I wouldn't recommend looping through all accounts, even if that was possible, it can only be done if the file names are listed as integers rather than player names. Instead, make a command like: /resetcash [playername], and use the player name to search through the accounts in scriptfiles, then reset that player's money. If the account doesn't exist, return a message... simple.


Re: Looping Through All Accounts - -=Dar[K]Lord=- - 24.01.2013

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
I wouldn't recommend looping through all accounts, even if that was possible, it can only be done if the file names are listed as integers rather than player names. Instead, make a command like: /resetcash [playername], and use the player name to search through the accounts in scriptfiles, then reset that player's money. If the account doesn't exist, return a message... simple.
no dude then how can we login...


Re: Looping Through All Accounts - Threshold - 24.01.2013

This has nothing to do with deleting, resetting or changing a player's password or deleting their file and creating it again, it's merely a task of setting the money in their player file to 0. I would recommend using y_ini for this kind of task, if you're not using it, it may seem a little more difficult than it should be. So this really shouldn't affect your login...

EDIT: Just saw that you edited your first post, just simply reset everything to 0, EXCEPT changing the password or admin levels etc. Only the variables you want to reset. (I have mistaken what you were asking for, for resetting an offline player's money.) Send me your player variables like: PlayerInfo[playerid][aLevel], or your player data enum, AND the path for your users like: "Server/Users/%s.ini". I will make this command for you, gladly.


Re: Looping Through All Accounts - -=Dar[K]Lord=- - 24.01.2013

Ok .


Re: Looping Through All Accounts - Threshold - 24.01.2013

pawn Код:
CMD:resetstats(playerid, params[])
{
    new name[MAX_PLAYER_NAME];
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "Only Administrators can use this command."); //I wasn't sure if your Admin variable was in a separate enum, or whether you didn't have one at all
    if(sscanf(params,"s[24]",name)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: {FFFFFF}/resetstats [Player Name]");
    new string[150];
    format(string, sizeof(string), UserPath, name);
    if(!fexist(string)) return SendClientMessage(playerid, 0xFF0000FF, "This username does not exist in the database. Check your spelling, and capitals.");
    new User[3];
    User[0] = pInfo[playerid][DPoints];
    User[1] = pInfo[playerid][DKills];
    User[2] = pInfo[playerid][DDeaths];
    INI_ParseFile(string, "LoadStats_%s", false, true, playerid);
    new INI:file = INI_Open(string);
    //INI_SetTag(file, "taghere"); //Replace 'taghere' with your own tag, if you're using one.
    INI_WriteInt(file, "Points", pInfo[playerid][DPoints]); //Change 'Points' to whatever your file variable is
    INI_WriteInt(file, "Kills", pInfo[playerid][DKills]); //Change 'Kills' to whatever your file variable is
    INI_WriteInt(file, "Deaths", pInfo[playerid][DDeaths]); //Change 'Deaths' to whatever your file variable is
    INI_Close(file);
    pInfo[playerid][DPoints] = User[0];
    pInfo[playerid][DKills] = User[1];
    pInfo[playerid][DDeaths] = User[2];
    SaveStats(playerid);
    new playername[24];
    GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
    format(string, sizeof(string), "Administrator %s has reset %s's statistics.", playername, name);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i)) //foreach is the better option
        {
            if(IsPlayerAdmin(i))
            {
                SendClientMessage(i, 0xFFFF00FF, string);
            }
        }
    }
    return 1;
}

forward LoadStats_data(playerid, name[], value[]); //Replace 'data' with whatever your tag is
public LoadStats_data(playerid, name[], value[])
{
    INI_Int("Points", pInfo[playerid][DPoints]); //Change 'Points' to whatever your file variable is
    INI_Int("Kills", pInfo[playerid][DKills]); //Change 'Kills' to whatever your file variable is
    INI_Int("Death", pInfo[playerid][DDeaths]); //Change 'Deaths' to whatever your file variable is
    return 1;
}

stock SaveStats(playerid)
{
    new name[24];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    new string[150];
    format(string, sizeof(string), UserPath, name);
    if(!fexist(string)) return 1;
    new INI:file = INI_Open(string);
    INI_WriteInt(file, "Points", pInfo[playerid][DPoints]); //Change 'Points' to whatever your file variable is
    INI_WriteInt(file, "Kills", pInfo[playerid][DKills]); //Change 'Kills' to whatever your file variable is
    INI_WriteInt(file, "Deaths", pInfo[playerid][DDeaths]); //Change 'Deaths' to whatever your file variable is
    INI_Close(file);
    return 1;
}
Remember to replace your variables with your own, this is an example using the information you provided, so it may or may not work for you if you don't replace the variables.

EDIT: Like antonio said below, you can use MySQL I guess, but I've never used MySQL so I wouldn't be able to tell you.


Re: Looping Through All Accounts - antonio112 - 24.01.2013

You can't loop through all accounts (offline accounts I mean). It is possible only with MYSQL.


Re: Looping Through All Accounts - -=Dar[K]Lord=- - 25.01.2013

Quote:
Originally Posted by antonio112
Посмотреть сообщение
You can't loop through all accounts (offline accounts I mean). It is possible only with MYSQL.
antonio is it possible as Garhouse has done loop in the houses we can also use MAX_ACCOUNTS and all.. just for information


Re: Looping Through All Accounts - Babul - 25.01.2013

there are TWO plugins supporting directory scans:
Filemanager
Directory


Re: Looping Through All Accounts - -=Dar[K]Lord=- - 10.02.2013

Can We do this with Database (DB) Reseting the points?? If yes. Then how?