Saving Score Using No Extra Include -
0_o - 03.08.2011
How To Save Players Score Using No Extra Include Like dini, Y_ini, Fini.
Just Include <samp>. Can Anyone Tell Me?
Re: Saving Score Using No Extra Include -
iPLEOMAX - 03.08.2011
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;
Re: Saving Score Using No Extra Include -
0_o - 03.08.2011
Not Working. When /Gmx All Players Score Are Same. Can You Try Tell Me Using Dini?
Re: Saving Score Using No Extra Include -
Kush - 03.08.2011
Quote:
Originally Posted by 0_o
Can You Try Tell Me Using Dini?
|
Dini is slow and outdated. Use Y_Ini or MySQL.
Re: Saving Score Using No Extra Include -
Mean - 03.08.2011
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" ) );
}
Re: Saving Score Using No Extra Include -
0_o - 04.08.2011
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.
Re: Saving Score Using No Extra Include -
Tigerkiller - 04.08.2011
i can show you how to make a mysql script included: saving, loading, edit and more just pm me if you are interested
Re: Saving Score Using No Extra Include -
MadeMan - 04.08.2011
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);
}
Re: Saving Score Using No Extra Include -
0_o - 04.08.2011
Well How Does LARP Script Save Score?