/** Copyright © 2016 Vaqtincha * * CSDM include file. * */ #if defined _csdm_core_included #endinput #endif #define _csdm_core_included #if AMXX_VERSION_NUM >= 175 #pragma reqlib csdm_core #if !defined AMXMODX_NOAUTOLOAD #pragma loadlib csdm_core #endif #else #pragma library csdm_core #endif #if !defined _reapi_included #include #endif const CSDM_VERSION_NUM = 008 stock const CSDM_VERSION_STRING[] = "0.0.8" stock const CSDM_PLUGIN_NAME[] = "CSDM Core" stock const g_szMainDir[] = "csdm" stock const g_szExtraCfgDir[] = "extraconfigs" stock const g_szSpawnDir[] = "spawns" stock const g_szDefaultCfgFile[] = "config.ini" stock const g_szMainSection[] = "[settings]" // config const MAX_CONFIG_PATH_LEN = 128 // configdata const MAX_LINE_LEN = 64 const MAX_KEY_LEN = 32 const MAX_VALUE_LEN = 32 const MAX_SECTION_LEN = 32 enum ReadTypes { CFG_READ, CFG_RELOAD } enum GameTypes { NORMAL_HIT, HEADSHOTS_ONLY, ALWAYS_HIT_HEAD, AUTO_HEALER } enum EquipTypes { EQUIP_NONE = -1, AUTO_EQUIP, EQUIP_MENU, RANDOM_WEAPONS, FREE_BUY } enum ColorTypes { DONT_CHANGE = 0, RED, BLUE, GREY } //■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ FORWARDS ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ /** Called when CSDM initializes. * * @param szVersion It passes in a version string, or a blank string if some load failure occurred. */ forward CSDM_Initialized(const szVersion[]) /** Called when CSDM is ready to accept config hooks. * * @param iReadAction See enum ReadTypes */ forward CSDM_ConfigurationLoad(const ReadTypes:iReadAction) /** Called when CSDM is execute CVar values. */ forward CSDM_ExecuteCVarValues() /** Called right before gamemode change. * * @param iCurrentMode Current gameplay mode * @param iNewMode Changed to * * @note return PLUGIN_HANDLED will block change */ forward CSDM_GamemodeChanged(const GameTypes:iCurrentMode, const GameTypes:iNewMode) /** Called right before round is restarted. * * @param bNewGame Is round restart */ forward CSDM_RestartRound(const bool:bNewGame) /** Player spawned. * * @param pPlayer Player id * @param bIsBot Is player bot ? * @param iNumSpawns Total spawns * * @note alive check not necessary */ forward CSDM_PlayerSpawned(const pPlayer, const bool:bIsBot, const iNumSpawns) /** Player killed. * * @param pVictim Victim id * @param pKiller Killer id * @param iLastHitGroup Last hitgroup * * @note pKiller == 0 if player was killed by world */ forward CSDM_PlayerKilled(const pVictim, const pKiller, const HitBoxGroup:iLastHitGroup) //■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ NATIVES ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ /** Read config section. * * forward params: public my_config_handler(const szLineData[], const iSectionID) * * @param szSectionName Section name defined in config. * @param szHandler Name of the handler function. * @param iSectionID section Index. (for multiple handler support) * * @return Index of section item. */ native CSDM_RegisterConfig(const szSectionName[], const szHandler[]) /** Gets config keyvalue. * * @param szKey Keyname * @param szValue The variable to store the value in. * @param iLen Lenght * * @return true/false */ native bool:CSDM_GetConfigKeyValue(const szKey[], szValue[], iLen) /** Gets gameplay mode. * * @return enum GameTypes */ native GameTypes:CSDM_GetGamemode() /** Sets gameplay mode. * * @param iNewMode See enum GameTypes * * @return Failed/Success */ native bool:CSDM_SetGamemode(const GameTypes:iNewMode) /** Gets equip mode. * * @return enum EquipTypes */ native CSDM_GetEquipmode() /** Sets equip mode. * * @param iNewMode enum EquipTypes * * @noreturn */ native CSDM_SetEquipmode(const EquipTypes:iNewMode) //■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ HELPER STUFF ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ // cfg #define ContainFlag(%1,%2) (containi(%1, %2) != -1) #define ParseConfigKey(%1,%2,%3,%4) (parse(%1, %2, charsmax(%2), %3, charsmax(%3), %4, charsmax(%4)) == 3 && %3[0] == '=') #define IsCommentLine(%1) (%1[0] == ';' || %1[0] == '#' || (%1[0] == '/' && %1[1] == '/')) #define IsValidTeam(%1) (TEAM_TERRORIST <= get_member(%1, m_iTeam) <= TEAM_CT) #define IsValidWeaponID(%1) (any:WEAPON_P228 <= %1 <= any:WEAPON_P90 && !(INVALID_WEAPONS_BS & (1<