Problem with the Record System !
#1

Hello there guys.
I have a problem with my Players Online Record..
I'll paste here my code:

OnPlayerConnect:
Код:
ServerInfo[ sPlayers ]++;
	if( ServerInfo[ sRecord ] < ServerInfo[ sPlayers ] )
	{
	    new Date[ 6 ];
		getdate( Date[ 2 ], Date[ 1 ], Date[ 0 ] );
		gettime( Date[ 3 ], Date[ 4 ], Date[ 5 ] );
		
		getdate( ServerInfo[ sY ], ServerInfo[ sM ], ServerInfo[ sD ] );
		gettime( ServerInfo[ sH ], ServerInfo[ sMi ], ServerInfo[ sS ] );

        if( !strlen( ServerInfo[ RecordBy ] ) ) format( ServerInfo[ RecordBy ], MAX_PLAYER_NAME, "Nobody" );
        
        format( eQuery, sizeof( eQuery ), "INSERT INTO `ServerRecord` (`Players`,`Date`,`Time`,`By`,`DateOLD`,`TimeOLD`,`ByOLD`) VALUES('%d','%d/%d/%d','%d:%d:%d','%s','%d/%d/%d','%d:%d:%d','%s')", ServerInfo[ sPlayers ], Date[ 0 ], Date[ 1 ], Date[ 2 ], Date[ 3 ], Date[ 4 ], Date[ 5 ], PlayerName( playerid ), ServerInfo[ sD ], ServerInfo[ sM ], ServerInfo[ sY ],ServerInfo[ sH ], ServerInfo[ sMi ], ServerInfo[ sS ], ServerInfo[ RecordBy ] );
		mysql_tquery( DB_Connect, eQuery, "ConfigRecord", "i", playerid );
		
		format( eBigString, 4140, "[RECORD]: {%06x}%s(%d) {FFFFFF}has broke the record of {FF0000}%d {FFFFFF}online Players !", GetPlayerColor( playerid ) >>> 8, PlayerName( playerid ), playerid, ServerInfo[ sRecord ] );
		SendClientMessageToAll( 0xFF0000FF, eBigString );

		for( new i = 0; i < 100; i++ )
			SendClientMessage( playerid, 0xFFFFFFFF, "" );

		FormatMSG( playerid, 0xFF0000FF, "[RECORD]: {FFFFFF}You have broken {FF0000}%s {FFFFFF}record with {FF0000}%d {FFFFFF}online Players !", ServerInfo[ RecordBy ], ServerInfo[ sRecord ] );

		format( ServerInfo[ RecordBy ], MAX_PLAYER_NAME, "%s", PlayerName( playerid ) );
        ServerInfo[ sRecord ] = ServerInfo[ sPlayers ];
	}
Config and Check Record:
Код:
function ConfigRecord( playerid )
{
    eQuery[ 0 ] = EOS;
    format( eQuery, sizeof( eQuery ), "SELECT `Players`, `Date`, `Time`, `By` FROM `ServerRecord`" );
    mysql_tquery( DB_Connect, eQuery, "CheckRecord", "i", playerid );
    return 1;
}

function CheckRecord( playerid )
{
	new Rows, Fields, String[ 5 ][ 128 ]; eQuery[ 0 ] = EOS;
	cache_get_data( Rows, Fields, DB_Connect );

    if( Rows )
	{
		cache_get_field_content( 0, "Players", String[ 0 ], DB_Connect, 64 );
		ServerInfo[ sRecord ] = strval(  String[ 0 ] );
		
	    cache_get_field_content( 0, "Date", String[ 1 ], DB_Connect );
		sscanf( String[ 1 ], "p<:>ii", ServerInfo[ sD ], ServerInfo[ sM ], ServerInfo[ sY ] );

	    cache_get_field_content( 0, "Time", String[ 2 ], DB_Connect );
		sscanf( String[ 2 ], "p<:>iii", ServerInfo[ sH ], ServerInfo[ sMi ], ServerInfo[ sS ] );

	    cache_get_field_content( 0, "By", String[ 3 ], DB_Connect );
		format( ServerInfo[ RecordBy ], MAX_PLAYER_NAME, "%s", String[ 3 ] );
	}
	else
	{
	    format( eQuery, 128, "INSERT INTO `ServerRecord` VALUES('0','0/0/0','0:0:0','Nobody','0/0/0','0:0:0','Nobody')");
	    mysql_tquery( DB_Connect, eQuery, "", "" );
	}
	return 1;
}
So, the problem is this:
When i connect for the first time on my chat appears:


Ok that's ok if appear: broked by Nobody ( for the first time is Nobody and there are 0 Players ).
Everything works when i reconnect my server. That message dont' appear because there are 1 player and server
record it's not bigger than server players.
Do you think there is a problem when for the first time appears 0 PLAYERS, do you think there must appear 1 Player if the record appear when i connect ( me = 1 player ) i have no ideea :\.

So the second problem is:
When i restart my server. And i re-enter the server the first message appears again:
Код:
broked by Nobody ( for the first time is Nobody and there are 0 Players ).
But on my Database appear that there was 1 player broked by FaLLenGirL, Old Broked by: Nobody.
Can you help me with this ? Please. Thanks.
Reply


Messages In This Thread
Problem with the Record System ! - by FaLLenGirL - 13.11.2016, 14:03
Re: Problem with the Record System ! - by FaLLenGirL - 13.11.2016, 15:43
Re: Problem with the Record System ! - by Logic_ - 13.11.2016, 16:03
Re: Problem with the Record System ! - by FaLLenGirL - 13.11.2016, 16:11
Re: Problem with the Record System ! - by FaLLenGirL - 13.11.2016, 17:02
Re: Problem with the Record System ! - by FaLLenGirL - 14.11.2016, 10:02

Forum Jump:


Users browsing this thread: 2 Guest(s)