Help saving ranks - pRank
#1

I have made an enum containging pRank for me to make some cop commands in certain ranks.

I "built in" my gamemode into SeifAdmin, so on the OnPlayerRegister and OnPlayerLogin there is these stuffs..

pawn Код:
new File:account = fopen(str, io_write);
      if (account)
        {
            strmid(AccountInfo[playerid][Password], password, 0, strlen(password), 255);
            AccountInfo[playerid][Cash] = GetPlayerMoney(playerid);
            new file[128];
            {
                format(file, sizeof file, "Password: %s\n\r", AccountInfo[playerid][Password]);
                {   fwrite(account, file); }
                format(file, sizeof file, "AdminLevel: %d\n\r", 0);
                {   fwrite(account, file); AccountInfo[playerid][AdminLevel] = 0; }
                format(file, sizeof file, "Cash: %d\n\r", AccountInfo[playerid][Cash]);
                {   fwrite(account, file); }
                format(file, sizeof file, "Warnings: %d\n\r",AccountInfo[playerid][Warns]);
                {   fwrite(account, file); }
                format(file, sizeof file, "WarnReason1: %s\n\r",AccountInfo[playerid][WarnReason1]);
                {   fwrite(account, file); }
                format(file, sizeof file, "WarnReason2: %s\n\r",AccountInfo[playerid][WarnReason2]);
                {   fwrite(account, file); }
                format(file, sizeof file, "WarnReason3: %s\n\r",AccountInfo[playerid][WarnReason3]);
                {   fwrite(account, file); }
                format(file, sizeof file, "IPAddress: %s\n\r",ip);
                {   fwrite(account, file); }
                format(file, sizeof file, "Rank: %s\n\r",PlayerInfo[playerid][pRank]);
                {   fwrite(account, file); }
            }
            fclose(account);
And on OnPlayerLogin:

pawn Код:
new File:account = fopen(str, io_read);
    if (account)
    {
      new pass[256];
      new passres[128], value[128];
      fread(account, pass, sizeof pass);
      passres = GetFileString(pass);
      if (!strcmp("Password", passres))
        {
            value = GetFileValue(pass);
            strmid(AccountInfo[playerid][Password], value, 0, strlen(value)-1, 128);
        }
        if (!strcmp(AccountInfo[playerid][Password], password, true))
        {
          while (fread(account, pass, 256))
            {
                passres = GetFileString(pass);
                if (strfind(passres, "AdminLevel") != -1)
                {
                    value = GetFileValue(pass);
                    AccountInfo[playerid][AdminLevel] = strval(value);
                }
                if (strfind(passres, "Cash") != -1)
                {
                    value = GetFileValue(pass);
                    AccountInfo[playerid][Cash] = strval(value);
                }
        if (strfind(passres, "Warnings") != -1)
                {
                    value = GetFileValue(pass);
                    AccountInfo[playerid][Warns] = strval(value);
                }
                if (strfind(passres, "WarnReason1") != -1)
                {
                    value = GetFileValue(pass);
                    strmid(AccountInfo[playerid][WarnReason1], value, 0, strlen(value)-1, 128);
                }
                if (strfind(passres, "WarnReason2") != -1)
                {
                    value = GetFileValue(pass);
                    strmid(AccountInfo[playerid][WarnReason2], value, 0, strlen(value)-1, 128);
                }
            if (strfind(passres, "WarnReason3") != -1)
                {
                    value = GetFileValue(pass);
                    strmid(AccountInfo[playerid][WarnReason3], value, 0, strlen(value)-1, 128);
                }
                if (strfind(passres, "Rank") != -1)
                {
                    value = GetFileValue(pass);
                    strmid(PlayerInfo[playerid][pRank], value, 0, strlen(value)-1, 128);
                }
            }
            fclose(account);
And OnPlayerUpdateAccount

pawn Код:
new File:account = fopen(str, io_write);
          if (account)
            {
                AccountInfo[playerid][Cash] = GetPlayerMoney(playerid);
                new file[128];
                {
                    format(file, sizeof file, "Password: %s\n\r", AccountInfo[playerid][Password]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "AdminLevel: %d\n\r",AccountInfo[playerid][AdminLevel]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "Cash: %d\n\r", AccountInfo[playerid][Cash]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "Warnings: %d\n\r",AccountInfo[playerid][Warns]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "WarnReason1: %s\n\r",AccountInfo[playerid][WarnReason1]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "WarnReason2: %s\n\r",AccountInfo[playerid][WarnReason2]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "WarnReason3: %s\n\r",AccountInfo[playerid][WarnReason3]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "IPAddress: %s\n\r",AccountInfo[playerid][IP]);
                    {   fwrite(account, file); }
                    format(file, sizeof file, "Rank: %s\n\r",PlayerInfo[playerid][pRank]);
                    {   fwrite(account, file); }
                }
                fclose(account);
            }
But next time I logon i dont have that rank.. (I made a little /lol command that sends a msg if you are rank 10 for example, but it doesnt show up! -.-

Please help.
Reply
#2

I suggest you use dini, because if you work with raw files, you're just making it yourself difficult.
Reply
#3

dini is always easyer for saving things
Reply
#4

When I include Dini I get around 26 errors and I have to remove tmp arrays and stuff, and that messes up my whole gamemode..
Reply
#5

Sorry for double post -

Im gonna make an FS ..
Reply
#6

Quote:
Originally Posted by [eX
Klutty ]
When I include Dini I get around 26 errors and I have to remove tmp arrays and stuff, and that messes up my whole gamemode..
You maybe missed a bracket or something.
Reply
#7

Heres the errors:

Quote:

C:\Program\SAMP Server\gamemodes\krpg.pwn(501) : error 021: symbol already defined: "strtok"
C:\Program\SAMP Server\gamemodes\krpg.pwn(516) : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(983) : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(1470) : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(1686) : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(1850) : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(185 : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(1926) : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(1959) : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(1967) : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(199 : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(2030) : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(2036) : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(207 : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(2111) : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(2160) : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(2196) : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(2236) : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(2286) : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(231 : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(2349) : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(2362) : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(2382) : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(2395) : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(2416) : error 047: array sizes do not match, or destination array is too small
C:\Program\SAMP Server\gamemodes\krpg.pwn(2452) : error 047: array sizes do not match, or destination array is too small

The first one I know how to fix but the rest, all of them are
pawn Код:
tmp = strtok(cmdtext, idx);
Reply
#8

new tmp[128] or 256 :>
Reply
#9

Quote:
Originally Posted by Jefff
new tmp[128] or 256 :>
I have one around the beginning of Onplayercommandtext, should i make one at every command that uses tmp?
Reply
#10

No :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)