Saving Score Using No Extra Include
#1

How To Save Players Score Using No Extra Include Like dini, Y_ini, Fini.
Just Include <samp>. Can Anyone Tell Me?
Reply
#2

I don't understand why you want this, but here:

Quite useless IMO.

pawn Код:
// For saving:
        new name[MAX_PLAYER_NAME], scr, string[64];
        GetPlayerName( playerid, name, sizeof(name) );
        scr = GetPlayerScore( playerid );
       
        format( string, sizeof(string), "%s.scr" );
       
        new File:userfile = fopen( string, io_write );
        format( string, sizeof(string), "%i",scr );
        fwrite( userfile, string );
        fclose( userfile );
        return 1;

// For Loading:
        new name[MAX_PLAYER_NAME], string[64];
        GetPlayerName( playerid, name, sizeof(name) );

        format( string, sizeof(string), "%s.scr" );
        if( !fexist(string) ) return true;
       
        new File:userfile = fopen( string, io_read );
        fread( userfile, string );
        fclose( userfile );
       
        SetPlayerScore( playerid, strval(string) );
        return 1;
Reply
#3

Not Working. When /Gmx All Players Score Are Same. Can You Try Tell Me Using Dini?
Reply
#4

Quote:
Originally Posted by 0_o
Посмотреть сообщение
Can You Try Tell Me Using Dini?
Dini is slow and outdated. Use Y_Ini or MySQL.
Reply
#5

It's because you save it in OnPlayerDisconnect, and you can't save it on timeout/disconnect. Try to leave the server, and join back in, your score will probably be the same from when you left.

Anyways, here's a DINI version, which I wouldn't recommend:
pawn Код:
//saving:
new
    file[ 128 ]
    ,pName[ 24 ]
;
GetPlayerName( playerid, pName, 24 );
format( file, sizeof file, "%sscr.txt", pName );
if( !dini_Exists( file ) ) {
    dini_Create( file );
}
dini_IntSet( file, "score", GetPlayerScore( playerid ) );

//loading:
new
    file[ 128 ]
    ,pName[ 24 ]
;
GetPlayerName( playerid, pName, 24 );
format( file, sizeof file, "%sscr.txt", pName );
if( dini_Exists( file ) ) {
    SetPlayerScore( playerid, dini_Int( file, "score" ) );
}
Reply
#6

Quote:
Originally Posted by Mean
Посмотреть сообщение
It's because you save it in OnPlayerDisconnect, and you can't save it on timeout/disconnect. Try to leave the server, and join back in, your score will probably be the same from when you left.

Anyways, here's a DINI version, which I wouldn't recommend:
pawn Код:
//saving:
new
    file[ 128 ]
    ,pName[ 24 ]
;
GetPlayerName( playerid, pName, 24 );
format( file, sizeof file, "%sscr.txt", pName );
if( !dini_Exists( file ) ) {
    dini_Create( file );
}
dini_IntSet( file, "score", GetPlayerScore( playerid ) );

//loading:
new
    file[ 128 ]
    ,pName[ 24 ]
;
GetPlayerName( playerid, pName, 24 );
format( file, sizeof file, "%sscr.txt", pName );
if( dini_Exists( file ) ) {
    SetPlayerScore( playerid, dini_Int( file, "score" ) );
}
Do You Know How To Save It As MYSQL? If You Know Please Tell Me.
Reply
#7

i can show you how to make a mysql script included: saving, loading, edit and more just pm me if you are interested
Reply
#8

Saving with native file functions

pawn Код:
SavePlayer(playerid)
{
    new filename[64];
    format(filename, sizeof(filename), "users/%s.ini", PlayerName(playerid));
    new File:handle = fopen(filename, io_write);
    new line[128];
    format(line, sizeof(line), "Score=%d\r\n", GetPlayerScore(playerid)); fwrite(handle, line);
    fclose(handle);
}
Reply
#9

Well How Does LARP Script Save Score?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)