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

[CS:S] Clan Tags AFK status


Post New Thread Reply   
 
Thread Tools Display Modes
Author
klausenbusk
AlliedModders Donor
Join Date: Jan 2011
Plugin ID:
2305
Plugin Version:
1.9
Plugin Category:
General Purpose
Plugin Game:
Counter-Strike: Source
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Check than a player is AFK by looking at his Clan
    Old 04-09-2011 , 14:11   [CS:S] Clan Tags AFK status
    Reply With Quote #1

    Clan Tag AFK status
    This plugin check if player are afk, and sets their status as a clan tag.



    Cvars:
    • sm_clafk_time 30 - Sets time without client have run commands, changed cvar or position before status are set to AFK
    • sm_clafk_version 1.9 - Clan Tag AFK version
    HOW-IT-WORK:
    • OnPluginStart a timer will be made, if clients movement buttons are being processed the timer will be rested.
    • When client join, a timer will be made, if the timer runs out, then client is AFK.
    • If the client runs a command or change a cvar, the timer will be reset
    Installation:
    • Move clantag-afk.smx into you Sourcemod/plugins folder
    • Move clafk.phrases.txt to uoi Sourcemod/translations folder
    TODO:
    • immunity
    • sm_clafk - Determines plugin functionality (0 = Disabled, 1 = Tag all players, 2 = Tag tagless players 3 = Only chang Tag when AFK 4 = Only chang Tag when ONLINE
    Changelog:
    Code:
    2015-03-18 (v1.9)
    Switched to "OnClientSayCommand", instant of manually say and say_team command hooks.
    "sm_clafk_time" is now "saved" to a variable on change, instant of retrieving on every afk reset.
    Other small changes #7..
    2014-12-31 (v1.8)
    Changed from movement check to button check, inspired by  "[TF2] Play Or Leave - a safer method of detecting AFKs"
    2012-08-01 (v1.7) (600 downloads)
    Updated for SM 1.4, don't work with older version without code change. 
    2011-10-25 (v1.6)
    Now resetTimer every time you move, instant of position check every XX sec. (should prevent teleport and similar to change your status to ONLINE).
    Added Polish language. (Credit Arcobot)
    Now use the N "format specifier" instant of GetClientName();
    2011-05-18 (v1.5)
    resetTimer not world check (should prevent you get errors, if you map say any thing or console..)
    2011-05-13 (v1.4)
    Fixed so timer also are reset when you type something in team chat :)
    Changed "< MaxClients" to "<= MaxClients".
    2011-04-1 (v1.3)
    Some code changs. Thank RedSword
    2011-04-1 (v1.2)
    Updated to have Multi-Language support.
    Now also reset the timer, when the client writes something in chat.
    2011-04-09 (v1.1)
    Updated to use the MaxClient variable instead of GetMaxClients()
    2011-04-09 (v1.0)
    Initial release.
    PS: Hope you understand, i'm not the best to English
    Attached Files
    File Type: txt clafk.phrases.txt (282 Bytes, 672 views)
    File Type: sp Get Plugin or Get Source (clantag-afk.sp - 942 views - 2.3 KB)

    Last edited by klausenbusk; 03-18-2015 at 18:06. Reason: v1.8; fb given
    klausenbusk is offline
    RedSword
    SourceMod Plugin Approver
    Join Date: Mar 2006
    Location: Quebec, Canada
    Old 04-11-2011 , 01:46   Re: [CS:S] Clan Tags AFK status
    Reply With Quote #2

    "are now AFK" --> "is now AFK"

    Also, for a first plugin you could try adding translation file (english + your own language). There are multiple plugins already existing where you can see how it works (and wiki).

    edit : (plugin description) "Check than a player is AFK by looking at his Clan" --> "Change clan tag of afk people to AFK"
    RedSword is offline
    klausenbusk
    AlliedModders Donor
    Join Date: Jan 2011
    Old 04-11-2011 , 05:37   Re: [CS:S] Clan Tags AFK status
    Reply With Quote #3

    Quote:
    Originally Posted by RedSword View Post
    "are now AFK" --> "is now AFK"

    Also, for a first plugin you could try adding translation file (english + your own language). There are multiple plugins already existing where you can see how it works (and wiki).

    edit : (plugin description) "Check than a player is AFK by looking at his Clan" --> "Change clan tag of afk people to AFK"
    I considered adding it before I made ​​it public
    I will look at it when i get home
    klausenbusk is offline
    RedSword
    SourceMod Plugin Approver
    Join Date: Mar 2006
    Location: Quebec, Canada
    Old 04-11-2011 , 11:11   Re: [CS:S] Clan Tags AFK status
    Reply With Quote #4

    You might have see this comment comming :

    you should allow someone to keep his clan tag. Always being ONLINE can be annoying (let a clan be a clan).

    EDIT :

    You should also rework your code to get your plugin approved...

    Use "MAXPLAYERS + 1" rather than "32". Some servers have more than 31 players ("new bob[32]" will create a 32-sized array with 0 to 31 indexes, making it bug for player #32 and not work for over 32 players).

    Code:
    for (new i = 1; i <= MaxClients; i++)
    {
    	if (i > 0 )
    I don't really see why "i" would be equal to 0. I also doubt MaxClients would do an integer overflow...

    Code:
    if (index == -1)
    		{
    			index = PushArrayCell(posList, GetClientUserId(i))
    		}	
    		else
    
    		position2[0] = GetArrayCell(posList, index, 1); // position[0]
    		position2[1] = GetArrayCell(posList, index, 2); // position[1]
    		position2[2] = GetArrayCell(posList, index, 3); // position[2]
    WHUTTT ?!?!? seriously.... (else)

    Code:
    if (index == -1 || position2[0] != position[0] || position2[1] != position[1] || position2[2] != position[2] || angles2[0] != angles[0] || angles2[1] != angles[1] || angles2[2] != angles[2])
    I suggest you do it on multiple lines to allow a better code-reading from other people.

    Code:
    iif (AFKTimers[client] != INVALID_HANDLE)
    {
    	if(CloseHandle(AFKTimers[client]))
    	{
    		AFKTimers[client] = INVALID_HANDLE
    	}
    	AFKTimers[client] = CreateTimer(GetConVarFloat(FindConVar("sm_clafk_time")), StatusAFK, client)
    	CS_SetClientClanTag(client, "ONLINE");
    }
    else
    {
    	AFKTimers[client] = CreateTimer(GetConVarFloat(FindConVar("sm_clafk_time")), StatusAFK, client)
    	CS_SetClientClanTag(client, "ONLINE");
    }
    Duplicated code. You don't need "else" if you're doing it in both case.

    Code:
    decl
    Good thing you thought about using them.

    You should either always use semi-columns (;) or never, that way your code has some coherence. If you want them you can add "#pragma semicolon 1" at the top of your file if you want the compiler to tell you when you're not using them.

    I also think you should space out more your code so it is more readable (add some linefeed (newline) between different codeblocks).

    Last edited by RedSword; 04-11-2011 at 11:47.
    RedSword is offline
    klausenbusk
    AlliedModders Donor
    Join Date: Jan 2011
    Old 04-12-2011 , 08:14   Re: [CS:S] Clan Tags AFK status
    Reply With Quote #5

    I will loke on it when i get time
    I hav tried a little with something like this
    sm_clafk - Determines plugin functionality (0 = Disabled, 1 = Tag all players, 2 = Tag tagless players 3 = Only chang Tag when AFK 4 = Only chang Tag when ONLINE

    But i can't see than it works, because CS:S seems to have the following bug
    http://forums.steampowered.com/forum....php?t=1769537
    so i wait for a fix, and so will i try again
    klausenbusk is offline
    SHAREN
    Senior Member
    Join Date: Dec 2011
    Old 02-29-2012 , 11:58   Re: [CS:S] Clan Tags AFK status
    Reply With Quote #6

    Maybe 2012-01-08 (v1.7)

    I'm waiting for when you add sm_clafk 3 = Only chang Tag when AFK
    SHAREN is offline
    Send a message via Skype™ to SHAREN
    RedSword
    SourceMod Plugin Approver
    Join Date: Mar 2006
    Location: Quebec, Canada
    Old 03-04-2015 , 19:59   Re: [CS:S] Clan Tags AFK status
    Reply With Quote #7

    Hey for approval you'll have to change the following :
    • You should use AddCommandListener rather than RegConsoleCmd on "say" and "say_team". You might want to read around on the forum the distinction between both.
    • Since sm_clafk_time is local to your plugin, you shouldn't use FindConVar with it (notably it may be executed a lot of time per frame).
    • Remove FCVAR_REPLICATED
    • Remove your dead code L22-23, or add the appropriate parts/functions and a possible comment (if it's a "hidden" functionality for you)
    • You're using both CloseHandle and KillTimer. Be consistent.

    I see that you're using timers without userId but since you're killing them OnClientDisconnect it is fine by me.

    Red
    __________________
    My plugins :
    Red Maze
    Afk Bomb
    RAWR (per player/rounds Awp Restrict.)
    Kill Assist
    Be Medic

    You can also Donate if you appreciate my work
    RedSword is offline
    klausenbusk
    AlliedModders Donor
    Join Date: Jan 2011
    Old 03-05-2015 , 10:46   Re: [CS:S] Clan Tags AFK status
    Reply With Quote #8

    Quote:
    Originally Posted by RedSword View Post
    Hey for approval you'll have to change the following :
    • You should use AddCommandListener rather than RegConsoleCmd on "say" and "say_team". You might want to read around on the forum the distinction between both.
    • Since sm_clafk_time is local to your plugin, you shouldn't use FindConVar with it (notably it may be executed a lot of time per frame).
    • Remove FCVAR_REPLICATED
    • Remove your dead code L22-23, or add the appropriate parts/functions and a possible comment (if it's a "hidden" functionality for you)
    • You're using both CloseHandle and KillTimer. Be consistent.

    I see that you're using timers without userId but since you're killing them OnClientDisconnect it is fine by me.

    Red
    Like this?
    Edit: Updated!
    Attached Files
    File Type: sp Get Plugin or Get Source (clantag-afk.sp - 881 views - 2.2 KB)

    Last edited by klausenbusk; 03-05-2015 at 11:08.
    klausenbusk is offline
    RedSword
    SourceMod Plugin Approver
    Join Date: Mar 2006
    Location: Quebec, Canada
    Old 03-13-2015 , 00:17   Re: [CS:S] Clan Tags AFK status
    Reply With Quote #9

    Hey; almost. If someone joins and he has the "AFK" tag, he'll be triggering resetTimer... which will print to everyone. That's an easy exploit that can annoy.

    I suggest simply setting a player's tag to ONLINE when he joins, or use a bool argument in reset timer for the initial execution, or even use a side variable (that last option wouldn't be pretty IMO).

    Also nicely seen OnClientSayCommand vs manually hooking.

    Red

    edit : marked as fb given
    __________________
    My plugins :
    Red Maze
    Afk Bomb
    RAWR (per player/rounds Awp Restrict.)
    Kill Assist
    Be Medic

    You can also Donate if you appreciate my work

    Last edited by RedSword; 03-13-2015 at 20:16.
    RedSword is offline
    klausenbusk
    AlliedModders Donor
    Join Date: Jan 2011
    Old 03-18-2015 , 11:09   Re: [CS:S] Clan Tags AFK status
    Reply With Quote #10

    Quote:
    Originally Posted by RedSword View Post
    Hey; almost. If someone joins and he has the "AFK" tag, he'll be triggering resetTimer... which will print to everyone. That's an easy exploit that can annoy.
    Fixed.. I update the post, when you is satisfied.
    Attached Files
    File Type: sp Get Plugin or Get Source (clantag-afk.sp - 855 views - 2.3 KB)
    klausenbusk 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 03:57.


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