Raised This Month: $ Target: $400
 0% 

Tutorial: Count rounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Pro Patria Finland
Senior Member
Join Date: Apr 2006
Location: BaronPub.com
Old 06-20-2007 , 17:06   Tutorial: Count rounds
Reply With Quote #1

Where should I begin?

I am using this in my FreemanMod, and I thought it would be useful to post this. Advanced coders propably would figure this out themselves, but I couldn't. I found this code from miscstats.sma by the AMXX Dev Team (originally written by OLO), but here it is simplified. Not that hard, but I wanna write a tutorial

So, here's an example where we print the current round number into clients console.
Code:
#include <amxmodx> #include <amxmisc> new g_roundcount //Our "roundcounter" public plugin_init() {     register_plugin("Round Counter", "1.0", "Pro Patria Finlandia")     register_event("HLTV", "roundStart", "a", "1=0", "2=0")  //This catches the new round start (thanks to VEN's tutorial)     register_event("SendAudio", "endRound", "a", "2&%!MRAD_terwin", "2&%!MRAD_ctwin", "2&%!MRAD_rounddraw") //This catches the round end     register_event("TextMsg", "restartRound", "a", "2&#Game_C", "2&#Game_w") //And this one catches a round restart ("Game Commencing" for example)         return PLUGIN_CONTINUE } public roundStart() { //This is roundstart, and this is where we print our round number to the console     client_print (0, print_console, "Hey, I am the round counter. This is round number %i. :)", g_roundcount) } public endRound() { //This is round end, where we simply add "1" to the value of "g_roundcount"     ++g_roundcount } public restartRound() { //When the round restarts, we'll make the value of "g_roundcount" 0, so the counting starts again. This is optional.     g_roundcount = 0 }

Simple, yet useful!
NOTE: This does NOT count the very first round when the server starts or the map is changed. I don't mind about it, but if you do, add "1" to g_roundcount when Freezetime ends (see Ven's tutorial). You can use this method to count almost everything that can be counted in the game (knifekills, headshots, etc.) Have fun with it!
__________________
I am not a number. I am Gordon Freeman!
Pro Patria Finland is offline
kmal2t
BANNED
Join Date: Apr 2006
Old 06-22-2007 , 03:28   Re: Tutorial: Count rounds
Reply With Quote #2

IN what way is this a tutorial and complicated that someone couldn't easily figure this out themself? You catch the round end and you add another one to a variable and reset it if you sv_restart. Assuming this actually was worth posting, you could have put it in the already existing round stuff tutorial..
kmal2t is offline
Pro Patria Finland
Senior Member
Join Date: Apr 2006
Location: BaronPub.com
Old 06-22-2007 , 03:58   Re: Tutorial: Count rounds
Reply With Quote #3

These tutorials here are mostly for scripting noobs, much like myself. It has been asked various times, and I thought I'd add it here (sorry if you don't approve, umh, not).

Yep, I could've posted this into VEN's thread, you are correct, but too late for that.
__________________
I am not a number. I am Gordon Freeman!
Pro Patria Finland is offline
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 06-22-2007 , 22:02   Re: Tutorial: Count rounds
Reply With Quote #4

Correct me if I'm wrong, but wouldn't this (in roundStart) eliminate the need to hook roundEnd and fix the bug where the first round is not counted?

Code:
client_print (0, print_chat, "Round number: %i.", ++g_roundcount)
Lee is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 06-23-2007 , 11:36   Re: Tutorial: Count rounds
Reply With Quote #5

Yep.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Tobiski
New Member
Join Date: Sep 2007
Location: Kalajoki, Finland
Old 09-05-2007 , 17:22   Re: Tutorial: Count rounds
Reply With Quote #6

n1 tut, made few things lighter to me (as a noob scripter;)
__________________
Tobiski is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 09-05-2007 , 19:27   Re: Tutorial: Count rounds
Reply With Quote #7

Oh yeah, I wanted to trash this, but didn't know I could. Thanks for reminding me, Tobiski.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
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 09:26.


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