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

Help With Timer


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DontWannaName
Veteran Member
Join Date: Jun 2007
Location: VALVe Land, WA
Old 01-15-2009 , 01:23   Help With Timer
Reply With Quote #1

Im trying to add a timer in this plugin to spam this chat message to people during the waiting for players round. My method isnt quite working but was wondering if anyone can take a look, I only copy and pasted a lot.

http://pastebin.com/m26a277b6
__________________

DontWannaName is offline
RM_Hamster
SourceMod Donor
Join Date: Jul 2008
Location: MA
Old 01-15-2009 , 11:10   Re: Help With Timer
Reply With Quote #2

So here's what I changed around:

I removed the two includes at the top that didn't need to be there. There's not really much problem leaving them in, but I prefer to not have them if I'm not using them.

Also, I moved the fake client check into the other line of checks simply to group them together.

Lastly, and the part that really matters, is that you were trying to grab the client's ID from teamplay_round_start. What you need to do is simply call the timer for Action:Display_Ad from there and loop through all the clients (i = 1; i < MaxClients). This will display the ad to everyone in the game. (http://wiki.alliedmods.net/Team_Fortress_2_Events)

One more thing: from the TF2 events in the wiki, it looks as though you could use teamplay_waiting_begins/ends instead of using Roundstarts to keep track of it. Just a small thing really, but it might help to keep the code coherent.

http://pastebin.com/d9c55f1f

Last edited by RM_Hamster; 01-15-2009 at 11:12.
RM_Hamster is offline
DontWannaName
Veteran Member
Join Date: Jun 2007
Location: VALVe Land, WA
Old 01-15-2009 , 12:12   Re: Help With Timer
Reply With Quote #3

Ok thanks. I was going to use the events but they didnt work with the code, i think he made it to end it himself with a check.
__________________

DontWannaName is offline
DontWannaName
Veteran Member
Join Date: Jun 2007
Location: VALVe Land, WA
Old 01-15-2009 , 20:13   Re: Help With Timer
Reply With Quote #4

That didnt work. This is what I have now and it still doesnt work.

http://pastebin.com/m1892dc2b
__________________

DontWannaName is offline
RM_Hamster
SourceMod Donor
Join Date: Jul 2008
Location: MA
Old 01-15-2009 , 20:25   Re: Help With Timer
Reply With Quote #5

http://pastebin.com/dd3b6b27

The line for getting a client's ID from teamplay_round_start was still there; you can't get a client from that event. PrintToChat, then, cannot print to client. It needs to print to i, the variable for each potential player. That's why it's not working. Also, if you're using 1.1, you can use MaxClients instead of GetMaxClients() - personal preference.

Also, you didn't need those two additional fake client checks, as those are still there in the lines above.

Hope it helps
RM_Hamster is offline
DontWannaName
Veteran Member
Join Date: Jun 2007
Location: VALVe Land, WA
Old 01-15-2009 , 20:27   Re: Help With Timer
Reply With Quote #6

Ok, I will test it now. I would use the 1.1 maxclients but im too lazy to compile anywhere but online.
__________________

DontWannaName is offline
DontWannaName
Veteran Member
Join Date: Jun 2007
Location: VALVe Land, WA
Old 01-15-2009 , 20:30   Re: Help With Timer
Reply With Quote #7

It only does the chat ad once, it doesnt spam it at all. Plus it changes my sv_tags
__________________

DontWannaName is offline
RM_Hamster
SourceMod Donor
Join Date: Jul 2008
Location: MA
Old 01-15-2009 , 20:34   Re: Help With Timer
Reply With Quote #8

If you want it to spam, you should use a repeatable timer (http://wiki.alliedmods.net/Timers_(S...eatable_Timers).

As for sv_tags, I don't know how to suppress that off the top of my head.
RM_Hamster is offline
DontWannaName
Veteran Member
Join Date: Jun 2007
Location: VALVe Land, WA
Old 01-15-2009 , 21:08   Re: Help With Timer
Reply With Quote #9

I dont know how to implement that. This is what I could do.

http://pastebin.com/d536c1436
__________________

DontWannaName is offline
RM_Hamster
SourceMod Donor
Join Date: Jul 2008
Location: MA
Old 01-15-2009 , 22:24   Re: Help With Timer
Reply With Quote #10

http://pastebin.com/d7c285b39

The extra code I took out wasn't needed in this case. It's only if you wanted to print multiple times at once; what's left is all you need to print it over and over. It will print once every minute until Roundstarts == 1. You could probably use Plugin_Stop instead of Plugin_Handled at the end there, but I usually prefer Plugin_Handled instead (doesn't really make a difference I think).

Also, I think that the timer handle closes itself after Plugin_Handled is returned, but I don't recall for sure... it might need to be explicitly closed with a CloseHandle().
RM_Hamster 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 01:49.


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