AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   Top 10 Player HlstatsCE Announcer (https://forums.alliedmods.net/showthread.php?t=139703)

snelvuur 10-04-2010 09:38

Top 10 Player HlstatsCE Announcer
 
1 Attachment(s)
[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

marvel 10-04-2010 16:14

Re: Top 10 Player HlstatsCE Announcer
 
Awesome! Please tell me it works on L4D(2)! :)

snelvuur 10-04-2010 19:28

Re: Top 10 Player HlstatsCE Announcer
 
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.

jockersoft 10-08-2010 12:47

Re: Top 10 Player HlstatsCE Announcer
 
I think my arena players will like it, they keep typing top10, rank... :wink:

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

snelvuur 10-08-2010 12:58

Re: Top 10 Player HlstatsCE Announcer
 
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.

jockersoft 10-08-2010 15:15

Re: Top 10 Player HlstatsCE Announcer
 
Quote:

Originally Posted by snelvuur (Post 1319140)
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

snelvuur 10-08-2010 19:30

Re: Top 10 Player HlstatsCE Announcer
 
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?

jockersoft 10-09-2010 05:41

Re: Top 10 Player HlstatsCE Announcer
 
Quote:

Originally Posted by snelvuur (Post 1319500)
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 (Post 1319500)
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

snelvuur 10-09-2010 06:20

Re: Top 10 Player HlstatsCE Announcer
 
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.

snelvuur 10-09-2010 07:33

Re: Top 10 Player HlstatsCE Announcer
 
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"


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

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