======================================================================================================= Tutorial on making AM Plugins to use with StatsMe ------------------------------------------------------------------------------------------------------- StatsMe forums: http://forums.unitedadmins.com/forumdisplay.php?s=&forumid=36 ======================================================================================================= ======================================================================================================= I. Engine messages ------------------------------------------------------------------------------------------------------- All messages sent to the player are sent to AM plugins with the entire contents of the engine message. I.E. DeathMsg has a format of "receiver" "index_of_killer" "index_of_victim" "headshots" "weapon_name" With statsme it's possible to catch all of the data sent to a player from the server. ------------------------------------------------------------------------------------------------------- II. How to register new engine event ------------------------------------------------------------------------------------------------------- Put at the end of pluging_init(): exec("sm_register ^"NAMEOFEVENT FLAGFORMODE^" ^"admin_command NAMEOFFUNCTION^" FLAGS ^"CONDITIONS^""); ------------------------------------------------------------------------------------------------------- III. Name of events ------------------------------------------------------------------------------------------------------- Builded in StatsMe SM_DeathMsg - "receiver" "index_of_killer" "index_of_victim" "headshot" "wpn_name" "team_killing" SM_RoundEnd - "receiver" SM_RoundStart - "receiver" SM_MonsterKill - "receiver" "kills" "headshots" SM_C4Timer - "receiver" "sec_left_to_the_explosion" SM_Damage - "receiver" "index_of_attacker" "damage" "aiming_at" "weapon" "team_attacking" SM_Connect - "receiver" "name" "ip" SM_PutInServer - "receiver" SM_Disconnect - "receiver" SM_InfoChanged - "receiver" Format for all events are available in the HLSDK, here are some examples: CurWeapon - "receiver" "is_wpn_active" "id_of_weapon" "ammo_in_clip" Damage - "receiver" "dmg_save?" "dmg_take" "dmg_type_bits" "coordx" "coordy" "coordz" DeathMsg - "receiver" "index_of_killer" "index_of_victim" "headshot" "wpn_name" TextMsg - "receiver" "msg_type" "text" "parameters_for_text" ResetHUD - "receiver" SendAudio - "receiver" "sound_mode" "sound" Health - "receiver" "amount_of_health" Battery - "receiver" "amount_of_armor" StatusIcon - "receiver" "state" "icon" TeamInfo - "receiver" "index_of_player" "name_of_team" TeamScore - "receiver" "name_of_team" "score" WeapPickup - "receiver" "id_of_wpn" IteamPickup - "receiver" "classname_of_iteam" SetFOV - "receiver" "value_of_fov" HudText - "receiver" "string" SayText - "receiver" "index_of_sender" "text" 30 - "receiver" - unofficial msg. which sends intermission event (timelimit reached) ------------------------------------------------------------------------------------------------------- IV. Flags ------------------------------------------------------------------------------------------------------- a - receive msg only if it is sent globally (to all players, then receiver is 0) b - receive msg only if it is dedicated to specified player (receiver is then index_of_player) c - receive only once (some messages are sent multiple times - i.e. radio sound is sent separately to each player, because some of them can hear sounds and others cannot) d - don't use quotes in the message body, this is useful for easier and faster message parsing (before you use it make sure that the msg. doesn't contain spaces in the body) e - fill command with vars and execute it without attaching the message body ------------------------------------------------------------------------------------------------------- V. Conditions ------------------------------------------------------------------------------------------------------- For example TextMsg message always has the same format "receiver" "msg_type" "msg_text" "parameters_for_text" You can already filter TextMsg in StatsMe which will greatly reduce CPU usage and make scripting more comfortable. Now let's filter TextMsg to send data if a new player connects to the server. For that go to cstrike/titles.txt and search for the body of messages displayed when new player connects: Game_connected { %s connected } Now pick a title and build a condition like this: "2=#Game_connected" Here '#' means that this text is from titles.txt. Also, '2=' means that it will call for this event only if the second parameter (msg_text) contains: "Game_connected". As a parameter, there will be the name of the player who connected. Conditions with the same indexes of value (i.e. "4=greande" "4=m4a1" for DeathMsg) become as OR cases. With diffrent indexes of value become as AND cases. For example: "3=1" "4=m4a1" for DeathMsg means - call if there is a headshot made by an m4a1. For better CPU performance you don't have to put the whole phrase in the condition. For example: "2=#Game_c" means on 100% that this is a message about a player connecting, because this is the only string from titles.txt which has such a unique beginning (there is also Game Commencing message but it begins with "#Game_C" and comparing is case sensitive) ------------------------------------------------------------------------------------------------------- VI. Debugging ------------------------------------------------------------------------------------------------------- It's a good idea to use temporary function to see the contents of the engine messages. For example: sm_register "Battery" "say " "ae" sm_register "DeathMsg" "say " "de" During the game, data will be printed to the say status and you will be able to track what is going on and what kind of values the engine sends. ------------------------------------------------------------------------------------------------------- VII. The rest of the names for engine messages ------------------------------------------------------------------------------------------------------- TE temp entity VoiceMask ReqState SelAmmo CurWeapon Geiger Flashlight FlashBat Health Damage Battery Train HudText SayText TextMsg WeaponList ResetHUD InitHUD ViewMode GameTitle DeathMsg ScoreAttrib ScoreInfo TeamInfo TeamScore GameMode MOTD ServerName AmmoPickup WeapPickup ItemPickup HideWeapon SetFOV ShowMenu ScreenShake ScreenFade AmmoX SendAudio RoundTime Money ArmorType BlinkAcct StatusValue StatusText StatusIcon BarTime ReloadSound Crosshair NVGToggle Radar Spectator VGUIMenu WClose WClose2 AllowSpec =======================================================================================================