[Help]saving score system
#1

im having a problem it saves the score, but it saves it like 0.000.000.000
pawn Код:
new score = GetPlayerScore(playerid);
        new string[256];
        new pname[24];
        GetPlayerName(playerid, pname, 24);
        format(string,256,"scores/%s.ini",pname);
       
        new File:scores=fopen(string, io_append);
       
        GetPlayerName(playerid, pname, 24);
        format(string, 256, "%s", score);
        fwrite(scores, string);
        fclose(scores);
       
        return 1;
    }
and yes there more before this this is just the line itself
Reply
#2

Try this:
pawn Код:
new score = GetPlayerScore(playerid);
new string[256], pname[MAX_PLAYERNAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "scores/%s.ini",pname);
new File: scores = fopen(string, io_append);
format(string, sizeof(string), "%i",score);
fwrite(scores, string);
fclose(scores);
Reply
#3

works but, puts score ontop of score like if a player has a score of 1 then relogs , then relogs again its 11
Reply
#4

well i did get that now on player connect how would i set there score to that im confused
Reply
#5

Quote:
Originally Posted by fangoth1
Посмотреть сообщение
well i did get that now on player connect how would i set there score to that im confused
Use a more advanced file writing system
Reply
#6

this is the only one i know how to use somewhat and dont want to study another one for a few weeks just to get a basic understaning
Reply
#7

Try dini or something.
Reply
#8

that would screw with STRTOK wouldnt it
Reply
#9

Better idea. I know the problem.
io_append will ADD string. So it's first "1". On reconnect, it will add "1" too, so it's "11"
Use io_write instead of io_append
Reply
#10

yea i fixed that Kwarde, thanks, but now how would i SetPlayerScore(playerid, Score) when they reconnect? XD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)