AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get playing time (being in CT or T team) (https://forums.alliedmods.net/showthread.php?t=85059)

Mlk27 02-04-2009 23:45

Get playing time (being in CT or T team)
 
hi. how does get_user_time work?

does it only count total time of a player spends being in server or total time he's being in server and playing (in either ct or t team)? what happen if he goes to spectator team, will his get_user_time increase?



p.s: sawce just answered me on irc that its player's total time in server, regardless the player is playing or just spectating



can anyone show me to make a counter that will count total playing time when a player being in ct or t..stop the counter when he disconnect or join spectator team..and countinue counting if he goes back to ct or t team..

TheRadiance 02-05-2009 01:10

Re: Get playing time (being in CT or T team)
 
From amxmodx.inc:
PHP Code:

/* Returns player playing time in seconds. 
* If flag is set then result is without connection time. */
native get_user_time(indexflag 0); 

Example:
PHP Code:

public client_disconnect(id)
{
    new 
gTime get_user_time(id); 
    
/* If you set the second parameter to 1, you will get user's connection time + it's played time on the server. If  you set it to 0, you will get user's only played time on the server. */


This command won't help you to detect user's played time only in teams (CT, T), it will count all user's time spent on server (from connect or putinserver) irrespective of his team.

anakin_cstrike 02-05-2009 03:31

Re: Get playing time (being in CT or T team)
 
Here's a start
PHP Code:

new Counter33 ][ ];

public 
plugin_init()
    
register_event"TeamInfo""join_team""a" );

public 
join_team()
{
    new 
id read_data);
    new 
team];
    
read_data2team);
    
    switch( 
team] )
    {
        case 
'C'// moved to CT, start to count on Counter[ id ][ 1 ]
        
case 'T':  // moved to T, start to count on Counter[ id ][ 0 ]
        
case 'S'// moved to SPECT, start to count on Counter[ id ][ 2 ]
    
}



Mlk27 02-05-2009 05:57

Re: Get playing time (being in CT or T team)
 
what about this..does this work?

Code:
#include <amxmodx> new g_MaxPlayers new playtime[33] new bool:g_spectator[33] public plugin_init() {     register_event("TeamInfo", "eTeamInfo", "a")     set_task(1.0, "CountPlayTime", _, _, _, "b")     g_MaxPlayers = get_maxplayers() } public client_disconnect(id) {     playtime[id] = 0 } public eTeamInfo() {     new id = read_data(1)     new client_team[2] ; read_data(2, client_team, charsmax(client_team))         switch(client_team[0])     {         case 'C': g_spectator[id] = false         case 'T': g_spectator[id] = false         case 'S': g_spectator[id] = true     } } public CountPlayTime() {     for(new id; id <= g_MaxPlayers; id++)     {         if(is_user_connected(id) && !g_spectator[id])             playtime[id]++     } }


any better idea?

anakin_cstrike 02-05-2009 08:15

Re: Get playing time (being in CT or T team)
 
PHP Code:

for(new id=1



All times are GMT -4. The time now is 01:48.

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