[Pomoc] Koliko sati igrac nije bio u serveru
Results 1 to 13 of 13
  1. #1
    Senior Member Array
    Join Date
    Jun 2015
    Location
    Home
    Karma
    3

    Default Koliko sati igrac nije bio u serveru

    Sam naslov kaze, potreban mi je plugin koji ce provjeriti koliko sati igrac nije bio online u serveru.

  2. #2
    Junior Member Array
    Join Date
    Jun 2015
    Karma
    0

    Default

    gametracker.rs ,ili .com, ukucas nik igraca i vidis kada je poslednji put igrao. Nema potrebe ubacivati nepotrebne plugine.

  3. #3
    Senior Member Array
    Join Date
    Jun 2015
    Location
    Home
    Karma
    3

    Default

    Da nema potrebe ne bih ni trazio takav plugin

  4. #4
    Senior Member Array
    Join Date
    Jun 2015
    Location
    Podgorica (Montenegro)
    Age
    20
    Karma
    5

    Default

    Quote Originally Posted by Ofnz View Post
    gametracker.rs ,ili .com, ukucas nik igraca i vidis kada je poslednji put igrao. Nema potrebe ubacivati nepotrebne plugine.
    Nema potrebe da mu odredjujes hoce li ili ne. Ako je trazio plugin znaci da ga ne zanima gametracker.rs/com

  5. #5
    Senior Member Array
    Join Date
    Apr 2011
    Location
    The Great Slavistania
    Age
    20
    Karma
    20

    Default

    Ovo je napisano na brzaka, nije testirano i pruza samo osnovnu funkcionalnost, bitno je da skapiras koncept, tako da mozes da unapredis plugin i da napravis svoj.
    Princip je veoma prost.
    Kada se igrac diskonektuje, plugin zabelezi njegov nick i trenutni time stamp, a kada udje na server, negov zapis u bazi bude obrisan.
    Kada ti ukucas komandu kojoj prosledjujes Steam ID igraca, plugin gleda da li je igrac u bazi, zatim uzima timestamp njegovog zadnjeg izlaska sa servera i oduzima ga od trenutnog, da bi dobio broj sekundi.
    Zatim deli broj sekudni sa 3600 da bi dobio broj sati.

    PS: SteamID moras da uneses izmedju navodnika.
    Primer: pabs_lookop "STEAM_0:0:92384728"

    Code:
    #include < amxmodx >
    #include < amxmisc >
    #include < nvault >
    #include < regex >
    
    new g_iVault;
    new Regex: g_rPatternSteamID = REGEX_PATTERN_FAIL;
    
    public plugin_init( ) {
    	register_plugin( "Player Absence Tracker", "1.0", "Milutinke (ByM)" );
    	
    	g_iVault = nvault_open( "PlayerAbsenceTracker" );
    	
    	new iReturn, szError[ 128 ];
    	g_rPatternSteamID = regex_compile("^^STEAM_0:[01]:\d+$", iReturn, szError, charsmax( szError ) );
        
    	if(g_rPatternSteamID == REGEX_PATTERN_FAIL)
    		log_amx( "Error creating SteamID pattern (%d): %s", iReturn, szError );
    		
    	register_concmd( "pabs_lookop", "fw_LookopCommand", ADMIN_BAN, "pabs_lookop <SteamID>" );
    }
    
    public fw_LookopCommand( iPlayer, iLevel, iCid ) {
    	if( !cmd_access( iPlayer, iLevel, iCid, 1 ) )
    		return PLUGIN_HANDLED;
    		
    	new szSteamID[ 32 ];
    	read_argv( 1, szSteamID, charsmax( szSteamID ) );
    	
    	if( !IsValidSteamID( szSteamID ) ) {
    		console_print( iPlayer, "Please enter valid Steam ID!" );
    		return PLUGIN_HANDLED;
    	}
    		
    	new szData[ 64 ];
    	new szDataParts[ 2 ][ 32 ];
    	new iTemp;
    	new iFound = nvault_lookup( g_iVault, szSteamID, szData, charsmax( szData ), iTemp );
    
    	if( iFound ) {
    		if( parse( szData, szDataParts[ 0 ], charsmax( szDataParts[ ] ), szDataParts[ 1 ], charsmax( szDataParts[ ] ) ) < 2 ) {
    			console_print( iPlayer, "Hmmm... something is wrong!" );
    			return PLUGIN_HANDLED;
    		}
    		
    		new iHours = ( get_systime( ) - str_to_num( szDataParts[ 1 ] ) ) / 3600;
    		console_print( iPlayer, "Player %s has been absent for %d hours!", szDataParts[ 0 ], iHours );
    	} else console_print( iPlayer, "Requested player is not found!" );
    		
    	return PLUGIN_HANDLED;
    }
    
    public client_authorized( iPlayer ) {
    	new szSteamID[ 32 ];
    	get_user_authid( iPlayer, szSteamID, charsmax( szSteamID ) );
    	
    	new szData[ 64 ];
    	new iTemp;
    	new iFound = nvault_lookup( g_iVault, szSteamID, szData, charsmax( szData ), iTemp );
    
    	if( iFound )
    		nvault_remove( g_iVault, szSteamID );
    }
    
    public client_disconnect( iPlayer ) {
    	new szSteamID[ 32 ];
    	get_user_authid( iPlayer, szSteamID, charsmax( szSteamID ) );
    	
    	new szNick[ 32 ];
    	get_user_name( iPlayer, szNick, charsmax( szNick ) );
    	
    	new szData[ 64 ];
    	formatex( szData, charsmax( szData ), "%s %d", szNick, get_systime( ) );
    	nvault_set( g_iVault, szSteamID, szData );
    }
    
    public plugin_end( ) {
    	if( g_iVault )
    		nvault_close( g_iVault );
    }
    
    stock bool: IsValidSteamID( const szSteamID[ ] ) {
    	new iTemp;
    	return ( g_rPatternSteamID != REGEX_PATTERN_FAIL && regex_match_c( szSteamID, g_rPatternSteamID, iTemp ) > 0 );
    }
    Last edited by milutinke2; 13-09-2017 at 22:05.

  6. #6
    Senior Member Array
    Join Date
    Jun 2013
    Location
    Beograd
    Karma
    0

    Default

    Quote Originally Posted by Ofnz View Post
    gametracker.rs ,ili .com, ukucas nik igraca i vidis kada je poslednji put igrao. Nema potrebe ubacivati nepotrebne plugine.
    A sta ako igrac promeni nick, kako ces ga onda naci pomocu carobnog stapica kad je poslednji put bio na serveru..

  7. #7
    Senior Member Array
    Join Date
    Jun 2015
    Location
    Home
    Karma
    3

    Default

    @milutinke: Hvala ti puno. Mozes li samo napraviti umjesto nVault-a MySQL i da se igracu pri ulasu na server ispise broj sati koji nije proveo na serveru (bez ikakvih clcmds i concmds)

  8. #8
    Senior Member Array
    Join Date
    Apr 2011
    Location
    The Great Slavistania
    Age
    20
    Karma
    20

    Default

    Quote Originally Posted by Croxeye View Post
    @milutinke: Hvala ti puno. Mozes li samo napraviti umjesto nVault-a MySQL i da se igracu pri ulasu na server ispise broj sati koji nije proveo na serveru (bez ikakvih clcmds i concmds)
    Sam uradi, nemam ja vremena.

  9. #9
    Senior Member Array
    Join Date
    Jun 2015
    Location
    Home
    Karma
    3

    Default

    Uredu, hvala u svakom slucaju. K+

  10. #10
    Senior Member Array
    Join Date
    Jun 2015
    Location
    Home
    Karma
    3

    Default

    Pokusao sam napraviti pomocu MySQL-a ali ispisuje prevelik broj sati. Moze li mi neko reci u cemu je problem

    PHP Code:
    new disconnect_time[33], iHours;

    public 
    client_putinserver(id)
    {
        
    CheckDisconnectTime(id);
    }

    public 
    client_disconnect(id)
    {
        
    SaveDisconnectTime(id); // U bazi se spasi u obliku npr: 1505767323
    }

    public 
    CheckDisconnectTime(id)
    {
        new 
    auth[33];
        
    get_user_name(idauth32);
        
        new 
    Handle:SQLConnection iErrorCode szError32 ];
        
    SQLConnection SQL_Connectg_SQLTuple iErrorCode szError charsmaxszError ) );
        
        if( 
    SQLConnection == Empty_Handle )
            
    set_fail_stateszError );
            
        new 
    Handle:Query SQL_PrepareQuerySQLConnection "SELECT `Disconnect time` FROM `save_data` WHERE `Nick` = '%s'" auth );
        
        if( !
    SQL_ExecuteQuery ) )
        {
            
    SQL_QueryErrorQuery g_szQueryCache 100 );
            
    set_fail_stateg_szQueryCache );
        }
        
        if(
    SQL_NumResults(Query))
        {
            
    disconnect_time[id] = SQL_ReadResult(Query0);
            
            
    iHours = ( get_systime( ) - str_to_numdisconnect_time[id] ) ) / 3600;
            
            
    set_task(5.0"PrintDisconnectTime"id);
        }
    }

    public 
    PrintDisconnectTime(id)
    {
        
    ColorChat(idGREEN"Nisi bio na serveru %d sati"iHours// Rezultat bude npr: Nisi bio na serveru 418268 sati


  11. #11
    Senior Member Array
    Join Date
    Aug 2013
    Location
    Forbidden Forest
    Karma
    6

    Default

    Cemu ovo "str_to_num( disconnect_time[id] )" ? Sumnjam da si broj snimao kao string.
    Pomoc oko plugina, TS3-a, discord-a mozete dobiti samo u vidu objasnjenja.
    P.S. Nemojte smarati/hejtovati obzirom da to niko ne voli a ja licno cu samo da vas kuliram.
    P.P.S. Nemojte pitati stvari na PM vec otvori temu.

  12. #12
    Senior Member Array
    Join Date
    Jun 2015
    Location
    Home
    Karma
    3

    Default

    Upravu si, nisam Samim tim je i milutinke pogrijesio. Sada radi super. Hvala

  13. #13
    Senior Member Array
    Join Date
    Apr 2011
    Location
    The Great Slavistania
    Age
    20
    Karma
    20

    Default

    Quote Originally Posted by Croxeye View Post
    Upravu si, nisam Samim tim je i milutinke pogrijesio. Sada radi super. Hvala
    Nisam pogresio, cuvao sam nick i vreme u stringu, zatim kada se komanda izvrsi, rastavljao sam string na nick i na broj sekundi, koji sam morao da pretvorim u integer iz stringa.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •