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

Top 10 Player HlstatsCE Announcer


Post New Thread Reply   
 
Thread Tools Display Modes
Author
snelvuur
Veteran Member
Join Date: Jun 2008
Location: Netherlands
Plugin ID:
1984
Plugin Version:
2.0
Plugin Category:
Statistical
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Announces a top10 player with a sound and a message to all clients when he/she joins
    Old 10-04-2010 , 09:38   Top 10 Player HlstatsCE Announcer
    Reply With Quote #1

    [ALL] Top 10 Player HlstatsCE Announcer

    This is my first plugin, so forgive me if i have very bad mistakes in it, someone has to learn somewhere too

    Description
    Basicly this plugins announces when somebody with a rank between 1 and 10 joins the servers with a nice sound and a center text message.
    You do need a installation of HlstatsCE for this to work ofcourse.

    Installation

    Install the smx file to your plugins folder.
    Add a entry to your databases.cfg

    Code:
    "top10"
            {
                           "driver"            "default"
                           "host"              "<your ip or hostname>"
                            "database"          "hlstatsx"
                            "user"              "<your db userid>"
                            "pass"              "<your password userid>"
            }

    Cvars


    [code]

    "sm_top10_hlstatsce_enabled", "1", "Whether this plugin should be enabled"
    "sm_top10_hlstatsce_game", buffer, "The shortname found after the game settings for particular servers on admin page"
    "sm_top10_hlstatsce_text", "2", "Default message type. 1 = Center, 2 = Hint text, 3 = Regular text. Leave empty for center"
    "sm_top10_hlstatsce_sounds", "addons/sourcemod/configs/top10_sounds.kv", "The config file containing the paths of sounds to play when a top10 hlstats player joins the game"

    I think thats it, have fun (hopefully)

    Changelog

    Code:
    Version 1.0
    - Initial version
    
    Version 1.01
    - Added css/l4d/l4d2 support
    - Added cvar sm_top10_text (location on where to display)
    
    Version 1.02
    - Added threaded sql calls
    - Fixed not precaching when no sound is set
    - Fixed all the loose identations
    - Hooking of convars for changes (dont know yet if correct)
    
    Version 1.03
    - Fixed sound not set
    - Possible fix for getting a error when client is no longer ingame
    
    Version 1.04
    - Should fix the error when bots/relays are present.
    
    Version 2.0
    - Added cookie support so that it remembers if people want to hear the see/hear the top10.
    - Added custom keyvalue file, so that you can indicate which sound files you add. Because of steam pipe, you would no longer need the sounds on the server itself.
    - Added now keeps tabs on hlxce, if you hide your self on hlxce it will not announce you ingame.
    - Moved to github
    Find the files at: https://github.com/Snelvuur/top10hlxce
    Attached Thumbnails
    Click image for larger version

Name:	example.png
Views:	5344
Size:	31.5 KB
ID:	74650  

    Last edited by snelvuur; 05-24-2013 at 18:02. Reason: updated to version 2.0
    snelvuur is offline
    marvel
    BANNED
    Join Date: Dec 2009
    Old 10-04-2010 , 16:14   Re: Top 10 Player HlstatsCE Announcer
    Reply With Quote #2

    Awesome! Please tell me it works on L4D(2)!
    marvel is offline
    snelvuur
    Veteran Member
    Join Date: Jun 2008
    Location: Netherlands
    Old 10-04-2010 , 19:28   Re: Top 10 Player HlstatsCE Announcer
    Reply With Quote #3

    It should work with l4d(2) and css too, just added that in for gametype. It wont play a sound when it detects l4d(2) since you cant download it anyways afaik.

    I've added a new cvar so you can choose where you want the message to show to people. Let me know if it works for you.
    snelvuur is offline
    jockersoft
    Member
    Join Date: Aug 2008
    Old 10-08-2010 , 12:47   Re: Top 10 Player HlstatsCE Announcer
    Reply With Quote #4

    I think my arena players will like it, they keep typing top10, rank...

    Can you add an option to disable the sound (check if sm_top10_sound is empty and don't precache/play it)?

    And to improve your SM coding (and help you fix the plugin, otherwise it would be hard to get it approved), here are a few suggestions:
    there are many loose indentation warnings while compiling. Not a big issue, but if someone uses another editor your mixing of tabs and spaces for formatting makes things difficult to read

    you should use threaded queries, since the HLX db can be quite slow or on another box

    you should connect to the DB only once at plugin/map start (with SQL_TConnect), not parsing the databases.cfg file everytime someone joins and then establish a connection

    replace
    Code:
    if(SQL_GetRowCount(hQuery) > 0)
    {
       SQL_FetchRow(hQuery);
    with
    Code:
    if(SQL_FetchRow(hQuery))
    {
    SELECT COUNT('*'), i guess you wanted it to be SELECT COUNT(*)
    (both work, but I've never seen '*' )

    the -1 at the end of the query may give different results from the hlx page

    you might want to hook convar changes instead of calling GetConVarString inside OnMapStart. In this way the admin that changes a convar doesn't have to wait for a changelevel. the only exception is the sound, that needs to be precached, so it is fine to update it only at change level

    Last edited by jockersoft; 10-08-2010 at 12:49.
    jockersoft is offline
    snelvuur
    Veteran Member
    Join Date: Jun 2008
    Location: Netherlands
    Old 10-08-2010 , 12:58   Re: Top 10 Player HlstatsCE Announcer
    Reply With Quote #5

    Thanks for the tips, so basicly the mixing of space and tabs will create those loose indentations? (because frankly, i dont know where they come from)

    I was already looking at threaded sql for a example since it would make the server do a "hickup" on every join of a player if the database was down.

    You need the -1, otherwise new players (that dont exist in hlstats yet) would be counterd as the nr 1 player.

    The select count ('*') indeed doesn't make much sence, i was playing with it since i had some issues and since it didn't make any difference i forgot to change it back.

    I'll add the option to empty the sm_top10_sound.
    snelvuur is offline
    jockersoft
    Member
    Join Date: Aug 2008
    Old 10-08-2010 , 15:15   Re: Top 10 Player HlstatsCE Announcer
    Reply With Quote #6

    Quote:
    Originally Posted by snelvuur View Post
    Thanks for the tips, so basicly the mixing of space and tabs will create those loose indentations? (because frankly, i dont know where they come from)
    you are welcome
    yes, most of the times it is a problem of some lines beginning with spaces and others with tabs
    jockersoft is offline
    snelvuur
    Veteran Member
    Join Date: Jun 2008
    Location: Netherlands
    Old 10-08-2010 , 19:30   Re: Top 10 Player HlstatsCE Announcer
    Reply With Quote #7

    So i think i got the threaded part in there and fixed the loose identations, i've also did a check if the soundfile is set, if not then skip the precache (assuming it works like this? how would i tell if it work? since there is no real check?)

    Also, i've added what you set with the hookconvarchange, only i dont fully understand that. I've tried to just change for instance "sm_top10_game" but it didn't change it on the fly. Dont think its 100% correct. Can you verify?
    snelvuur is offline
    jockersoft
    Member
    Join Date: Aug 2008
    Old 10-09-2010 , 05:41   Re: Top 10 Player HlstatsCE Announcer
    Reply With Quote #8

    Quote:
    Originally Posted by snelvuur View Post
    i've also did a check if the soundfile is set, if not then skip the precache (assuming it works like this? how would i tell if it work? since there is no real check?)
    replace
    if (cvarSoundName) {
    with
    if (strlen(soundFileName) > 1) {

    Quote:
    Originally Posted by snelvuur View Post
    Also, i've added what you set with the hookconvarchange, only i dont fully understand that. I've tried to just change for instance "sm_top10_game" but it didn't change it on the fly. Dont think its 100% correct. Can you verify?
    with
    if (oldValue[0] == newValue[0]) {
    you are comparing the 1st char of the 2 strings. you should use StrEqual to compare the whole string.
    And sm_top10_sound should not be treated in the same way, since it will produce errors in the client and it will fail to play the sound even after the map change
    jockersoft is offline
    snelvuur
    Veteran Member
    Join Date: Jun 2008
    Location: Netherlands
    Old 10-09-2010 , 06:20   Re: Top 10 Player HlstatsCE Announcer
    Reply With Quote #9

    Ok, i'll give it another shot making progress at least.

    p.s. isn't "if (oldValue[0] == newValue[0])" comparing the first string of a array 0?
    *never mind* http://wiki.alliedmods.net/Introduction_to_SourcePawn

    I do some perl / php sometimes and sometimes all these thing confuse eachother.

    Last edited by snelvuur; 10-09-2010 at 06:38.
    snelvuur is offline
    snelvuur
    Veteran Member
    Join Date: Jun 2008
    Location: Netherlands
    Old 10-09-2010 , 07:33   Re: Top 10 Player HlstatsCE Announcer
    Reply With Quote #10

    I also noticed this:

    L 10/09/2010 - 11:13:12: [SM] Native "EmitSound" reported: Client 2 is not connected
    L 10/09/2010 - 11:13:12: [SM] Displaying call stack trace for plugin "top10hlxce-announce.smx":
    L 10/09/2010 - 11:13:12: [SM] [0] Line 370, /home/lz/am2/orangebox/tf/addons/sourcemod/scripting/include/sdktools_sound.inc::EmitSoundToClient()
    L 10/09/2010 - 11:13:12: [SM] [1] Line 120, top10hlxce-announce.sp::OnClientPostAdminCheck()

    But i do this:

    if( IsClientConnected(i) && ! IsFakeClient(i)) { blabla }

    Why would it still "fail"
    snelvuur 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 07:48.


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