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"

jockersoft 10-09-2010 13:14

Re: Top 10 Player HlstatsCE Announcer
 
difficult to say without looking at the updated source :)
but try with IsClientInGame instead of IsClientConnected

snelvuur 10-09-2010 14:34

Re: Top 10 Player HlstatsCE Announcer
 
I've set the "isclientingame" in it, and adjusted the strlen compare correct (was a issue) also still had 1 debug line still turned on, which is removed.

D_ONE 10-09-2010 22:34

Re: Top 10 Player HlstatsCE Announcer
 
Very nice script :). Works great here, I might be being dense but is there a way to completely disable the sound file (Its not in the style of our server) as when I edit it out it still try's to download an empty path on the server. Could I suggest a cvar to make it simpler. I'll be running it with minimal noise (just chatbox text announcement) when I can figure the sound thing out. :)

snelvuur 10-10-2010 07:34

Re: Top 10 Player HlstatsCE Announcer
 
Well i tried my self, but even if i do a strcmp matching "none" it will just fail one or the other, i need a correct example or something..

bouncer 10-10-2010 14:04

Re: Top 10 Player HlstatsCE Announcer
 
could this be made to work with gameME?

snelvuur 10-10-2010 14:11

Re: Top 10 Player HlstatsCE Announcer
 
If you know the sql query to get the rank, it basicly could.. assuming you have also database access.

jockersoft 10-10-2010 15:42

Re: Top 10 Player HlstatsCE Announcer
 
1 Attachment(s)
Quote:

Originally Posted by snelvuur (Post 1321038)
Well i tried my self, but even if i do a strcmp matching "none" it will just fail one or the other, i need a correct example or something..

try with this

snelvuur 10-10-2010 18:20

Re: Top 10 Player HlstatsCE Announcer
 
Same issue, tried that too. Still loads the mp3, even though i set it to "" for the sm_top10_sound.

honorcode23 10-10-2010 18:23

Re: Top 10 Player HlstatsCE Announcer
 
Quote:

Originally Posted by snelvuur (Post 1321581)
Same issue, tried that too. Still loads the mp3, even though i set it to "" for the sm_top10_sound.

Code:

if(!StrEqual(soundFileName, "none"))
{
          Precache();
}

What about that?

snelvuur 10-12-2010 17:56

Re: Top 10 Player HlstatsCE Announcer
 
I tried it with equal "" (as in i put sm_top10_sound "") but for some apparent reason it still downloads the mp3...

jockersoft 10-12-2010 18:30

Re: Top 10 Player HlstatsCE Announcer
 
put sm_top10_sound ""
changelevel
does it still download it?

(the downloads table doesn't get cleared until a map change)

snelvuur 10-12-2010 18:35

Re: Top 10 Player HlstatsCE Announcer
 
Well i did the change level...

[TS] Team Names: Red Blue - OnRoundEnd available: yes
Host_Error: CEngineSoundServer::PrecacheSound: Bad string:

Uploading dump (in-process) [proxy '']
/tmp/dumps/crash_20101013003559_1.dmp

Thats kind off bad :) never made it go mad this much..
Just tried it again, changelevel.. and poef crash..

jockersoft 10-13-2010 11:43

Re: Top 10 Player HlstatsCE Announcer
 
no idea about what's going on: just tried with the version i posted in #12, and no crashes or downloads are made after setting sm_top10_sound to "" and changing map.

snelvuur 10-13-2010 12:11

Re: Top 10 Player HlstatsCE Announcer
 
weird, i am running the dev tree maybe thats the difference, i'll try yours again and do some extra testing on that since this should be a rocket science "issue"

snelvuur 10-14-2010 14:24

Re: Top 10 Player HlstatsCE Announcer
 
If anyone can verify that post 17 indeed does not load a sound with the "sm_top10_sound" to "" (so nothing) that it does not download a file, since when i try it even though i verify it with console i still get the file send to my client.

I've placed the one from post 17 as the lead in the main page, assuming someone will stumble upon issues otherwise. For what it needs to do for me is fine now, and it seems for you too ;)

snelvuur 12-29-2010 15:54

Re: Top 10 Player HlstatsCE Announcer
 
Weirdly enough, now it just tries to download the sound everytime you connect prettymuch (Except for the inital first time) since the last big update.. i'll look into it, if i can find it ;)

janpepu 12-31-2010 02:14

Re: Top 10 Player HlstatsCE Announcer
 
thank for your plugin!

Can you activate sound and text only if the player connecting to the server for the first time and not at each begin of map.

What 's appens if there are 2 or more top10 players on the server at the beginig of the map ?

What 's appens if there are 2 or more top10 players connecting on the server at the time ? (Maybe you can add a timer to don't play the sound if a sound has already started)

What 's appens if player reconnecting to the server for flood with the sound ? (maybee play sound for the player one time per map ?)


good luck

snelvuur 12-31-2010 03:42

Re: Top 10 Player HlstatsCE Announcer
 
About the flooding, if it is a regular player... he wont be how do you say it "a noob" to misuse it. Also he doesn't here the sound and does not see the text since he is one of the top10 players.

if 2 players join at the same time it will only do the sond once as far as i have heard, the text will quickly follow up on eachother. But mostly they almost never join at the exact same time.

janpepu 12-31-2010 05:53

Re: Top 10 Player HlstatsCE Announcer
 
ok thx
and for the sound at changelevel ? (if a top10 player is on the server)

snelvuur 12-31-2010 06:56

Re: Top 10 Player HlstatsCE Announcer
 
after changelevel it would emit the sound again. per player, assuming they dont both join at the same time (it will only be once then at that moment) if that is what you mean

Datenkralle 03-04-2011 23:55

Re: Top 10 Player HlstatsCE Announcer
 
I think your screenhot are too old, no "tf2..." gametypes exists as games - only "tf" for Team Fortress 2. Or are there individual making server gametypes and why?
But how can i configure the plugin in the adminoptions in hlstatsx:ce?

snelvuur 03-05-2011 10:49

Re: Top 10 Player HlstatsCE Announcer
 
tf = tf2, and there is no such thing to configure in hlstatsx:ce just read the instructions and follow that. That should be sufficient.

Datenkralle 03-05-2011 11:34

Re: Top 10 Player HlstatsCE Announcer
 
Ok, i will test it on my server.
But i wonder, why he give a screenshot from hlstats. But i think that's nothing say. It's only confusing. :mrgreen:

Falco 03-05-2011 13:43

Re: Top 10 Player HlstatsCE Announcer
 
Following error in logs


Quote:

L 03/05/2011 - 11:39:08: [SM] Native "SQL_TQuery" reported: Invalid database Handle 0 (error: 4)
L 03/05/2011 - 11:39:08: [SM] Displaying call stack trace for plugin "top10hlxce-announce.smx":
L 03/05/2011 - 11:39:08: [SM] [0] Line 84, /home/groups/alliedmodders/forums/files/3/8/5/5/0/75683.attach::CheckTop10()
L 03/05/2011 - 11:39:08: [SM] [1] Line 101, /home/groups/alliedmodders/forums/files/3/8/5/5/0/75683.attach::OnClientPostAdminCheck()

Datenkralle 03-05-2011 21:12

Re: Top 10 Player HlstatsCE Announcer
 
Sound is downloading, but no sound announce, or text announce on server.
The plugin isn't work, thats pitty.

Groger 10-03-2011 10:23

Re: Top 10 Player HlstatsCE Announcer
 
Code:

L 10/04/2011 - 15:56:13: [SM] Native "SQL_TQuery" reported: Invalid database Handle 0 (error: 4)
L 10/04/2011 - 15:56:13: [SM] Displaying call stack trace for plugin "top10.smx":
L 10/04/2011 - 15:56:13: [SM]  [0]  Line 84, top10.sp::CheckTop10()
L 10/04/2011 - 15:56:13: [SM]  [1]  Line 101, top10.sp::OnClientPostAdminCheck()

Just like the guy above me, doesnt work. I would love to see this working!

snelvuur 10-03-2011 10:45

Re: Top 10 Player HlstatsCE Announcer
 
Still works fine here, you created the top10 database in the databases.cfg and changed the sm_top10_game to point to the name of your install (as shown in the screenshot, which is a example) ?

Groger 10-03-2011 14:51

Re: Top 10 Player HlstatsCE Announcer
 
Ah, I see the problem now. I entered css1 because it said so on your screenshot. But it was "css" on our hlstatsx.

I'm sorry for my stupidity. Thx!

sinblaster 10-05-2011 02:59

Re: Top 10 Player HlstatsCE Announcer
 
I am also getting this error and Ive dbl checked my settings

Code:

L 10/05/2011 - 17:49:02: [SM] Native "SQL_TQuery" reported: Invalid database Handle 0 (error: 4) L 10/05/2011 - 17:49:02: [SM] Displaying call stack trace for plugin "top10hlxce-announce.smx":
  L 10/05/2011 - 17:49:02: [SM]  [0]  Line 84, /home/groups/alliedmodders/forums/files/3/8/5/5/0/75683.attach::CheckTop10()
  L 10/05/2011 - 17:49:02: [SM]  [1]  Line 101, /home/groups/alliedmodders/forums/files/3/8/5/5/0/75683.attach::OnClientPostAdminCheck()

CSS Windows Server mmsource-1.8.7 | sourcemod-1.3.8 SDK Hooks 2

12 months this has been waiting?

snelvuur 10-05-2011 04:21

Re: Top 10 Player HlstatsCE Announcer
 
The most common mistake i see normally is that the top10 database is not created and that the name of the "game" from hlstats is not correctly setup in the server.cfg. As you can see it is working for others (not only me)

As a reminder, the screenshot on the first page is a example. Since we have many games the gametype can be different too. Make sure that is correct.


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

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