Raised This Month: $32 Target: $400
 8% 

SessionUsage


Post New Thread Reply   
 
Thread Tools Display Modes
Author
NinjaSK
Senior Member
Join Date: Sep 2012
Plugin ID:
3274
Plugin Version:
1.0
Plugin Category:
General Purpose
Plugin Game:
Counter-Strike: Source
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Will post to player how long he played in the current session.
    Old 10-05-2012 , 15:01   SessionUsage
    Reply With Quote #1

    • Description
      • Will post to player how long he played in the current session.
    • Changelog
      • Quote:
        05-10-2012 (v1.0)

        *Plugin created.
    • Installation instructions
      • Place the file SessionUsage.sp in cstrike/addons/sourcemod/scripting
      • Place the SessionUsage.smx in cstrike/addons/sourcemod/plugins

    Enjoy!
    Attached Files
    File Type: sp Get Plugin or Get Source (SessionUsage.sp - 709 views - 1.5 KB)

    Last edited by NinjaSK; 11-23-2012 at 04:13.
    NinjaSK is offline
    Sreaper
    髪を用心
    Join Date: Nov 2009
    Old 10-05-2012 , 15:05   Re: SessionUsage
    Reply With Quote #2

    Sounds cool. Can you elaborate on when and where it will be posted?
    Sreaper is offline
    NinjaSK
    Senior Member
    Join Date: Sep 2012
    Old 10-05-2012 , 15:09   Re: SessionUsage
    Reply With Quote #3

    When a player connects to a server the time is recorded. When the player types
    /usage or !usage in chat the server will print a message in the following format:
    (to chat)
    SESSION: # hours # minutes.

    That's the only functionality basically, to allow players to know how long they
    have played in the current session.
    If I have more time I will try to create a database connection to allow overall
    usage in that server.

    Last edited by NinjaSK; 10-05-2012 at 15:11.
    NinjaSK is offline
    shavit
    AlliedModders Donor
    Join Date: Dec 2011
    Location: Israel
    Old 10-05-2012 , 16:32   Re: SessionUsage
    Reply With Quote #4

    Please post the command and add an version cvar/anything else.
    You may need some optimizations.
    I'll do them and post.

    Edit:
    PHP Code:
    #include <sourcemod>

    #pragma semicolon 1

    #define PLUGIN_VERSION "1.1"
     
    public Plugin:myinfo =
    {
        
    name "SessionUsage",
        
    author "NinjaSK",
        
    description"Will post to player how long he played in the current session.",
        
    version PLUGIN_VERSION,
        
    url "http://www.GaymeX.co.il"
    }

    public 
    OnPluginStart()
    {
        
    RegConsoleCmd("sm_usage"Command_Usage"Will show the player how much time he played in the current session.");
        
        new 
    Handle:Version CreateConVar("sm_usage_version"PLUGIN_VERSION"Plugin's version"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
        
        
    SetConVarInt(VersionStringToInt(PLUGIN_VERSION), _true);
    }
     
    public 
    Action:Command_Usage(clientargs)
    {
        new 
    Float:usage GetClientTime(client),
            
    mins RoundToFloor(usage)/60,
            
    hours mins/60;
        
        
    // for(new i = 0;i < hours; i++) new values start with the value 0 by default in Sourcemod.
        
    for(new ihoursi++)
        {
            
    mins -= 60;
        }
        
        if(!
    mins)
        {
            
    PrintToChat(client"\x04SESSION: \x03You need to play more than 1 minute to see your play-time.");
            return 
    Plugin_Handled;
        }
        
        
    PrintToChat(client"\x04SESSION: \x03%d hour(s), \x01minute(s)."hoursmins);
        
        return 
    Plugin_Handled;

    I promise it's better.
    __________________
    retired

    Last edited by shavit; 10-05-2012 at 16:44.
    shavit is offline
    NinjaSK
    Senior Member
    Join Date: Sep 2012
    Old 10-05-2012 , 17:07   Re: SessionUsage
    Reply With Quote #5

    I would like to have it without the (s) though. :/

    Also, what's if(!mins)?

    Last edited by NinjaSK; 10-05-2012 at 17:07.
    NinjaSK is offline
    Mitchell
    ~lick~
    Join Date: Mar 2010
    Old 10-05-2012 , 17:14   Re: SessionUsage
    Reply With Quote #6

    Quote:
    Originally Posted by NinjaSK View Post
    I would like to have it without the (s) though. :/

    Also, what's if(!mins)?
    SOme code i got, and eidted some to work with minutes, and days
    Code:
    GetTimeFromStamp(timestamp, String:TimeStamp[128], index=0) { 
    	new Days = timestamp / 60 / 60 / 24; // Borrowed from Mr.Exvel.
    	new Hours = (timestamp / 60 / 60) % 24;
    	new Mins = (timestamp / 60) % 60;
    	new Secs = timestamp % 60;
    	new String:s_Days[12];
    	new String:s_Hours[12];
    	new String:s_Mins[12];
    	new String:s_Secs[12];
    	FormatEx(s_Days, 12, "%d %s ", Days, (Days == 1) ? "Day" : "Dayss");
    	FormatEx(s_Hours, 12, "%d %s ", Hours, (Hours == 1) ? "Hour" : "Hours");
    	FormatEx(s_Mins, 12, "%d %s%s", Mins, (Mins == 1) ? "Min" : "Mins", (index==1) ? " " : "");
    	if(index==1)
    	{
    		FormatEx(s_Secs, 12, "%d %s", Secs, (Secs == 1) ? "Sec" : "Secs");
    	}
    	Format(TimeStamp, 64, "%s%s%s%s", (Days == 0) ? "" : s_Days, (Hours == 0) ? "" : s_Hours, (Mins == 0) ? "" : s_Mins, (index == 0) ? "" : s_Secs);
    }
    GetTimeFromStamp(timestamp, String:TimeStamp[128], index=0)

    if index==1 then it will add seconds to the string.
    Mitchell is offline
    NinjaSK
    Senior Member
    Join Date: Sep 2012
    Old 10-05-2012 , 17:36   Re: SessionUsage
    Reply With Quote #7

    I thought about that at start but I don't know anyone who actually
    logged into a server for a whole day
    Then again, that calls for a database connection to save overall
    usage like I suggested last time.
    Unfortunately, I don't have a lot of time on my hands for these mod
    changes.

    Last edited by NinjaSK; 10-05-2012 at 17:36.
    NinjaSK is offline
    shavit
    AlliedModders Donor
    Join Date: Dec 2011
    Location: Israel
    Old 10-05-2012 , 17:58   Re: SessionUsage
    Reply With Quote #8

    In an if statement ! means that the value/bool is false, when false == 0 and true != 0.
    Hope you understand.
    __________________
    retired
    shavit is offline
    NinjaSK
    Senior Member
    Join Date: Sep 2012
    Old 10-05-2012 , 18:07   Re: SessionUsage
    Reply With Quote #9

    Yeah, I know how to code in all sorts of languages, I know what
    that sign means I just never saw an if statement where you get:
    if ( not zero like !variable) :/
    NinjaSK is offline
    Mitchell
    ~lick~
    Join Date: Mar 2010
    Old 10-05-2012 , 19:24   Re: SessionUsage
    Reply With Quote #10

    i never saw any body ask for storing the connection time, that is kinda like my player chat rankings plugin lol.
    Mitchell is offline
    Reply



    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 23:52.


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