De exemplu: e mapa de_dust2x2, eu am 250 de puncte, se schimba mapa pe de_inferno si am 0 puncte in loc sa am tot 250.
Punctele si numele player-ului se salveaza intr-un fisier .dat dar nu sunt si citite de acolo :-? Punctele ti se pastreaza daca iesi si intri inapoi pe server inainte sa se schimbe mapa..
Codul pentru salvarea punctelor :
Code: Select all
new szFile [ 256 ];
Code: Select all
new Dir [ 64 ];
get_configsdir ( Dir, sizeof ( Dir ) -1 ); // folderul configs
format ( szFile, sizeof ( szFile ) -1, "%s/Points.dat", Dir );
Code: Select all
public client_authorised( id ) {
if ( !is_user_bot ( id ) || !is_user_hltv ( id ) )
LoadPoints( id )
return PLUGIN_CONTINUE;
}
public client_disconnect( id ) {
if ( !is_user_bot ( id ) || !is_user_hltv ( id ) )
SavePoints( id )
return PLUGIN_CONTINUE;
}
Code: Select all
public SavePoints( id ) {
new Name [ 32 ];
get_user_name ( id, Name, sizeof ( Name ) -1 );
new Save [ 1024 ];
format ( Save, sizeof ( Save ) -1, "^"%s^" %d", Name, Points [ id ] );
new Line [ 128 ], Arg1 [ 32 ];
new Linie, IsPlayer = false;
new iFile = fopen ( szFile, "rt" );
while ( !feof ( iFile ) ) {
fgets ( iFile, Line, 127 );
parse ( Line, Arg1, 31 );
if ( equali ( Arg1, Name ) ) {
write_file ( szFile, Save, Linie );
IsPlayer = true;
break;
}
Linie++;
}
fclose ( iFile );
if ( !IsPlayer )
write_file ( szFile, Save, -1 );
}
public LoadPoints( id ) {
{
new Name [ 32 ];
get_user_name ( id, Name, sizeof ( Name ) -1 );
new Line [ 128 ], Arg [ 32 ], Arg1 [ 32 ];
new IsPlayer = false;
new iFile = fopen ( szFile, "rt" )
while ( !feof ( iFile ) ) {
fgets ( iFile, Line, 127 );
trim ( Line );
parse ( Line, Arg, 31, Arg1, 31 );
if ( equali ( Arg, Name ) ) {
Points [ id ] = str_to_num ( Arg1 );
IsPlayer = true;
break;
}
}
fclose ( iFile );
if ( !IsPlayer )
Points [ id ] = 0;
}
}