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!
__________________