Raised This Month: $12 Target: $400
 3% 

Time played - First seen - Last seen ( Nvault & SQL )


Post New Thread Reply   
 
Thread Tools Display Modes
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-19-2022 , 05:40   Re: Time played - First seen - Last seen ( Nvault & SQL )
Reply With Quote #21

Quote:
Originally Posted by The RaiD. View Post
can u add a top15 for all players?
Requirements:
nVault Utility
nVault Array
Unix Time

The command: say /toptime

Note: it works with sql and nvault
Attached Files
File Type: sma Get Plugin or Get Source (TimePlayed.sma - 108 views - 17.4 KB)
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 05-19-2022 at 07:01.
Supremache is offline
Krystek.
Member
Join Date: May 2022
Old 05-19-2022 , 08:38   Re: Time played - First seen - Last seen ( Nvault & SQL )
Reply With Quote #22

What do I have to do for the w / toptime to show the time, e.g. 3 day 1 hours 24 minutes
And remove the unnecessary FIRST SEEN and LAST SEEN for me because when I try it does not work

Last edited by Krystek.; 05-19-2022 at 09:15.
Krystek. is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-19-2022 , 09:24   Re: Time played - First seen - Last seen ( Nvault & SQL )
Reply With Quote #23

Quote:
Originally Posted by Krystek. View Post
What do I have to do for the w / toptime to show the time, e.g. 3 day 1 hours 24 minutes
The maximum motd characters is 1536 so if i added this format it will appear just 5 players

Quote:
And remove the unnecessary FIRST SEEN and LAST SEEN for me because when I try it does not work
What do you mean it's not working?
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 05-19-2022 at 09:26.
Supremache is offline
Krystek.
Member
Join Date: May 2022
Old 05-19-2022 , 09:38   Re: Time played - First seen - Last seen ( Nvault & SQL )
Reply With Quote #24

Quote:
Originally Posted by Supremache View Post
The maximum motd characters is 1536 so if i added this format it will appear just 5 players
By removing FIRST SEEN and LAST SEEN, I would have had room for the days:hours:minutes format

Quote:
What do you mean it's not working?
Basically, I was able to remove it, but a little complicated code prevents me from figuring out how to get the Days:Hours:Minutes format.
Krystek. is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-19-2022 , 10:03   Re: Time played - First seen - Last seen ( Nvault & SQL )
Reply With Quote #25

Quote:
Originally Posted by Krystek. View Post
By removing FIRST SEEN and LAST SEEN, I would have had room for the days:hours:minutes format



Basically, I was able to remove it, but a little complicated code prevents me from figuring out how to get the Days:Hours:Minutes format.
Replace this function:
Code:
public ShowTop10( id, Handle:iQuery, const szError[ ], iErrCode, szData[ ], iDataSize )
{
	new iVault , iRow , iCount , iNextOffset , iCurrentOffset , szKey[ 45 ] , iAvailablePlayers , pdVal[ PlayerData ];
	new szMOTD[ 1536 ] , iPos, iTime;

	if( get_pcvar_num( g_cSaveMethod ) )
	{
		iPos = formatex( szMOTD , charsmax( szMOTD ) , "<body bgcolor=#000000><font color=#98f5ff><pre>" );
		iPos += formatex( szMOTD[ iPos ] , charsmax( szMOTD ) - iPos , "%2s %-22.22s %s^n" , "#" , "Name" , "Time Played" );
		new iNumResults = SQL_NumResults( iQuery ), szName[ MAX_NAME_LENGTH ];
		
		id = szData[ 0 ];
		
		if( iNumResults ) 
		{
			for(new i; i < min( iNumResults , 10 ); i++)
			{
				SQL_ReadResult( iQuery, SQL_FieldNameToNum( iQuery, "Name" ), szName, charsmax( szName ) )
				iTime = SQL_ReadResult( iQuery, SQL_FieldNameToNum( iQuery, "Time Played" ) )
				
				iPos += formatex( szMOTD[ iPos ] , charsmax( szMOTD ) - iPos ,"%2d %-22.22s %s^n", ( i + 1 ) , szName, get_time_length_ex( iTime ) );
				
				SQL_NextRow( iQuery );
			}
		}
	}
	else
	{				
		enum _:Top15Info
		{
			nVault_Offset,
			TimePlayed_Value,
			First_Seen_Value,
			LastSeen_Value
		}
	    
		static iSortData[ MAX_PLAYER_SUPPORT ][ Top15Info ];
		nvault_close( g_iVault );
		g_iVault = nvault_open( NVAULT_DATABASE );
	    
		iVault = nvault_util_open( NVAULT_DATABASE );
	    
		iCount = nvault_util_count( iVault );
	    
		for ( iRow = 0 ; iRow < iCount && iRow < MAX_PLAYER_SUPPORT ; iRow++ )
		{
			iNextOffset = nvault_util_read_array( iVault , iNextOffset , szKey , charsmax( szKey ) , pdVal[ PlayerData:0 ] , sizeof( pdVal ) );
		
			iSortData[ iRow ][ nVault_Offset ] = iCurrentOffset;
		
			iSortData[ iRow ][ TimePlayed_Value ] = pdVal[ Time_Played ];
			iSortData[ iRow ][ First_Seen_Value ] = pdVal[ First_Seen ];
			iSortData[ iRow ][ LastSeen_Value ] = pdVal[ Last_Seen ];
			
			iCurrentOffset = iNextOffset;
		}
		
		SortCustom2D( iSortData , min( iCount , MAX_PLAYER_SUPPORT ) , "CompareTime" );
	
		iPos = formatex( szMOTD , charsmax( szMOTD ) , "<body bgcolor=#000000><font color=#98f5ff><pre>" );
		iPos += formatex( szMOTD[ iPos ] , charsmax( szMOTD ) - iPos , "%2s %-22.22s %s^n" , "#" , "Name" , "Time Played" );
	    
		iAvailablePlayers = min( iCount , 10 );
	    
		for ( iRow = 0 ; iRow < iAvailablePlayers ; iRow++ )
		{
			iCurrentOffset = iSortData[ iRow ][ nVault_Offset ];
			nvault_util_read_array( iVault , iCurrentOffset , szKey , charsmax( szKey ) , pdVal[ PlayerData:0 ] , sizeof( pdVal ) );

			iPos += formatex( szMOTD[ iPos ] , charsmax( szMOTD ) - iPos ,"%2d %-22.22s %s^n", ( iRow + 1 ) , pdVal[ PlayerName ] , get_time_length_ex( pdVal[ Time_Played ] ) );
		}
	    
		nvault_util_close( iVault );
	}
	    
	formatex( szMOTD[ iPos ], charsmax( szMOTD ) - iPos , "</body></font></pre>" );
	    
	show_motd( id , szMOTD , "Time Played Top 10" );
	    
	return PLUGIN_HANDLED;
}
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
Krystek.
Member
Join Date: May 2022
Old 05-22-2022 , 15:40   Re: Time played - First seen - Last seen ( Nvault & SQL )
Reply With Quote #26

/toptime does not work as offline toptime .. only displays online players.

I'm not sure but I just changed it

Code:
 SELECT * FROM `%s` WHERE Player = '%s'
on
Code:
 "SELECT * FROM `TimePlayed` WHERE Player = Name ORDER BY `Time Played` DESC LIMIT 10"
Is it appropriate?

Last edited by Krystek.; 05-22-2022 at 16:08.
Krystek. is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-22-2022 , 16:56   Re: Time played - First seen - Last seen ( Nvault & SQL )
Reply With Quote #27

Quote:
Originally Posted by Krystek. View Post
/toptime does not work as offline toptime .. only displays online players.

I'm not sure but I just changed it

Code:
 SELECT * FROM `%s` WHERE Player = '%s'
on
Code:
 "SELECT * FROM `TimePlayed` WHERE Player = Name ORDER BY `Time Played` DESC LIMIT 10"
Is it appropriate?
Hmm, I have tested only nvault and i thought there is no problem with sql also i have gone to my univirsty a i cant test it, for now try what you typed and replace min( iNumResults , 10 ) to iNumResults
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
Krystek.
Member
Join Date: May 2022
Old 05-22-2022 , 17:06   Re: Time played - First seen - Last seen ( Nvault & SQL )
Reply With Quote #28

Quote:
Originally Posted by Supremache View Post
Hmm, I have tested only nvault and i thought there is no problem with sql also i have gone to my univirsty a i cant test it, for now try what you typed and replace min( iNumResults , 10 ) to iNumResults
Is it about such an application?

Code:
for(new i; i < iNumResults ; i++)
Krystek. is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-22-2022 , 17:16   Re: Time played - First seen - Last seen ( Nvault & SQL )
Reply With Quote #29

Quote:
Originally Posted by Krystek. View Post
Is it about such an application?

Code:
for(new i; i < iNumResults ; i++)
Yes, it's also if it's doesn't work then try to use nvault untill i get back..
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
Krystek.
Member
Join Date: May 2022
Old 07-21-2022 , 03:52   Re: Time played - First seen - Last seen ( Nvault & SQL )
Reply With Quote #30

Quote:
Originally Posted by Supremache View Post
Yes, it's also if it's doesn't work then try to use nvault untill i get back..
When is the improvement and optimization of all bugs?
Krystek. is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:18.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode