Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <a_mysql>
- enum rekInfo {
- data [ 30 ] ,
- rekordas
- }
- new rek [ rekInfo ] ;
- stock getPlayers ( ) {
- new players = 0;
- for ( new i = 0; i < MAX_PLAYERS; i ++ )
- players ++ ;
- return players;
- }
- stock loadRecord ( ) {
- new query [ 50 ] , result [ 100 ] ;
- format ( query , sizeof ( query ) , "SELECT rekordas,data FROM options" ) ;
- mysql_query ( query ) ;
- mysql_store_result ( ) ;
- if ( mysql_num_rows ( ) ) {
- mysql_fetch_row ( result ) ;
- mysql_fetch_field_row ( query , "rekordas" ) ;
- rek [ rekordas ] = strval ( query ) ;
- mysql_fetch_field_row ( query , "data" ) ;
- format ( rek [ data ] , 30 , "%s" , query ) ;
- }
- mysql_free_result ( ) ;
- return true;
- }
- stock saveRecord ( ) {
- new query [ 50 ] ;
- format ( query , sizeof ( query ) ,
- "UPDATE options SET \
- rekordas = %d,\
- data = '%s'" ,
- rek [ rekordas ] , rek [ data ]
- ) ;
- mysql_query ( query ) ;
- return true;
- }
- public OnGameModeInit ( ) {
- loadRecord ( ) ;
- return true;
- }
- public OnGameModeExit ( ) {
- saveRecord ( ) ;
- return true;
- }
- public OnPlayerConnect ( playerid ) {
- if ( getPlayers ( ) >= rek [ rekordas ] ) {
- new string [ 65 ] ;
- rek [ rekordas ] = getPlayers ( ) ;
- new time [ 6 ] ;
- getdate ( time [ 0 ] , time [ 1 ] , time [ 2 ] ) ;
- gettime ( time [ 3 ] , time [ 4 ] , time [ 5 ] ) ;
- format ( rek [ data ] , 30 , "%d-%02d-%02d %02d:%02d:%02d" , time [ 0 ] , time [ 1 ] , time [ 2 ] , time [ 3 ] , time [ 4 ] , time [ 5 ] ) ;
- format ( string , sizeof ( string ) , "Senas rekordas: %d, naujas rekordas %d" , rek [ rekordas ] , getPlayers ( ) ) ;
- SendClientMessageToAll ( -1 , string ) ;
- format ( string , sizeof ( string ) , "Pasiektas %s" , rek [ data ] ) ;
- SendClientMessageToAll ( -1 , string ) ;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement