Ajutor Sistem de Puncte

Discutii legate de instalarea, configurarea si modificarea unui server de Counter-Strike.

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Post Reply
User avatar
JusT.
Membru, skill +2
Membru, skill +2
Posts: 761
Joined: 24 Jun 2013, 14:27
Detinator Steam: Da
SteamID: justsstyle
Reputatie: Fost Membru Club eXtreamCS (5 apr - 5 mai - acces in club)
Has thanked: 1 time
Been thanked: 4 times

06 Feb 2016, 23:12

Salut, folosesc un sistem de puncte pe server-ul meu si nu reusesc sa fac ca punctele sa se salveze dupa schimbarea mapei.
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;
}

}
Poate cineva sa ma ajute ?
Post Reply

Return to “Probleme la servere dedicate de Counter-Strike”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 69 guests