SA-MP Forums Archive
[Help]saving score system - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Help]saving score system (/showthread.php?tid=206690)



[Help]saving score system - fangoth1 - 04.01.2011

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


Re: [Help]saving score system - Toreno - 04.01.2011

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);



Re: [Help]saving score system - fangoth1 - 04.01.2011

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


Re: [Help]saving score system - fangoth1 - 04.01.2011

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


Re: [Help]saving score system - Sinner - 04.01.2011

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


Re: [Help]saving score system - fangoth1 - 04.01.2011

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


Re: [Help]saving score system - Kwarde - 04.01.2011

Try dini or something.


Re: [Help]saving score system - fangoth1 - 04.01.2011

that would screw with STRTOK wouldnt it


Re: [Help]saving score system - Kwarde - 04.01.2011

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


Re: [Help]saving score system - fangoth1 - 04.01.2011

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