How to write and read on SeifAdmin?
#1

How to write and read on SeifAdmin?

Using:

https://sampwiki.blast.hk/wiki/Fwrite

Im using SeifAdmin for my roleplay from scratch,
And when they filled in male/female, Year born, Where they live,
I want it to save it to the file of there name.
But in the same file of in which SeifAdmin saves all registered and stuff in,
Where would i put these lines to save it?

Would it be:

AccountInfo[playerid][Tut] = 1;
OnPlayerUpdateAccount(playerid);

If so, That dont work
Reply
#2

Quote:
Originally Posted by Torran
AccountInfo[playerid][Tut] = 1;
OnPlayerUpdateAccount(playerid);
That's right, but you'd have to add an extra fwrite line in OnPlayerUpdateAccount callback for the new variable that you want to set.

I don't actually use SeifAdmin but gathering from what you've said, that's pretty much all you need to save it into their account.

So in the OnPlayerUpdateAccount you would add a line like:

pawn Код:
format(string,sizeof(string),"Tut=%d\n",AccountInfo[playerid][Tut]); fwrite(file,string);
Subject to different variable names, of course.

Also you shouldn't need to call OnPlayerUpdateAccount everytime you change a variable that you wish to save, it should only be called OnPlayerDisconnect, which it probably already is, so no need to add extra OnPlayerUpdateAccount calls
Reply
#3

Well in the OnPlayerUpdateAccount callback:
There is this..

pawn Код:
public OnPlayerUpdateAccount(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(AccountInfo[playerid][Logged] == 1)
        {
            new name[MAX_PLAYER_NAME], str[128];
          GetPlayerName(playerid, name, sizeof name);
          format(str, sizeof str, "/sAccounts/%s.seifadmin", name);
          new File:account = fopen(str, io_write);
          if (account)
            {
                AccountInfo[playerid][Cash] = GetPlayerMoney(playerid);
                new file[256];
                {
                    format(file, sizeof file, "Password: %s\n", AccountInfo[playerid][Password]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "AdminLevel: %d\n",AccountInfo[playerid][AdminLevel]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "Cash: %d\n", AccountInfo[playerid][Cash]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "Warnings: %d\n",AccountInfo[playerid][Warns]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "WarnReason1: %s\n",AccountInfo[playerid][WarnReason1]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "WarnReason2: %s\n",AccountInfo[playerid][WarnReason2]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "WarnReason3: %s\n",AccountInfo[playerid][WarnReason3]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "IPAddress: %s\n",AccountInfo[playerid][IP]);
                    {   fwrite(account, file); }
                }
                fclose(account);
            }
        }
    }
    return 1;
}
So i should do this?

pawn Код:
public OnPlayerUpdateAccount(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(AccountInfo[playerid][Logged] == 1)
        {
            new name[MAX_PLAYER_NAME], str[128];
          GetPlayerName(playerid, name, sizeof name);
          format(str, sizeof str, "/sAccounts/%s.seifadmin", name);
          new File:account = fopen(str, io_write);
          if (account)
            {
                AccountInfo[playerid][Cash] = GetPlayerMoney(playerid);
                new file[256];
                {
                    format(file, sizeof file, "Password: %s\n", AccountInfo[playerid][Password]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "AdminLevel: %d\n",AccountInfo[playerid][AdminLevel]);
                    {   fwrite(account, file); }
                                format(file, sizeof file, "Tut: %d\n",AccountInfo[playerid][Tut]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "Cash: %d\n", AccountInfo[playerid][Cash]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "Warnings: %d\n",AccountInfo[playerid][Warns]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "WarnReason1: %s\n",AccountInfo[playerid][WarnReason1]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "WarnReason2: %s\n",AccountInfo[playerid][WarnReason2]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "WarnReason3: %s\n",AccountInfo[playerid][WarnReason3]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "IPAddress: %s\n",AccountInfo[playerid][IP]);
                    {   fwrite(account, file); }
                }
                fclose(account);
            }
        }
    }
    return 1;
}
Reply
#4

That should do it , so when that callback is sent, it will write it to the users account.

I'd imagine the callback is usually sent OnPlayerDisconnect.

Now if you want to set the variable when they join, there should be a similiar system in OnPlayerConnect that sets the variable, so just go there, look at how the other ones are done, and copy one for your tutorial variable
Reply
#5

Ok i will try ina moment
Reply
#6

That works, But if i turn the server off, The back on, It sets it back to 0
Reply
#7

Quote:
Originally Posted by Torran
That works, But if i turn the server off, The back on, It sets it back to 0
You mean that in the file itself, it's set back to 0?
Reply
#8

Well ive added a message OnPlayerSpawn

If: Tut = 1;
Sends me a message saying Tutorial is 1

Else
Sends me a message saying Tutorial is 0,

I type /tutorial to set it to 1,
Then if i go off, Come back on, It ses its 1,
I look in my file, Its also 1,
But if i turn my server off and back on,
The tutorial in my file is 0
Reply
#9

Anyone?
Reply
#10

Have you set so it reads,save and loads in OnPlayerLogin, OnPlayerRegister and OnPlayerUpdateAccount? :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)