diff --git a/addons/amxmodx/scripting/include/rt_api.inc b/addons/amxmodx/scripting/include/rt_api.inc index 57e58e4..ad3191b 100644 --- a/addons/amxmodx/scripting/include/rt_api.inc +++ b/addons/amxmodx/scripting/include/rt_api.inc @@ -9,8 +9,13 @@ #endif #define _rt_api_included -public stock const VERSION[] = "2.3.17"; -public stock const AUTHORS[] = "DEV-CS.RU Community"; +#define PLUGIN_VERSION "2.4.0" +#define PLUGIN_AUTHORS "HLDS.RUN Community" + +/** + * The name of the general dictionary file + */ +#define PLUGIN_DICTIONARY "rt_library.txt" /** * Invalid entity index @@ -56,171 +61,171 @@ new const DEAD_BODY_CLASSNAME[] = "rt_corpse_empty"; /** * [PRE] Called after the activator starts resurrection/planting (on press USE - `E`) * - * @param iEnt Corpse entity index - * @param iPlayer Player id who can be ressurected - * @param iActivator Player id who ressurect - * @param eMode MODE_REVIVE - started the resurrection, MODE_PLANT - started planting + * @param entId Corpse entity index + * @param playerId Player id who can be ressurected + * @param activatorId Player id who ressurect + * @param mode MODE_REVIVE - started the resurrection, MODE_PLANT - started planting * * @return PLUGIN_CONTINUE to start resurrection/planting * PLUGIN_HANDLED to stop resurrection/planting */ -forward rt_revive_start(const iEnt, const iPlayer, const iActivator, const Modes:eMode); +forward rt_revive_start(const entId, const playerId, const activatorId, const Modes:mode); /** * [POST] Called after the activator starts resurrection/planting (on press USE - `E`) * - * @note This forward will not be called if something was blocked attempt in rt_revive_start() + * @note This forward will not be called if something was blocked attempt in rt_revive_start() * - * @param iEnt Corpse entity index - * @param iPlayer Player id who can be ressurected - * @param iActivator Player id who ressurect - * @param eMode MODE_REVIVE - started the resurrection, MODE_PLANT - started planting + * @param entId Corpse entity index + * @param playerId Player id who can be ressurected + * @param activatorId Player id who ressurect + * @param mode MODE_REVIVE - started the resurrection, MODE_PLANT - started planting * * @noreturn */ -forward rt_revive_start_post(const iEnt, const iPlayer, const iActivator, const Modes:eMode); +forward rt_revive_start_post(const entId, const playerId, const activatorId, const Modes:mode); /** * PreThink on resurrection/planting * - * @note Timer can be 0.0 + * @note Timer can be 0.0 * - * @param iEnt Corpse entity index - * @param iPlayer Player id who can be ressurected - * @param iActivator Player id who ressurect - * @param fTimer Resurrection time - * @param eMode MODE_REVIVE - the player continues to be resurrected, MODE_PLANT - the player continues to be planted + * @param entId Corpse entity index + * @param playerId Player id who can be ressurected + * @param activatorId Player id who ressurect + * @param timer Resurrection time + * @param mode MODE_REVIVE - the player continues to be resurrected, MODE_PLANT - the player continues to be planted * * @return PLUGIN_CONTINUE to continue resurrection/planting * PLUGIN_HANDLED to stop resurrection/planting */ -forward rt_revive_loop_pre(const iEnt, const iPlayer, const iActivator, const Float:fTimer, Modes:eMode); +forward rt_revive_loop_pre(const entId, const playerId, const activatorId, const Float:timer, Modes:mode); /** * PostThink on resurrection/planting * - * @note Timer can't be 0.0 + * @note Timer can't be 0.0 * - * @param iEnt Corpse entity index - * @param iPlayer Player id who can be ressurected - * @param iActivator Player id who ressurect - * @param fTimer Resurrection time - * @param eMode MODE_REVIVE - the player continues to be resurrected, MODE_PLANT - the player continues to be planted + * @param entId Corpse entity index + * @param playerId Player id who can be ressurected + * @param activatorId Player id who ressurect + * @param timer Resurrection time + * @param mode MODE_REVIVE - the player continues to be resurrected, MODE_PLANT - the player continues to be planted * * @noreturn */ -forward rt_revive_loop_post(const iEnt, const iPlayer, const iActivator, const Float:fTimer, Modes:eMode); +forward rt_revive_loop_post(const entId, const playerId, const activatorId, const Float:timer, Modes:mode); /** * Called after the resurrection/planting is ending * - * @param iEnt Corpse entity index - * @param iPlayer Player id who can be ressurected - * @param iActivator Player id who ressurect - * @param eMode MODE_REVIVE - the player was resurrected, MODE_PLANT - the player was planted + * @param entId Corpse entity index + * @param playerId Player id who can be ressurected + * @param activatorId Player id who ressurect + * @param mode MODE_REVIVE - the player was resurrected, MODE_PLANT - the player was planted * * @noreturn */ -forward rt_revive_end(const iEnt, const iPlayer, const iActivator, const Modes:eMode); +forward rt_revive_end(const entId, const playerId, const activatorId, const Modes:mode); /** * Called when the player has stopped resurrecting/planting * - * @param iEnt Corpse entity index - * @param iPlayer Player id who can be ressurected or RT_NULLENT - * @param iActivator Player id who ressurect or RT_NULLENT - * @param eMode MODE_REVIVE - stopped the resurrection, MODE_PLANT - stopped planting + * @param entId Corpse entity index + * @param playerId Player id who can be ressurected or RT_NULLENT + * @param activatorId Player id who ressurect or RT_NULLENT + * @param mode MODE_REVIVE - stopped the resurrection, MODE_PLANT - stopped planting * * @noreturn */ -forward rt_revive_cancelled(const iEnt, const iPlayer, const iActivator, const Modes:eMode); +forward rt_revive_cancelled(const entId, const playerId, const activatorId, const Modes:mode); /** * Called before a corpse is created * - * @param iEnt Corpse entity index - * @param iPlayer Player id whose corpse + * @param entId Corpse entity index + * @param playerId Player id whose corpse * * @return PLUGIN_CONTINUE to continue the created of a corpse * PLUGIN_HANDLED to stop the created of a corpse */ -forward rt_creating_corpse_start(const iEnt, const iPlayer); +forward rt_creating_corpse_start(const entId, const playerId); /** * Called after the creation of the corpse is completed * - * @param iEnt Corpse entity index - * @param iPlayer Player id whose corpse - * @param fVecOrigin Coordinates of the corpse + * @param entId Corpse entity index + * @param playerId Player id whose corpse + * @param vecOrigin Coordinates of the corpse * * @noreturn */ -forward rt_creating_corpse_end(const iEnt, const iPlayer, const Float:fVecOrigin[3]); +forward rt_creating_corpse_end(const entId, const playerId, const Float:vecOrigin[3]); /** * Returns current user mode * - * @note In rt_revive_cancelled() and rt_revive_end() always return MODE_NONE + * @note In rt_revive_cancelled() and rt_revive_end() always return MODE_NONE * - * @param iPlayer Client index + * @param playerId Client index * * @return see 'Modes' enum */ -native Modes:rt_get_user_mode(iPlayer); +native Modes:rt_get_user_mode(playerId); /** * Will interrupt the current process * - * @param iPlayer Client index + * @param playerId Client index * * @return true if success, false otherwise */ -native bool:rt_reset_use(iPlayer); +native bool:rt_reset_use(playerId); /** * Removal of corpses * - * @param iPlayer Player id whose corpse or 0 for all corpses - * @param szClassName Entity classname + * @param playerId Player id whose corpse or 0 for all corpses + * @param className Entity classname * * @return Player id who is resurrecting or 0 */ -stock RemoveCorpses(const iPlayer = 0, const szClassName[] = DEAD_BODY_CLASSNAME) { - new iEnt = RT_NULLENT; - new iActivator, iOwner; +stock RemoveCorpses(const playerId = 0, const className[] = DEAD_BODY_CLASSNAME) { + new entId = RT_NULLENT; + new activatorId, ownerId; - while((iEnt = rg_find_ent_by_class(iEnt, szClassName)) > 0) { - if(!is_nullent(iEnt)) { - if(iPlayer && (iOwner = get_entvar(iEnt, var_owner)) != iPlayer) + while((entId = rg_find_ent_by_class(entId, className)) > 0) { + if(!is_nullent(entId)) { + if(playerId && (ownerId = get_entvar(entId, var_owner)) != playerId) continue; - if(iPlayer && iOwner == iPlayer) - iActivator = get_entvar(iEnt, var_iuser1); + if(playerId && ownerId == playerId) + activatorId = get_entvar(entId, var_iuser1); - set_entvar(iEnt, var_flags, FL_KILLME); - set_entvar(iEnt, var_nextthink, 0.0); - set_entvar(iEnt, var_iuser1, 0); + set_entvar(entId, var_flags, FL_KILLME); + set_entvar(entId, var_nextthink, 0.0); + set_entvar(entId, var_iuser1, 0); - if(iActivator) + if(activatorId) break; } } - return iActivator; + return activatorId; } /** * Notifying players in chat * - * @param iPlayer Player id or 0 to display to all clients - * @param iSender Player id used as the message sender or color type - * @param szFmtRules Formatting rules + * @param playerId Player id or 0 to display to all clients + * @param senderId Player id used as the message sender or color type + * @param fmtRules Formatting rules * * @noreturn */ -stock NotifyClient(const iPlayer, const iSender, any:...) { +stock NotifyClient(const playerId, const senderId, any:...) { new szMessage[MAX_MESSAGE_LENGTH]; - SetGlobalTransTarget(iPlayer); + SetGlobalTransTarget(playerId); vformat(szMessage, charsmax(szMessage), "%l", 3); - client_print_color(iPlayer, iSender, "%l %s", "RT_CHAT_TAG", szMessage); -} + client_print_color(playerId, senderId, "%l %s", "RT_CHAT_TAG", szMessage); +} \ No newline at end of file diff --git a/addons/amxmodx/scripting/rt_bonus.sma b/addons/amxmodx/scripting/rt_bonus.sma index 46cd4bc..e7c0906 100644 --- a/addons/amxmodx/scripting/rt_bonus.sma +++ b/addons/amxmodx/scripting/rt_bonus.sma @@ -3,8 +3,9 @@ #include #include -public stock const PLUGIN[] = "Revive Teammates: Bonus"; -public stock const CFG_FILE[] = "addons/amxmodx/configs/rt_configs/rt_bonus.cfg"; +#define PLUGIN_NAME "Revive Teammates: Bonus" + +#define CFG_FILE "addons/amxmodx/configs/rt_configs/rt_bonus.cfg" #define MAX_SPAWN_WEAPONS 6 @@ -20,10 +21,10 @@ enum CVARS { NO_DEATHPOINT }; -new g_eCvars[CVARS]; +new Cvars[CVARS]; -new g_iWeapons; -new g_szWeapon[MAX_SPAWN_WEAPONS][32]; +new Weapon[MAX_SPAWN_WEAPONS][32]; +new WeaponsNum; public plugin_precache() { CreateCvars(); @@ -33,82 +34,82 @@ public plugin_precache() { } public plugin_init() { - register_plugin(PLUGIN, VERSION, AUTHORS); + register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHORS); - register_dictionary("rt_library.txt"); + register_dictionary(PLUGIN_DICTIONARY); } public plugin_cfg() { - new szMapName[MAX_MAPNAME_LENGTH], szWeapon[32]; - get_mapname(szMapName, charsmax(szMapName)); + new mapName[MAX_MAPNAME_LENGTH], weaponName[32]; + get_mapname(mapName, charsmax(mapName)); - if(g_eCvars[WEAPONS_MAPS][0] != EOS && containi(szMapName, "awp_") != -1) { - while(argbreak(g_eCvars[WEAPONS_MAPS], szWeapon, charsmax(szWeapon), g_eCvars[WEAPONS_MAPS], charsmax(g_eCvars[WEAPONS_MAPS])) != -1) { - if(g_iWeapons == MAX_SPAWN_WEAPONS) + if(Cvars[WEAPONS_MAPS][0] != EOS && containi(mapName, "awp_") != -1) { + while(argbreak(Cvars[WEAPONS_MAPS], weaponName, charsmax(weaponName), Cvars[WEAPONS_MAPS], charsmax(Cvars[WEAPONS_MAPS])) != -1) { + if(WeaponsNum == MAX_SPAWN_WEAPONS) break; - copy(g_szWeapon[g_iWeapons++], charsmax(g_szWeapon[]), szWeapon); + copy(Weapon[WeaponsNum++], charsmax(Weapon[]), weaponName); } return; } - if(g_eCvars[WEAPONS][0] != EOS) { - while(argbreak(g_eCvars[WEAPONS], szWeapon, charsmax(szWeapon), g_eCvars[WEAPONS], charsmax(g_eCvars[WEAPONS])) != -1) { - if(g_iWeapons == MAX_SPAWN_WEAPONS) + if(Cvars[WEAPONS][0] != EOS) { + while(argbreak(Cvars[WEAPONS], weaponName, charsmax(weaponName), Cvars[WEAPONS], charsmax(Cvars[WEAPONS])) != -1) { + if(WeaponsNum == MAX_SPAWN_WEAPONS) break; - copy(g_szWeapon[g_iWeapons++], charsmax(g_szWeapon[]), szWeapon); + copy(Weapon[WeaponsNum++], charsmax(Weapon[]), weaponName); } } } -public rt_revive_end(const iEnt, const iPlayer, const iActivator, const Modes:eMode) { - switch(eMode) { +public rt_revive_end(const entId, const playerId, const activatorId, const Modes:mode) { + switch(mode) { case MODE_REVIVE: { - new Modes:iMode = Modes:get_entvar(iEnt, var_iuser3); + new Modes:entMode = Modes:get_entvar(entId, var_iuser3); - if(iMode != MODE_PLANT) { - if(g_eCvars[REVIVE_HEALTH]) - rg_add_health_to_player(iActivator, g_eCvars[REVIVE_HEALTH]); + if(entMode != MODE_PLANT) { + if(Cvars[REVIVE_HEALTH]) + rg_add_health_to_player(activatorId, Cvars[REVIVE_HEALTH]); - if(g_eCvars[HEALTH]) - set_entvar(iPlayer, var_health, floatclamp(g_eCvars[HEALTH], 1.0, Float:get_entvar(iPlayer, var_max_health))); + if(Cvars[HEALTH]) + set_entvar(playerId, var_health, floatclamp(Cvars[HEALTH], 1.0, Float:get_entvar(playerId, var_max_health))); - if(g_eCvars[ARMOR]) - rg_set_user_armor(iPlayer, g_eCvars[ARMOR], ArmorType:g_eCvars[ARMOR_TYPE]); + if(Cvars[ARMOR]) + rg_set_user_armor(playerId, Cvars[ARMOR], ArmorType:Cvars[ARMOR_TYPE]); - if(g_iWeapons > 0) { - rg_remove_all_items(iPlayer); + if(WeaponsNum > 0) { + rg_remove_all_items(playerId); - for(new i; i <= g_iWeapons; i++) { - new iWeapon = rg_give_item(iPlayer, g_szWeapon[i]); + for(new i; i <= WeaponsNum; i++) { + new playerWeapon = rg_give_item(playerId, Weapon[i]); - if(!is_nullent(iWeapon)) { - new WeaponIdType:iWeaponType = WeaponIdType:get_member(iWeapon, m_iId); + if(!is_nullent(playerWeapon)) { + new WeaponIdType:weaponType = WeaponIdType:get_member(playerWeapon, m_iId); - if(iWeaponType != WEAPON_KNIFE && iWeaponType != WEAPON_SHIELDGUN) - rg_set_user_bpammo(iPlayer, iWeaponType, rg_get_iteminfo(iWeapon, ItemInfo_iMaxAmmo1)); + if(weaponType != WEAPON_KNIFE && weaponType != WEAPON_SHIELDGUN) + rg_set_user_bpammo(playerId, weaponType, rg_get_iteminfo(playerWeapon, ItemInfo_iMaxAmmo1)); } } } - if(g_eCvars[FRAGS]) - ExecuteHamB(Ham_AddPoints, iActivator, g_eCvars[FRAGS], false); + if(Cvars[FRAGS]) + ExecuteHamB(Ham_AddPoints, activatorId, Cvars[FRAGS], false); - if(g_eCvars[NO_DEATHPOINT]) - set_member(iPlayer, m_iDeaths, max(get_member(iPlayer, m_iDeaths) - 1, 0)); + if(Cvars[NO_DEATHPOINT]) + set_member(playerId, m_iDeaths, max(get_member(playerId, m_iDeaths) - 1, 0)); } } case MODE_PLANT: { - if(g_eCvars[PLANTING_HEALTH]) - rg_add_health_to_player(iActivator, g_eCvars[PLANTING_HEALTH]); + if(Cvars[PLANTING_HEALTH]) + rg_add_health_to_player(activatorId, Cvars[PLANTING_HEALTH]); } } } -stock rg_add_health_to_player(const iPlayer, const Float:flHealth) { - set_entvar(iPlayer, var_health, floatclamp(Float:get_entvar(iPlayer, var_health) + flHealth, 1.0, Float:get_entvar(iPlayer, var_max_health))); +stock rg_add_health_to_player(const playerId, const Float:health) { + set_entvar(playerId, var_health, floatclamp(Float:get_entvar(playerId, var_health) + health, 1.0, Float:get_entvar(playerId, var_max_health))); } public CreateCvars() { @@ -117,16 +118,16 @@ public CreateCvars() { "weapon_knife weapon_deagle", FCVAR_NONE, "What weapons should be given to the player after resurrection(no more than 6)(otherwise standard from game.cfg)"), - g_eCvars[WEAPONS], - charsmax(g_eCvars[WEAPONS]) + Cvars[WEAPONS], + charsmax(Cvars[WEAPONS]) ); bind_pcvar_string(create_cvar( "rt_weapons_maps", "weapon_knife weapon_awp", FCVAR_NONE, "What weapons should be given to the player after resurrection on 'awp_' maps(no more than 6)(otherwise standard from game.cfg)"), - g_eCvars[WEAPONS_MAPS], - charsmax(g_eCvars[WEAPONS_MAPS]) + Cvars[WEAPONS_MAPS], + charsmax(Cvars[WEAPONS_MAPS]) ); bind_pcvar_float(create_cvar( "rt_revive_health", @@ -135,7 +136,7 @@ public CreateCvars() { "How much more health to add after resurrection", true, 0.0), - g_eCvars[REVIVE_HEALTH] + Cvars[REVIVE_HEALTH] ); bind_pcvar_float(create_cvar( "rt_planting_health", @@ -144,7 +145,7 @@ public CreateCvars() { "How much more health to add after planting", true, 0.0), - g_eCvars[PLANTING_HEALTH] + Cvars[PLANTING_HEALTH] ); bind_pcvar_float(create_cvar( "rt_health", @@ -153,7 +154,7 @@ public CreateCvars() { "The number of health of the resurrected player", true, 1.0), - g_eCvars[HEALTH] + Cvars[HEALTH] ); bind_pcvar_num(create_cvar( "rt_armor_type", @@ -164,7 +165,7 @@ public CreateCvars() { 0.0, true, 2.0), - g_eCvars[ARMOR_TYPE] + Cvars[ARMOR_TYPE] ); bind_pcvar_num(create_cvar( "rt_armor", @@ -173,7 +174,7 @@ public CreateCvars() { "Number of armor of the resurrected player", true, 0.0), - g_eCvars[ARMOR] + Cvars[ARMOR] ); bind_pcvar_num(create_cvar( "rt_frags", @@ -182,7 +183,7 @@ public CreateCvars() { "Number of frags for resurrection", true, 0.0), - g_eCvars[FRAGS] + Cvars[FRAGS] ); bind_pcvar_num(create_cvar( "rt_restore_death", @@ -193,6 +194,6 @@ public CreateCvars() { 0.0, true, 1.0), - g_eCvars[NO_DEATHPOINT] + Cvars[NO_DEATHPOINT] ); } \ No newline at end of file diff --git a/addons/amxmodx/scripting/rt_core.sma b/addons/amxmodx/scripting/rt_core.sma index 67c18ee..c09d886 100644 --- a/addons/amxmodx/scripting/rt_core.sma +++ b/addons/amxmodx/scripting/rt_core.sma @@ -4,8 +4,9 @@ #include #include -public stock const PLUGIN[] = "Revive Teammates: Core"; -public stock const CFG_FILE[] = "addons/amxmodx/configs/rt_configs/rt_core.cfg"; +#define PLUGIN_NAME "Revive Teammates: Core" + +#define CFG_FILE "addons/amxmodx/configs/rt_configs/rt_core.cfg" // Custom Player Models https://dev-cs.ru/resources/928/ native bool:custom_player_models_get_path(const player, path[] = "", length = 0); @@ -21,9 +22,9 @@ enum CVARS { CORPSE_MODEL_MODE }; -new g_eCvars[CVARS]; +new Cvars[CVARS]; -enum Forwards { +enum FORWARDS { ReviveStart, ReviveStart_Post, ReviveLoop_Pre, @@ -34,16 +35,16 @@ enum Forwards { CreatingCorpseEnd }; -new g_eForwards[Forwards]; +new Forwards[FORWARDS]; -new g_iPlantingPluginID; +new PlantingPluginId; -new Float:g_fLastUse[MAX_PLAYERS + 1], g_iTimeUntil[MAX_PLAYERS + 1]; +new Float:LastUse[MAX_PLAYERS + 1], TimeUntil[MAX_PLAYERS + 1]; -new Float:g_fVecSpawnOrigin[3]; -new HookChain:g_pHook_GetPlayerSpawnSpot; -new g_szModel[MAX_PLAYERS + 1][64]; -new Modes:g_iCurrentMode[MAX_PLAYERS + 1] = { MODE_NONE, ... }; +new Float:VecSpawnOrigin[3]; +new HookChain:HC_GetPlayerSpawnSpot; +new Model[MAX_PLAYERS + 1][64]; +new Modes:CurrentMode[MAX_PLAYERS + 1] = { MODE_NONE, ... }; public plugin_precache() { CreateCvars(); @@ -53,267 +54,267 @@ public plugin_precache() { } public plugin_init() { - register_plugin(PLUGIN, VERSION, AUTHORS); + register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHORS); - register_dictionary("rt_library.txt"); + register_dictionary(PLUGIN_DICTIONARY); register_message(get_user_msgid("ClCorpse"), "MessageHook_ClCorpse"); RegisterHookChain(RG_CSGameRules_CleanUpMap, "CSGameRules_CleanUpMap_Post", true); RegisterHookChain(RG_CBasePlayer_UseEmpty, "CBasePlayer_UseEmpty_Pre", false); - DisableHookChain((g_pHook_GetPlayerSpawnSpot = RegisterHookChain(RG_CSGameRules_GetPlayerSpawnSpot, "CSGameRules_GetPlayerSpawnSpot_Pre", false))); + DisableHookChain((HC_GetPlayerSpawnSpot = RegisterHookChain(RG_CSGameRules_GetPlayerSpawnSpot, "CSGameRules_GetPlayerSpawnSpot_Pre", false))); RegisterHookChain(RG_CBasePlayer_Spawn, "CBasePlayer_Spawn_Pre", false); RegisterHookChain(RG_CBasePlayer_SetClientUserInfoModel, "CBasePlayer_SetClientUserInfoModel_Pre"); - g_eForwards[ReviveStart] = CreateMultiForward("rt_revive_start", ET_STOP, FP_CELL, FP_CELL, FP_CELL, FP_CELL); - g_eForwards[ReviveStart_Post] = CreateMultiForward("rt_revive_start_post", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL); - g_eForwards[ReviveLoop_Pre] = CreateMultiForward("rt_revive_loop_pre", ET_STOP, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_CELL); - g_eForwards[ReviveLoop_Post] = CreateMultiForward("rt_revive_loop_post", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_CELL); - g_eForwards[ReviveEnd] = CreateMultiForward("rt_revive_end", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL); - g_eForwards[ReviveCancelled] = CreateMultiForward("rt_revive_cancelled", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL); - g_eForwards[CreatingCorpseStart] = CreateMultiForward("rt_creating_corpse_start", ET_STOP, FP_CELL, FP_CELL); - g_eForwards[CreatingCorpseEnd] = CreateMultiForward("rt_creating_corpse_end", ET_IGNORE, FP_CELL, FP_CELL, FP_ARRAY); + Forwards[ReviveStart] = CreateMultiForward("rt_revive_start", ET_STOP, FP_CELL, FP_CELL, FP_CELL, FP_CELL); + Forwards[ReviveStart_Post] = CreateMultiForward("rt_revive_start_post", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL); + Forwards[ReviveLoop_Pre] = CreateMultiForward("rt_revive_loop_pre", ET_STOP, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_CELL); + Forwards[ReviveLoop_Post] = CreateMultiForward("rt_revive_loop_post", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_CELL); + Forwards[ReviveEnd] = CreateMultiForward("rt_revive_end", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL); + Forwards[ReviveCancelled] = CreateMultiForward("rt_revive_cancelled", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL); + Forwards[CreatingCorpseStart] = CreateMultiForward("rt_creating_corpse_start", ET_STOP, FP_CELL, FP_CELL); + Forwards[CreatingCorpseEnd] = CreateMultiForward("rt_creating_corpse_end", ET_IGNORE, FP_CELL, FP_CELL, FP_ARRAY); - g_iPlantingPluginID = is_plugin_loaded("rt_planting.amxx", true); + PlantingPluginId = is_plugin_loaded("rt_planting.amxx", true); } -public client_disconnected(iPlayer) { - g_fLastUse[iPlayer] = 0.0; +public client_disconnected(playerId) { + LastUse[playerId] = 0.0; - PlayerSpawnOrDisconnect(iPlayer); + PlayerSpawnOrDisconnect(playerId); } -public client_remove(iPlayer) { - g_iCurrentMode[iPlayer] = MODE_NONE; +public client_remove(playerId) { + CurrentMode[playerId] = MODE_NONE; } public CSGameRules_CleanUpMap_Post() { - arrayset(g_iCurrentMode, MODE_NONE, sizeof(g_iCurrentMode)); + arrayset(CurrentMode, MODE_NONE, sizeof(CurrentMode)); RemoveCorpses(0, DEAD_BODY_CLASSNAME); } -public CBasePlayer_UseEmpty_Pre(const iActivator) { - if(~get_entvar(iActivator, var_flags) & FL_ONGROUND) +public CBasePlayer_UseEmpty_Pre(const activatorId) { + if(~get_entvar(activatorId, var_flags) & FL_ONGROUND) return; - new iEnt = RT_NULLENT; + new entId = RT_NULLENT; - new Float:fVecPlOrigin[3], Float:fVecEntOrigin[3]; - get_entvar(iActivator, var_origin, fVecPlOrigin); + new Float:vecPlOrigin[3], Float:vecEntOrigin[3]; + get_entvar(activatorId, var_origin, vecPlOrigin); - while((iEnt = rg_find_ent_by_class(iEnt, DEAD_BODY_CLASSNAME)) > 0) { - if(!is_nullent(iEnt)) { - get_entvar(iEnt, var_vuser4, fVecEntOrigin); + while((entId = rg_find_ent_by_class(entId, DEAD_BODY_CLASSNAME)) > 0) { + if(!is_nullent(entId)) { + get_entvar(entId, var_vuser4, vecEntOrigin); - if(ExecuteHam(Ham_FVecInViewCone, iActivator, fVecEntOrigin) && vector_distance(fVecPlOrigin, fVecEntOrigin) < g_eCvars[SEARCH_RADIUS]) { - Corpse_Use(iEnt, iActivator); + if(ExecuteHam(Ham_FVecInViewCone, activatorId, vecEntOrigin) && vector_distance(vecPlOrigin, vecEntOrigin) < Cvars[SEARCH_RADIUS]) { + Corpse_Use(entId, activatorId); return; } } } } -public CSGameRules_GetPlayerSpawnSpot_Pre(const iPlayer) { - DisableHookChain(g_pHook_GetPlayerSpawnSpot); +public CSGameRules_GetPlayerSpawnSpot_Pre(const playerId) { + DisableHookChain(HC_GetPlayerSpawnSpot); - set_entvar(iPlayer, var_flags, get_entvar(iPlayer, var_flags) | FL_DUCKING); + set_entvar(playerId, var_flags, get_entvar(playerId, var_flags) | FL_DUCKING); - set_entvar(iPlayer, var_velocity, NULL_VECTOR); - set_entvar(iPlayer, var_v_angle, NULL_VECTOR); + set_entvar(playerId, var_velocity, NULL_VECTOR); + set_entvar(playerId, var_v_angle, NULL_VECTOR); - new Float:fVecAngles[3]; - get_entvar(iPlayer, var_angles, fVecAngles); - fVecAngles[0] = fVecAngles[2] = 0.0; - set_entvar(iPlayer, var_angles, fVecAngles); + new Float:vecAngles[3]; + get_entvar(playerId, var_angles, vecAngles); + vecAngles[0] = vecAngles[2] = 0.0; + set_entvar(playerId, var_angles, vecAngles); - set_entvar(iPlayer, var_punchangle, NULL_VECTOR); - set_entvar(iPlayer, var_fixangle, 1); + set_entvar(playerId, var_punchangle, NULL_VECTOR); + set_entvar(playerId, var_fixangle, 1); - engfunc(EngFunc_SetSize, iPlayer, Float:{-16.000000, -16.000000, -18.000000}, Float:{16.000000, 16.000000, 32.000000}); - engfunc(EngFunc_SetOrigin, iPlayer, g_fVecSpawnOrigin); + engfunc(EngFunc_SetSize, playerId, Float:{-16.000000, -16.000000, -18.000000}, Float:{16.000000, 16.000000, 32.000000}); + engfunc(EngFunc_SetOrigin, playerId, VecSpawnOrigin); SetHookChainReturn(ATYPE_INTEGER, RT_NULLENT); return HC_SUPERCEDE; } -public CBasePlayer_Spawn_Pre(const iPlayer) { - PlayerSpawnOrDisconnect(iPlayer); +public CBasePlayer_Spawn_Pre(const playerId) { + PlayerSpawnOrDisconnect(playerId); } -public CBasePlayer_SetClientUserInfoModel_Pre(const iPlayer, szInfoBuffer[], szNewModel[]) { - copy(g_szModel[iPlayer], charsmax(g_szModel[]), szNewModel); +public CBasePlayer_SetClientUserInfoModel_Pre(const playerId, infoBuffer[], newModel[]) { + copy(Model[playerId], charsmax(Model[]), newModel); } -public Corpse_Use(const iEnt, const iActivator) { - if(is_nullent(iEnt) || get_member_game(m_bRoundTerminating) || !ExecuteHam(Ham_IsPlayer, iActivator)) +public Corpse_Use(const entId, const activatorId) { + if(is_nullent(entId) || get_member_game(m_bRoundTerminating) || !ExecuteHam(Ham_IsPlayer, activatorId)) return; - new iPlayer = get_entvar(iEnt, var_owner); - new TeamName:iPlTeam = TeamName:get_member(iPlayer, m_iTeam); - new TeamName:iActTeam = TeamName:get_member(iActivator, m_iTeam); - new TeamName:iEntTeam = TeamName:get_entvar(iEnt, var_team); - new Modes:eCurrentMode = (iActTeam == iPlTeam) ? MODE_REVIVE : MODE_PLANT; + new playerId = get_entvar(entId, var_owner); + new TeamName:plTeam = TeamName:get_member(playerId, m_iTeam); + new TeamName:actTeam = TeamName:get_member(activatorId, m_iTeam); + new TeamName:entTeam = TeamName:get_entvar(entId, var_team); + new Modes:currentMode = (actTeam == plTeam) ? MODE_REVIVE : MODE_PLANT; - if(g_iPlantingPluginID == INVALID_PLUGIN_ID && eCurrentMode == MODE_PLANT) + if(PlantingPluginId == INVALID_PLUGIN_ID && currentMode == MODE_PLANT) return; - if(iActTeam == TEAM_SPECTATOR || iPlTeam == TEAM_SPECTATOR) + if(actTeam == TEAM_SPECTATOR || plTeam == TEAM_SPECTATOR) return; - if(iEntTeam != iPlTeam) { - NotifyClient(iActivator, print_team_red, "RT_CHANGE_TEAM"); + if(entTeam != plTeam) { + NotifyClient(activatorId, print_team_red, "RT_CHANGE_TEAM"); return; } - if(get_entvar(iEnt, var_iuser1)) { - NotifyClient(iActivator, print_team_red, "RT_ACTIVATOR_EXISTS"); + if(get_entvar(entId, var_iuser1)) { + NotifyClient(activatorId, print_team_red, "RT_ACTIVATOR_EXISTS"); return; } - if(!is_user_alive(iActivator)) { - ResetCorpseThink(g_eForwards[ReviveCancelled], iEnt, iPlayer, iActivator, eCurrentMode); + if(!is_user_alive(activatorId)) { + ResetCorpseThink(Forwards[ReviveCancelled], entId, playerId, activatorId, currentMode); return; } new fwRet; - ExecuteForward(g_eForwards[ReviveStart], fwRet, iEnt, iPlayer, iActivator, eCurrentMode); + ExecuteForward(Forwards[ReviveStart], fwRet, entId, playerId, activatorId, currentMode); if(fwRet == PLUGIN_HANDLED) { - ResetCorpseThink(g_eForwards[ReviveCancelled], iEnt, iPlayer, iActivator, eCurrentMode); + ResetCorpseThink(Forwards[ReviveCancelled], entId, playerId, activatorId, currentMode); return; } - new Float:fGameTime = get_gametime(); + new Float:gameTime = get_gametime(); - if(g_fLastUse[iActivator] > fGameTime) { - NotifyClient(iActivator, print_team_red, "RT_ANTI_FLOOD"); - ResetCorpseThink(g_eForwards[ReviveCancelled], iEnt, iPlayer, iActivator, eCurrentMode); + if(LastUse[activatorId] > gameTime) { + NotifyClient(activatorId, print_team_red, "RT_ANTI_FLOOD"); + ResetCorpseThink(Forwards[ReviveCancelled], entId, playerId, activatorId, currentMode); return; } - g_fLastUse[iActivator] = fGameTime + g_eCvars[ANTIFLOOD_TIME]; + LastUse[activatorId] = gameTime + Cvars[ANTIFLOOD_TIME]; - NotifyClient(iActivator, print_team_blue, eCurrentMode == MODE_REVIVE ? "RT_TIMER_REVIVE" : "RT_TIMER_PLANT", iPlayer); + NotifyClient(activatorId, print_team_blue, currentMode == MODE_REVIVE ? "RT_TIMER_REVIVE" : "RT_TIMER_PLANT", playerId); - g_iTimeUntil[iActivator] = 0; + TimeUntil[activatorId] = 0; - set_entvar(iEnt, var_iuser1, iActivator); - set_entvar(iEnt, var_iuser2, eCurrentMode); - set_entvar(iEnt, var_fuser1, fGameTime + g_eCvars[REVIVE_TIME]); - set_entvar(iEnt, var_fuser3, g_eCvars[REVIVE_TIME]); - set_entvar(iEnt, var_nextthink, fGameTime + 0.1); + set_entvar(entId, var_iuser1, activatorId); + set_entvar(entId, var_iuser2, currentMode); + set_entvar(entId, var_fuser1, gameTime + Cvars[REVIVE_TIME]); + set_entvar(entId, var_fuser3, Cvars[REVIVE_TIME]); + set_entvar(entId, var_nextthink, gameTime + 0.1); - g_iCurrentMode[iActivator] = eCurrentMode; + CurrentMode[activatorId] = currentMode; - ExecuteForward(g_eForwards[ReviveStart_Post], _, iEnt, iPlayer, iActivator, eCurrentMode); + ExecuteForward(Forwards[ReviveStart_Post], _, entId, playerId, activatorId, currentMode); } -public Corpse_Think(const iEnt) { - if(is_nullent(iEnt)) +public Corpse_Think(const entId) { + if(is_nullent(entId)) return; - new iPlayer = get_entvar(iEnt, var_owner); - new iActivator = get_entvar(iEnt, var_iuser1); - new Float:fGameTime = get_gametime(); + new playerId = get_entvar(entId, var_owner); + new activatorId = get_entvar(entId, var_iuser1); + new Float:gameTime = get_gametime(); - if(!iActivator) { - if(g_eCvars[CORPSE_TIME] && Float:get_entvar(iEnt, var_fuser4) < fGameTime) { - RemoveCorpses(iPlayer, DEAD_BODY_CLASSNAME); + if(!activatorId) { + if(Cvars[CORPSE_TIME] && Float:get_entvar(entId, var_fuser4) < gameTime) { + RemoveCorpses(playerId, DEAD_BODY_CLASSNAME); return; } - set_entvar(iEnt, var_nextthink, fGameTime + 1.0); + set_entvar(entId, var_nextthink, gameTime + 1.0); return; } - new TeamName:iPlTeam = TeamName:get_member(iPlayer, m_iTeam); - new TeamName:iEntTeam = TeamName:get_entvar(iEnt, var_team); - new Modes:eCurrentMode = Modes:get_entvar(iEnt, var_iuser2); + new TeamName:plTeam = TeamName:get_member(playerId, m_iTeam); + new TeamName:entTeam = TeamName:get_entvar(entId, var_team); + new Modes:currentMode = Modes:get_entvar(entId, var_iuser2); - if(iEntTeam != iPlTeam) { - NotifyClient(iActivator, print_team_red, "RT_CHANGE_TEAM"); - ResetCorpseThink(g_eForwards[ReviveCancelled], iEnt, iPlayer, iActivator, eCurrentMode); + if(entTeam != plTeam) { + NotifyClient(activatorId, print_team_red, "RT_CHANGE_TEAM"); + ResetCorpseThink(Forwards[ReviveCancelled], entId, playerId, activatorId, currentMode); return; } - if(~get_entvar(iActivator, var_button) & IN_USE) { - NotifyClient(iActivator, print_team_red, eCurrentMode == MODE_REVIVE ? "RT_CANCELLED_REVIVE" : "RT_CANCELLED_PLANT"); - ResetCorpseThink(g_eForwards[ReviveCancelled], iEnt, iPlayer, iActivator, eCurrentMode); + if(~get_entvar(activatorId, var_button) & IN_USE) { + NotifyClient(activatorId, print_team_red, currentMode == MODE_REVIVE ? "RT_CANCELLED_REVIVE" : "RT_CANCELLED_PLANT"); + ResetCorpseThink(Forwards[ReviveCancelled], entId, playerId, activatorId, currentMode); return; } - new Float:fTimeUntil[2]; - fTimeUntil[0] = Float:get_entvar(iEnt, var_fuser1); - fTimeUntil[1] = Float:get_entvar(iEnt, var_fuser3); + new Float:timeUntil[2]; + timeUntil[0] = Float:get_entvar(entId, var_fuser1); + timeUntil[1] = Float:get_entvar(entId, var_fuser3); - g_iTimeUntil[iActivator]++; + TimeUntil[activatorId]++; - if(g_iTimeUntil[iActivator] == 10 || g_eCvars[FORCE_FWD_MODE]) { - if(g_eCvars[FORCE_FWD_MODE]) { - fTimeUntil[1] -= 0.1; + if(TimeUntil[activatorId] == 10 || Cvars[FORCE_FWD_MODE]) { + if(Cvars[FORCE_FWD_MODE]) { + timeUntil[1] -= 0.1; } else { - fTimeUntil[1] -= 1.0; + timeUntil[1] -= 1.0; } - if(!is_user_alive(iActivator)) { - ResetCorpseThink(g_eForwards[ReviveCancelled], iEnt, iPlayer, iActivator, eCurrentMode); + if(!is_user_alive(activatorId)) { + ResetCorpseThink(Forwards[ReviveCancelled], entId, playerId, activatorId, currentMode); return; } new fwRet; - ExecuteForward(g_eForwards[ReviveLoop_Pre], fwRet, iEnt, iPlayer, iActivator, fTimeUntil[1], eCurrentMode); + ExecuteForward(Forwards[ReviveLoop_Pre], fwRet, entId, playerId, activatorId, timeUntil[1], currentMode); if(fwRet == PLUGIN_HANDLED) { - ResetCorpseThink(g_eForwards[ReviveCancelled], iEnt, iPlayer, iActivator, eCurrentMode); + ResetCorpseThink(Forwards[ReviveCancelled], entId, playerId, activatorId, currentMode); return; } } - if(fGameTime > fTimeUntil[0]) { - new Modes:iMode = Modes:get_entvar(iEnt, var_iuser3); + if(gameTime > timeUntil[0]) { + new Modes:entMode = Modes:get_entvar(entId, var_iuser3); - if(eCurrentMode == MODE_REVIVE && iMode != MODE_PLANT) { - NotifyClient(iActivator, print_team_red, "RT_REVIVE", iPlayer); - NotifyClient(iPlayer, print_team_red, "RT_REVIVED", iActivator); + if(currentMode == MODE_REVIVE && entMode != MODE_PLANT) { + NotifyClient(activatorId, print_team_red, "RT_REVIVE", playerId); + NotifyClient(playerId, print_team_red, "RT_REVIVED", activatorId); - get_entvar(iActivator, var_origin, g_fVecSpawnOrigin); + get_entvar(activatorId, var_origin, VecSpawnOrigin); - RemoveCorpses(iPlayer, DEAD_BODY_CLASSNAME); + RemoveCorpses(playerId, DEAD_BODY_CLASSNAME); - EnableHookChain(g_pHook_GetPlayerSpawnSpot); - rg_round_respawn(iPlayer); - DisableHookChain(g_pHook_GetPlayerSpawnSpot); + EnableHookChain(HC_GetPlayerSpawnSpot); + rg_round_respawn(playerId); + DisableHookChain(HC_GetPlayerSpawnSpot); - if(is_user_alive(iPlayer)) - engfunc(EngFunc_SetOrigin, iPlayer, g_fVecSpawnOrigin); + if(is_user_alive(playerId)) + engfunc(EngFunc_SetOrigin, playerId, VecSpawnOrigin); } - if(!is_user_alive(iActivator)) { - ResetCorpseThink(g_eForwards[ReviveCancelled], iEnt, iPlayer, iActivator, eCurrentMode); + if(!is_user_alive(activatorId)) { + ResetCorpseThink(Forwards[ReviveCancelled], entId, playerId, activatorId, currentMode); return; } - g_iCurrentMode[iActivator] = MODE_NONE; + CurrentMode[activatorId] = MODE_NONE; - ExecuteForward(g_eForwards[ReviveEnd], _, iEnt, iPlayer, iActivator, eCurrentMode); + ExecuteForward(Forwards[ReviveEnd], _, entId, playerId, activatorId, currentMode); return; } - if(g_iTimeUntil[iActivator] == 10 || g_eCvars[FORCE_FWD_MODE]) { - if(!is_user_alive(iActivator)) { - ResetCorpseThink(g_eForwards[ReviveCancelled], iEnt, iPlayer, iActivator, eCurrentMode); + if(TimeUntil[activatorId] == 10 || Cvars[FORCE_FWD_MODE]) { + if(!is_user_alive(activatorId)) { + ResetCorpseThink(Forwards[ReviveCancelled], entId, playerId, activatorId, currentMode); return; } - ExecuteForward(g_eForwards[ReviveLoop_Post], _, iEnt, iPlayer, iActivator, fTimeUntil[1], eCurrentMode); + ExecuteForward(Forwards[ReviveLoop_Post], _, entId, playerId, activatorId, timeUntil[1], currentMode); - g_iTimeUntil[iActivator] = 0; + TimeUntil[activatorId] = 0; } - set_entvar(iEnt, var_fuser3, fTimeUntil[1]); - set_entvar(iEnt, var_nextthink, fGameTime + 0.1); + set_entvar(entId, var_fuser3, timeUntil[1]); + set_entvar(entId, var_nextthink, gameTime + 0.1); } public MessageHook_ClCorpse() { @@ -325,102 +326,171 @@ public MessageHook_ClCorpse() { arg_id = 12 }; - new iPlayer = get_msg_arg_int(arg_id); - new TeamName:iPlTeam = TeamName:get_member(iPlayer, m_iTeam); + new playerId = get_msg_arg_int(arg_id); + new TeamName:plTeam = TeamName:get_member(playerId, m_iTeam); - if(iPlTeam == TEAM_SPECTATOR || g_szModel[iPlayer][0] == EOS) + if(plTeam == TEAM_SPECTATOR || Model[playerId][0] == EOS) return PLUGIN_HANDLED; - new iEnt = rg_create_entity("info_target"); + new entId = rg_create_entity("info_target"); new fwRet; - ExecuteForward(g_eForwards[CreatingCorpseStart], fwRet, iEnt, iPlayer); + ExecuteForward(Forwards[CreatingCorpseStart], fwRet, entId, playerId); if(fwRet == PLUGIN_HANDLED) { - set_entvar(iEnt, var_flags, FL_KILLME); - set_entvar(iEnt, var_nextthink, 0.0); + set_entvar(entId, var_flags, FL_KILLME); + set_entvar(entId, var_nextthink, 0.0); return PLUGIN_HANDLED; } - /*new szModel[32], szModelPath[MAX_RESOURCE_PATH_LENGTH]; - get_user_info(iPlayer, "model", szModel, charsmax(szModel)); - formatex(szModelPath, charsmax(szModelPath), "models/player/%s/%s.mdl", szModel, szModel);*/ - new szModelPath[MAX_RESOURCE_PATH_LENGTH]; + /*new model[32], modelPath[MAX_RESOURCE_PATH_LENGTH]; + get_user_info(playerId, "model", model, charsmax(model)); + formatex(modelPath, charsmax(modelPath), "models/player/%s/%s.mdl", model, model);*/ + new modelPath[MAX_RESOURCE_PATH_LENGTH]; - new Float:fVecOrigin[3]; - fVecOrigin[0] = float(get_msg_arg_int(2) / 128); - fVecOrigin[1] = float(get_msg_arg_int(3) / 128); - fVecOrigin[2] = float(get_msg_arg_int(4) / 128); + new Float:vecOrigin[3]; + vecOrigin[0] = float(get_msg_arg_int(2) / 128); + vecOrigin[1] = float(get_msg_arg_int(3) / 128); + vecOrigin[2] = float(get_msg_arg_int(4) / 128); - if(!custom_player_models_get_path(iPlayer, szModelPath, charsmax(szModelPath))) { - new iBody = get_msg_arg_int(arg_body); + if(!custom_player_models_get_path(playerId, modelPath, charsmax(modelPath))) { + new body = get_msg_arg_int(arg_body); - if(!g_eCvars[CORPSE_MODEL_MODE]) { - formatex(szModelPath, charsmax(szModelPath), "models/player/%s/%s.mdl", g_szModel[iPlayer], g_szModel[iPlayer]); + if(!Cvars[CORPSE_MODEL_MODE]) { + formatex(modelPath, charsmax(modelPath), "models/player/%s/%s.mdl", Model[playerId], Model[playerId]); } else { - new szModel[64]; - rh_update_user_info(iPlayer); - get_user_info(iPlayer, "model", szModel, charsmax(szModel)); - formatex(szModelPath, charsmax(szModelPath), "models/player/%s/%s.mdl", szModel, szModel); + new model[64]; + rh_update_user_info(playerId); + get_user_info(playerId, "model", model, charsmax(model)); + formatex(modelPath, charsmax(modelPath), "models/player/%s/%s.mdl", model, model); } - set_entvar(iEnt, var_body, iBody); - set_entvar(iEnt, var_skin, get_entvar(iPlayer, var_skin)); + set_entvar(entId, var_body, body); + set_entvar(entId, var_skin, get_entvar(playerId, var_skin)); } else { - new iBody, iSkin; - custom_player_models_get_body(iPlayer, iPlTeam, iBody); - custom_player_models_get_skin(iPlayer, iPlTeam, iSkin); - set_entvar(iEnt, var_body, iBody); - set_entvar(iEnt, var_skin, iSkin); + new body, skin; + custom_player_models_get_body(playerId, plTeam, body); + custom_player_models_get_skin(playerId, plTeam, skin); + set_entvar(entId, var_body, body); + set_entvar(entId, var_skin, skin); } - set_entvar(iEnt, var_modelindex, engfunc(EngFunc_ModelIndex, szModelPath)); - set_entvar(iEnt, var_model, szModelPath); - //set_entvar(iEnt, var_renderfx, kRenderFxDeadPlayer); - //set_entvar(iEnt, var_renderamt, float(iPlayer)); + set_entvar(entId, var_modelindex, engfunc(EngFunc_ModelIndex, modelPath)); + set_entvar(entId, var_model, modelPath); + //set_entvar(entId, var_renderfx, kRenderFxDeadPlayer); + //set_entvar(entId, var_renderamt, float(playerId)); - set_entvar(iEnt, var_classname, DEAD_BODY_CLASSNAME); - set_entvar(iEnt, var_sequence, get_entvar(iPlayer, var_sequence)); - set_entvar(iEnt, var_frame, 255.0); - set_entvar(iEnt, var_owner, iPlayer); - set_entvar(iEnt, var_team, iPlTeam); + set_entvar(entId, var_classname, DEAD_BODY_CLASSNAME); + set_entvar(entId, var_sequence, get_entvar(playerId, var_sequence)); + set_entvar(entId, var_frame, 255.0); + set_entvar(entId, var_owner, playerId); + set_entvar(entId, var_team, plTeam); - //get_entvar(iPlayer, var_origin, fVecOrigin); - engfunc(EngFunc_SetOrigin, iEnt, fVecOrigin); + //get_entvar(playerId, var_origin, vecOrigin); + engfunc(EngFunc_SetOrigin, entId, vecOrigin); - new Float:fVecAngles[3]; - get_entvar(iPlayer, var_angles, fVecAngles); - set_entvar(iEnt, var_angles, fVecAngles); + new Float:vecAngles[3]; + get_entvar(playerId, var_angles, vecAngles); + set_entvar(entId, var_angles, vecAngles); - engfunc(EngFunc_GetBonePosition, iEnt, 2, fVecOrigin, fVecAngles); - set_entvar(iEnt, var_vuser4, fVecOrigin); + engfunc(EngFunc_GetBonePosition, entId, 2, vecOrigin, vecAngles); + set_entvar(entId, var_vuser4, vecOrigin); - set_entvar(iEnt, var_fuser2, g_eCvars[SEARCH_RADIUS]); + set_entvar(entId, var_fuser2, Cvars[SEARCH_RADIUS]); - set_entvar(iEnt, var_nextthink, get_gametime() + 1.0); - SetThink(iEnt, "Corpse_Think"); + set_entvar(entId, var_nextthink, get_gametime() + 1.0); + SetThink(entId, "Corpse_Think"); - if(g_eCvars[CORPSE_TIME]) - set_entvar(iEnt, var_fuser4, get_gametime() + g_eCvars[CORPSE_TIME]); + if(Cvars[CORPSE_TIME]) + set_entvar(entId, var_fuser4, get_gametime() + Cvars[CORPSE_TIME]); - fVecOrigin[2] += 20.0; + vecOrigin[2] += 20.0; - ExecuteForward(g_eForwards[CreatingCorpseEnd], _, iEnt, iPlayer, PrepareArray(_:fVecOrigin, sizeof(fVecOrigin))); + ExecuteForward(Forwards[CreatingCorpseEnd], _, entId, playerId, PrepareArray(_:vecOrigin, sizeof(vecOrigin))); return PLUGIN_HANDLED; } -stock PlayerSpawnOrDisconnect(const iPlayer) { - new iActivator = RemoveCorpses(iPlayer, DEAD_BODY_CLASSNAME); +stock PlayerSpawnOrDisconnect(const playerId) { + new activatorId = RemoveCorpses(playerId, DEAD_BODY_CLASSNAME); - if(is_user_connected(iActivator)) - NotifyClient(iActivator, print_team_red, "RT_DISCONNECTED"); + if(is_user_connected(activatorId)) + NotifyClient(activatorId, print_team_red, "RT_DISCONNECTED"); - ResetCorpseThink(g_eForwards[ReviveCancelled], RT_NULLENT, iPlayer, iActivator, MODE_NONE); + ResetCorpseThink(Forwards[ReviveCancelled], RT_NULLENT, playerId, activatorId, MODE_NONE); // TODO need to handle corpse user respawn - //if(g_iCurrentMode[iPlayer]) { } + //if(CurrentMode[playerId]) { } +} + +/** + * Reset entity think + * + * @param eForward Forward type + * @param entId Corpse entity index + * @param playerId Player id whose corpse + * @param activatorId Player id who ressurect + * @param eMode MODE_REVIVE - stopped the resurrection, MODE_PLANT - stopped planting + * + * @noreturn + */ +ResetCorpseThink(const eForward, const entId, playerId, activatorId, const Modes:eMode) { + if(!is_nullent(entId)) { + set_entvar(entId, var_nextthink, get_gametime() + 1.0); + set_entvar(entId, var_iuser1, 0); + } + + if(activatorId != RT_NULLENT) { + CurrentMode[activatorId] = MODE_NONE; + } + + playerId = is_user_connected(playerId) ? playerId : RT_NULLENT; + activatorId = is_user_connected(activatorId) ? activatorId : RT_NULLENT; + + ExecuteForward(eForward, _, entId, playerId, activatorId, eMode); +} + +public plugin_natives() { + set_native_filter("native_filter"); + register_native("rt_get_user_mode", "_rt_get_user_mode"); + register_native("rt_reset_use", "_rt_reset_use"); +} + +public Modes:_rt_get_user_mode() { + enum { arg_user = 1 }; + + return CurrentMode[ get_param(arg_user) ]; +} + +public bool:_rt_reset_use() { + enum { arg_user = 1 }; + + new playerId = get_param(arg_user); + + if(CurrentMode[playerId] == MODE_NONE) { + return false; + } + + new entId = RT_NULLENT; + + while((entId = rg_find_ent_by_class(entId, DEAD_BODY_CLASSNAME)) > 0) { + if(!is_entity(entId)) { + continue; + } + + if(playerId == get_entvar(entId, var_iuser1)) { + ResetCorpseThink(Forwards[ReviveCancelled], entId, get_entvar(entId, var_owner), playerId, get_entvar(entId, var_iuser2)); + return true; + } + } + + CurrentMode[playerId] = MODE_NONE; + return false; +} + +public native_filter(const nativeName[], nativeId, trapMode) { + return PLUGIN_HANDLED; } public CreateCvars() { @@ -431,7 +501,7 @@ public CreateCvars() { "Duration of the player's resurrection(in seconds)", true, 1.0), - g_eCvars[REVIVE_TIME] + Cvars[REVIVE_TIME] ); bind_pcvar_float(create_cvar( "rt_revive_antiflood", @@ -440,7 +510,7 @@ public CreateCvars() { "Duration of anti-flood resurrection(in seconds)", true, 1.0), - g_eCvars[ANTIFLOOD_TIME] + Cvars[ANTIFLOOD_TIME] ); bind_pcvar_float(create_cvar( "rt_corpse_time", @@ -449,7 +519,7 @@ public CreateCvars() { "Duration of a corpse's life (in seconds). If you set it to 0, the corpse lives until the end of the round.", true, 0.0), - g_eCvars[CORPSE_TIME] + Cvars[CORPSE_TIME] ); bind_pcvar_float(create_cvar( "rt_search_radius", @@ -458,7 +528,7 @@ public CreateCvars() { "Search radius for a corpse", true, 1.0), - g_eCvars[SEARCH_RADIUS] + Cvars[SEARCH_RADIUS] ); bind_pcvar_num(create_cvar( "rt_force_fwd_mode", @@ -469,7 +539,7 @@ public CreateCvars() { 0.0, true, 1.0), - g_eCvars[FORCE_FWD_MODE] + Cvars[FORCE_FWD_MODE] ); bind_pcvar_num(create_cvar( "rt_corpse_model_mode", @@ -480,75 +550,6 @@ public CreateCvars() { 0.0, true, 1.0), - g_eCvars[CORPSE_MODEL_MODE] + Cvars[CORPSE_MODEL_MODE] ); -} - -/** - * Reset entity think - * - * @param eForward Forward type - * @param iEnt Corpse entity index - * @param iPlayer Player id whose corpse - * @param iActivator Player id who ressurect - * @param eMode MODE_REVIVE - stopped the resurrection, MODE_PLANT - stopped planting - * - * @noreturn - */ -ResetCorpseThink(const eForward, const iEnt, iPlayer, iActivator, const Modes:eMode) { - if(!is_nullent(iEnt)) { - set_entvar(iEnt, var_nextthink, get_gametime() + 1.0); - set_entvar(iEnt, var_iuser1, 0); - } - - if(iActivator != RT_NULLENT) { - g_iCurrentMode[iActivator] = MODE_NONE; - } - - iPlayer = is_user_connected(iPlayer) ? iPlayer : RT_NULLENT; - iActivator = is_user_connected(iActivator) ? iActivator : RT_NULLENT; - - ExecuteForward(eForward, _, iEnt, iPlayer, iActivator, eMode); -} - -public plugin_natives() { - set_native_filter("native_filter"); - register_native("rt_get_user_mode", "_rt_get_user_mode"); - register_native("rt_reset_use", "_rt_reset_use"); -} - -public Modes:_rt_get_user_mode() { - enum { arg_user = 1 }; - - return g_iCurrentMode[ get_param(arg_user) ]; -} - -public bool:_rt_reset_use() { - enum { arg_user = 1 }; - - new pPlayer = get_param(arg_user); - - if(g_iCurrentMode[pPlayer] == MODE_NONE) { - return false; - } - - new iEnt = RT_NULLENT; - - while((iEnt = rg_find_ent_by_class(iEnt, DEAD_BODY_CLASSNAME)) > 0) { - if(!is_entity(iEnt)) { - continue; - } - - if(pPlayer == get_entvar(iEnt, var_iuser1)) { - ResetCorpseThink(g_eForwards[ReviveCancelled], iEnt, get_entvar(iEnt, var_owner), pPlayer, get_entvar(iEnt, var_iuser2)); - return true; - } - } - - g_iCurrentMode[pPlayer] = MODE_NONE; - return false; -} - -public native_filter(const szNativeName[], iNativeID, iTrapMode) { - return PLUGIN_HANDLED; } \ No newline at end of file diff --git a/addons/amxmodx/scripting/rt_effects.sma b/addons/amxmodx/scripting/rt_effects.sma index a66e9da..7f7ae43 100644 --- a/addons/amxmodx/scripting/rt_effects.sma +++ b/addons/amxmodx/scripting/rt_effects.sma @@ -3,8 +3,9 @@ #include #include -public stock const PLUGIN[] = "Revive Teammates: Effects"; -public stock const CFG_FILE[] = "addons/amxmodx/configs/rt_configs/rt_effects.cfg"; +#define PLUGIN_NAME "Revive Teammates: Effects" + +#define CFG_FILE "addons/amxmodx/configs/rt_configs/rt_effects.cfg" new const CORPSE_SPRITE_CLASSNAME[] = "rt_corpse_sprite"; @@ -21,9 +22,9 @@ enum CVARS { PLANTING_GLOW[32] }; -new g_eCvars[CVARS]; +new Cvars[CVARS]; -enum DHudData { +enum DHUD_DATA { COLOR_R, COLOR_G, COLOR_B, @@ -31,16 +32,16 @@ enum DHudData { Float:COORD_Y }; -enum GlowColors +enum GLOWCOLORS { Float:REVIVE_COLOR, Float:PLANTING_COLOR }; -new Float:g_eGlowColors[GlowColors][3]; +new Float:GlowColors[GLOWCOLORS][3]; -new g_eDHudData[Modes][DHudData]; +new DHudData[Modes][DHUD_DATA]; -new Float:g_fTime; +new Float:Time; public plugin_precache() { CreateCvars(); @@ -48,55 +49,55 @@ public plugin_precache() { server_cmd("exec %s", CFG_FILE); server_exec(); - if(g_eCvars[CORPSE_SPRITE][0] != EOS) - precache_model(g_eCvars[CORPSE_SPRITE]); + if(Cvars[CORPSE_SPRITE][0] != EOS) + precache_model(Cvars[CORPSE_SPRITE]); - new szHudColors[3][4]; + new hudColors[3][4]; - if(parse(g_eCvars[REVIVE_COLORS], szHudColors[0], charsmax(szHudColors[]), - szHudColors[1], charsmax(szHudColors[]), szHudColors[2], charsmax(szHudColors[])) == 3) { - g_eDHudData[MODE_REVIVE][COLOR_R] = str_to_num(szHudColors[0]); - g_eDHudData[MODE_REVIVE][COLOR_G] = str_to_num(szHudColors[1]); - g_eDHudData[MODE_REVIVE][COLOR_B] = str_to_num(szHudColors[2]); + if(parse(Cvars[REVIVE_COLORS], hudColors[0], charsmax(hudColors[]), + hudColors[1], charsmax(hudColors[]), hudColors[2], charsmax(hudColors[])) == 3) { + DHudData[MODE_REVIVE][COLOR_R] = str_to_num(hudColors[0]); + DHudData[MODE_REVIVE][COLOR_G] = str_to_num(hudColors[1]); + DHudData[MODE_REVIVE][COLOR_B] = str_to_num(hudColors[2]); } - if(parse(g_eCvars[PLANTING_COLORS], szHudColors[0], charsmax(szHudColors[]), - szHudColors[1], charsmax(szHudColors[]), szHudColors[2], charsmax(szHudColors[])) == 3) { - g_eDHudData[MODE_PLANT][COLOR_R] = str_to_num(szHudColors[0]); - g_eDHudData[MODE_PLANT][COLOR_G] = str_to_num(szHudColors[1]); - g_eDHudData[MODE_PLANT][COLOR_B] = str_to_num(szHudColors[2]); + if(parse(Cvars[PLANTING_COLORS], hudColors[0], charsmax(hudColors[]), + hudColors[1], charsmax(hudColors[]), hudColors[2], charsmax(hudColors[])) == 3) { + DHudData[MODE_PLANT][COLOR_R] = str_to_num(hudColors[0]); + DHudData[MODE_PLANT][COLOR_G] = str_to_num(hudColors[1]); + DHudData[MODE_PLANT][COLOR_B] = str_to_num(hudColors[2]); } - new szHudCoords[2][8]; + new hudCoords[2][8]; - if(parse(g_eCvars[REVIVE_COORDS], szHudCoords[0], charsmax(szHudCoords[]), szHudCoords[1], charsmax(szHudCoords[])) == 2) { - g_eDHudData[MODE_REVIVE][COORD_X] = str_to_float(szHudCoords[0]); - g_eDHudData[MODE_REVIVE][COORD_Y] = str_to_float(szHudCoords[1]); + if(parse(Cvars[REVIVE_COORDS], hudCoords[0], charsmax(hudCoords[]), hudCoords[1], charsmax(hudCoords[])) == 2) { + DHudData[MODE_REVIVE][COORD_X] = str_to_float(hudCoords[0]); + DHudData[MODE_REVIVE][COORD_Y] = str_to_float(hudCoords[1]); } - if(parse(g_eCvars[PLANTING_COORDS], szHudCoords[0], charsmax(szHudCoords[]), szHudCoords[1], charsmax(szHudCoords[])) == 2) { - g_eDHudData[MODE_PLANT][COORD_X] = str_to_float(szHudCoords[0]); - g_eDHudData[MODE_PLANT][COORD_Y] = str_to_float(szHudCoords[1]); + if(parse(Cvars[PLANTING_COORDS], hudCoords[0], charsmax(hudCoords[]), hudCoords[1], charsmax(hudCoords[])) == 2) { + DHudData[MODE_PLANT][COORD_X] = str_to_float(hudCoords[0]); + DHudData[MODE_PLANT][COORD_Y] = str_to_float(hudCoords[1]); } } public plugin_init() { - register_plugin(PLUGIN, VERSION, AUTHORS); + register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHORS); - register_dictionary("rt_library.txt"); + register_dictionary(PLUGIN_DICTIONARY); - if(g_eCvars[CORPSE_SPRITE][0] != EOS) + if(Cvars[CORPSE_SPRITE][0] != EOS) register_forward(FM_AddToFullPack, "AddToFullPack_Pre", false); } public plugin_cfg() { - g_fTime = get_pcvar_float(get_cvar_pointer("rt_revive_time")); + Time = get_pcvar_float(get_cvar_pointer("rt_revive_time")); - if(g_eCvars[REVIVE_GLOW][0] != EOS) - g_eGlowColors[REVIVE_COLOR] = parseHEXColor(g_eCvars[REVIVE_GLOW]); + if(Cvars[REVIVE_GLOW][0] != EOS) + GlowColors[REVIVE_COLOR] = parseHEXColor(Cvars[REVIVE_GLOW]); - if(g_eCvars[PLANTING_GLOW][0] != EOS) - g_eGlowColors[PLANTING_COLOR] = parseHEXColor(g_eCvars[PLANTING_GLOW]); + if(Cvars[PLANTING_GLOW][0] != EOS) + GlowColors[PLANTING_COLOR] = parseHEXColor(Cvars[PLANTING_GLOW]); } public AddToFullPack_Pre(es, e, ent, host, flags, player, pSet) { @@ -111,126 +112,118 @@ public AddToFullPack_Pre(es, e, ent, host, flags, player, pSet) { return FMRES_IGNORED; } -public rt_revive_start(const iEnt, const iPlayer, const iActivator, const Modes:eMode) { - switch(eMode) { +public rt_revive_start(const entId, const playerId, const activatorId, const Modes:mode) { + switch(mode) { case MODE_REVIVE: { - if(g_eCvars[SPECTATOR]) { - rg_internal_cmd(iPlayer, "specmode", "4"); - set_entvar(iPlayer, var_iuser2, iActivator); - set_member(iPlayer, m_hObserverTarget, iActivator); - set_member(iPlayer, m_flNextObserverInput, get_gametime() + 1.25); + if(Cvars[SPECTATOR]) { + rg_internal_cmd(playerId, "specmode", "4"); + set_entvar(playerId, var_iuser2, activatorId); + set_member(playerId, m_hObserverTarget, activatorId); + set_member(playerId, m_flNextObserverInput, get_gametime() + 1.25); } - if(g_eCvars[NOTIFY_DHUD]) { - DisplayDHudMessage(iActivator, eMode, "RT_DHUD_REVIVE", iPlayer); - DisplayDHudMessage(iPlayer, eMode, "RT_DHUD_REVIVE2", iActivator); + if(Cvars[NOTIFY_DHUD]) { + DisplayDHudMessage(activatorId, mode, "RT_DHUD_REVIVE", playerId); + DisplayDHudMessage(playerId, mode, "RT_DHUD_REVIVE2", activatorId); } - if(g_eCvars[REVIVE_GLOW][0] != EOS) - rg_set_rendering(iEnt, kRenderFxGlowShell, g_eGlowColors[REVIVE_COLOR], kRenderNormal, 30.0); + if(Cvars[REVIVE_GLOW][0] != EOS) + rg_set_rendering(entId, kRenderFxGlowShell, GlowColors[REVIVE_COLOR], kRenderNormal, 30.0); } case MODE_PLANT: { - if(g_eCvars[NOTIFY_DHUD]) - DisplayDHudMessage(iActivator, eMode, "RT_DHUD_PLANTING", iPlayer); + if(Cvars[NOTIFY_DHUD]) + DisplayDHudMessage(activatorId, mode, "RT_DHUD_PLANTING", playerId); - if(g_eCvars[PLANTING_GLOW][0] != EOS) - rg_set_rendering(iEnt, kRenderFxGlowShell, g_eGlowColors[PLANTING_COLOR], kRenderNormal, 30.0); + if(Cvars[PLANTING_GLOW][0] != EOS) + rg_set_rendering(entId, kRenderFxGlowShell, GlowColors[PLANTING_COLOR], kRenderNormal, 30.0); } } } -public rt_revive_cancelled(const iEnt, const iPlayer, const iActivator, const Modes:eMode) { - if(g_eCvars[NOTIFY_DHUD]) { - if(iActivator != RT_NULLENT) - ClearDHudMessages(iActivator); +public rt_revive_cancelled(const entId, const playerId, const activatorId, const Modes:mode) { + if(Cvars[NOTIFY_DHUD]) { + if(activatorId != RT_NULLENT) + ClearDHudMessages(activatorId); - if(iPlayer != RT_NULLENT) - ClearDHudMessages(iPlayer); + if(playerId != RT_NULLENT) + ClearDHudMessages(playerId); } - switch(eMode) - { - case MODE_REVIVE: - { - if(g_eCvars[REVIVE_GLOW][0] != EOS) - rg_set_rendering(iEnt); + switch(mode) { + case MODE_REVIVE: { + if(Cvars[REVIVE_GLOW][0] != EOS) + rg_set_rendering(entId); } - case MODE_PLANT: - { - if(g_eCvars[PLANTING_GLOW][0] != EOS) - rg_set_rendering(iEnt); + case MODE_PLANT: { + if(Cvars[PLANTING_GLOW][0] != EOS) + rg_set_rendering(entId); } } } -public rt_revive_end(const iEnt, const iPlayer, const iActivator, const Modes:eMode) { - if(g_eCvars[NOTIFY_DHUD]) { - ClearDHudMessages(iActivator); - ClearDHudMessages(iPlayer); +public rt_revive_end(const entId, const playerId, const activatorId, const Modes:mode) { + if(Cvars[NOTIFY_DHUD]) { + ClearDHudMessages(activatorId); + ClearDHudMessages(playerId); } - switch(eMode) - { - case MODE_REVIVE: - { - static iMode; - iMode = get_entvar(iEnt, var_iuser3); + switch(mode) { + case MODE_REVIVE: { + static entMode; + entMode = get_entvar(entId, var_iuser3); - if(any:iMode != MODE_PLANT && g_eCvars[REVIVE_GLOW][0] != EOS) - rg_set_rendering(iEnt); + if(any:entMode != MODE_PLANT && Cvars[REVIVE_GLOW][0] != EOS) + rg_set_rendering(entId); } - case MODE_PLANT: - { - if(g_eCvars[PLANTING_GLOW][0] != EOS) - rg_set_rendering(iEnt); + case MODE_PLANT: { + if(Cvars[PLANTING_GLOW][0] != EOS) + rg_set_rendering(entId); } } } -public rt_creating_corpse_end(const iEnt, const iPlayer, const Float:fVecOrigin[3]) { - if(g_eCvars[CORPSE_SPRITE][0] == EOS) +public rt_creating_corpse_end(const entId, const playerId, const Float:vecOrigin[3]) { + if(Cvars[CORPSE_SPRITE][0] == EOS) return; - new iEntSprite = rg_create_entity("info_target"); + new entSprite = rg_create_entity("info_target"); - engfunc(EngFunc_SetOrigin, iEntSprite, fVecOrigin); - engfunc(EngFunc_SetModel, iEntSprite, g_eCvars[CORPSE_SPRITE]); + engfunc(EngFunc_SetOrigin, entSprite, vecOrigin); + engfunc(EngFunc_SetModel, entSprite, Cvars[CORPSE_SPRITE]); - set_entvar(iEntSprite, var_classname, CORPSE_SPRITE_CLASSNAME); - set_entvar(iEntSprite, var_owner, iPlayer); - set_entvar(iEntSprite, var_iuser1, iEnt); - set_entvar(iEntSprite, var_team, TeamName:get_entvar(iEnt, var_team)); - set_entvar(iEntSprite, var_scale, g_eCvars[SPRITE_SCALE]); - set_entvar(iEntSprite, var_renderfx, kRenderFxNone); - set_entvar(iEntSprite, var_rendercolor, Float:{255.0, 255.0, 255.0}); - set_entvar(iEntSprite, var_rendermode, kRenderTransAlpha); - set_entvar(iEntSprite, var_renderamt, 255.0); - set_entvar(iEntSprite, var_nextthink, get_gametime() + 0.1); + set_entvar(entSprite, var_classname, CORPSE_SPRITE_CLASSNAME); + set_entvar(entSprite, var_owner, playerId); + set_entvar(entSprite, var_iuser1, entId); + set_entvar(entSprite, var_team, TeamName:get_entvar(entId, var_team)); + set_entvar(entSprite, var_scale, Cvars[SPRITE_SCALE]); + set_entvar(entSprite, var_renderfx, kRenderFxNone); + set_entvar(entSprite, var_rendercolor, Float:{255.0, 255.0, 255.0}); + set_entvar(entSprite, var_rendermode, kRenderTransAlpha); + set_entvar(entSprite, var_renderamt, 255.0); + set_entvar(entSprite, var_nextthink, get_gametime() + 0.1); - SetThink(iEntSprite, "CorpseSprite_Think"); + SetThink(entSprite, "CorpseSprite_Think"); } -public CorpseSprite_Think(const iEnt) { - new iHostEnt = get_entvar(iEnt, var_iuser1); +public CorpseSprite_Think(const entId) { + new hostEnt = get_entvar(entId, var_iuser1); - if(is_nullent(iHostEnt) || !FClassnameIs(iHostEnt, DEAD_BODY_CLASSNAME)) { - RemoveCorpses(get_entvar(iEnt, var_owner), CORPSE_SPRITE_CLASSNAME); + if(is_nullent(hostEnt) || !FClassnameIs(hostEnt, DEAD_BODY_CLASSNAME)) { + RemoveCorpses(get_entvar(entId, var_owner), CORPSE_SPRITE_CLASSNAME); return; } - set_entvar(iEnt, var_nextthink, get_gametime() + 0.1); + set_entvar(entId, var_nextthink, get_gametime() + 0.1); } -stock rg_set_rendering(const id, const fx = kRenderFxNone, const Float:fColor[3] = {0.0, 0.0, 0.0}, const render = kRenderNormal, const Float:fAmount = 0.0) -{ +stock rg_set_rendering(const id, const fx = kRenderFxNone, const Float:color[3] = {0.0, 0.0, 0.0}, const render = kRenderNormal, const Float:amount = 0.0) { set_entvar(id, var_renderfx, fx); - set_entvar(id, var_rendercolor, fColor); + set_entvar(id, var_rendercolor, color); set_entvar(id, var_rendermode, render); - set_entvar(id, var_renderamt, fAmount); + set_entvar(id, var_renderamt, amount); } -stock Float:parseHEXColor(const value[]) -{ +stock Float:parseHEXColor(const value[]) { new Float:result[3]; if(value[0] != '#' && strlen(value) != 7) @@ -243,15 +236,12 @@ stock Float:parseHEXColor(const value[]) return result; } -stock Float:parse16bit(ch1, ch2) -{ +stock Float:parse16bit(ch1, ch2) { return float(parseHex(ch1) * 16 + parseHex(ch2)); } -stock parseHex(const ch) -{ - switch(ch) - { +stock parseHex(const ch) { + switch(ch) { case '0'..'9': return (ch - '0'); case 'a'..'f': return (10 + ch - 'a'); case 'A'..'F': return (10 + ch - 'A'); @@ -260,19 +250,19 @@ stock parseHex(const ch) return 0; } -stock DisplayDHudMessage(const iPlayer, const Modes:eMode, any:...) { - new szMessage[128]; - SetGlobalTransTarget(iPlayer); - vformat(szMessage, charsmax(szMessage), "%l", 3); +stock DisplayDHudMessage(const playerId, const Modes:mode, any:...) { + new message[128]; + SetGlobalTransTarget(playerId); + vformat(message, charsmax(message), "%l", 3); - set_dhudmessage(g_eDHudData[eMode][COLOR_R], g_eDHudData[eMode][COLOR_G], g_eDHudData[eMode][COLOR_B], - g_eDHudData[eMode][COORD_X], g_eDHudData[eMode][COORD_Y], .holdtime = g_fTime); - show_dhudmessage(iPlayer, szMessage); + set_dhudmessage(DHudData[mode][COLOR_R], DHudData[mode][COLOR_G], DHudData[mode][COLOR_B], + DHudData[mode][COORD_X], DHudData[mode][COORD_Y], .holdtime = Time); + show_dhudmessage(playerId, message); } -stock ClearDHudMessages(const iPlayer, const iChannel = 8) { - for(new i; i < iChannel; i++) - show_dhudmessage(iPlayer, ""); +stock ClearDHudMessages(const playerId, const channel = 8) { + for(new i; i < channel; i++) + show_dhudmessage(playerId, ""); } public CreateCvars() { @@ -285,7 +275,7 @@ public CreateCvars() { 0.0, true, 1.0), - g_eCvars[SPECTATOR] + Cvars[SPECTATOR] ); bind_pcvar_num(create_cvar( "rt_notify_dhud", @@ -296,47 +286,47 @@ public CreateCvars() { 0.0, true, 1.0), - g_eCvars[NOTIFY_DHUD] + Cvars[NOTIFY_DHUD] ); bind_pcvar_string(create_cvar( "rt_revive_dhud_colors", "0 255 0", FCVAR_NONE, "DHUD's color at resurrection"), - g_eCvars[REVIVE_COLORS], - charsmax(g_eCvars[REVIVE_COLORS]) + Cvars[REVIVE_COLORS], + charsmax(Cvars[REVIVE_COLORS]) ); bind_pcvar_string(create_cvar( "rt_revive_dhud_coords", "-1.0 0.8", FCVAR_NONE, "DHUD's coordinates at resurrection"), - g_eCvars[REVIVE_COORDS], - charsmax(g_eCvars[REVIVE_COORDS]) + Cvars[REVIVE_COORDS], + charsmax(Cvars[REVIVE_COORDS]) ); bind_pcvar_string(create_cvar( "rt_planting_dhud_colors", "255 0 0", FCVAR_NONE, "DHUD's color at planting"), - g_eCvars[PLANTING_COLORS], - charsmax(g_eCvars[PLANTING_COLORS]) + Cvars[PLANTING_COLORS], + charsmax(Cvars[PLANTING_COLORS]) ); bind_pcvar_string(create_cvar( "rt_planting_dhud_coords", "-1.0 0.8", FCVAR_NONE, "DHUD's coordinates at planting"), - g_eCvars[PLANTING_COORDS], - charsmax(g_eCvars[PLANTING_COORDS]) + Cvars[PLANTING_COORDS], + charsmax(Cvars[PLANTING_COORDS]) ); bind_pcvar_string(create_cvar( "rt_corpse_sprite", "sprites/rt/corpse_sprite2.spr", FCVAR_NONE, "Resurrection sprite over a corpse. To disable the function, leave the cvar empty"), - g_eCvars[CORPSE_SPRITE], - charsmax(g_eCvars[CORPSE_SPRITE]) + Cvars[CORPSE_SPRITE], + charsmax(Cvars[CORPSE_SPRITE]) ); bind_pcvar_float(create_cvar( "rt_sprite_scale", @@ -347,22 +337,22 @@ public CreateCvars() { 0.1, true, 0.5), - g_eCvars[SPRITE_SCALE] + Cvars[SPRITE_SCALE] ); bind_pcvar_string(create_cvar( "rt_revive_glow", "#5da130", FCVAR_NONE, "The color of the corpse being resurrected(HEX)"), - g_eCvars[REVIVE_GLOW], - charsmax(g_eCvars[REVIVE_GLOW]) + Cvars[REVIVE_GLOW], + charsmax(Cvars[REVIVE_GLOW]) ); bind_pcvar_string(create_cvar( "rt_planting_glow", "#9b2d30", FCVAR_NONE, "The color of the corpse being planted(HEX)"), - g_eCvars[PLANTING_GLOW], - charsmax(g_eCvars[PLANTING_GLOW]) + Cvars[PLANTING_GLOW], + charsmax(Cvars[PLANTING_GLOW]) ); } \ No newline at end of file diff --git a/addons/amxmodx/scripting/rt_planting.sma b/addons/amxmodx/scripting/rt_planting.sma index 3cc405e..06d2c6f 100644 --- a/addons/amxmodx/scripting/rt_planting.sma +++ b/addons/amxmodx/scripting/rt_planting.sma @@ -3,8 +3,9 @@ #include #include -public stock const PLUGIN[] = "Revive Teammates: Planting"; -public stock const CFG_FILE[] = "addons/amxmodx/configs/rt_configs/rt_planting.cfg"; +#define PLUGIN_NAME "Revive Teammates: Planting" + +#define CFG_FILE "addons/amxmodx/configs/rt_configs/rt_planting.cfg" enum CVARS { Float:DAMAGE, @@ -12,20 +13,20 @@ enum CVARS { MAX_PLANTING }; -new g_eCvars[CVARS]; +new Cvars[CVARS]; -enum _:PlayerData { +enum _:PLAYER_DATA { PLANTING_COUNT }; -new g_ePlayerData[MAX_PLAYERS + 1][PlayerData]; +new PlayerData[MAX_PLAYERS + 1][PLAYER_DATA]; -new g_szModels[3]; +new Models[3]; public plugin_precache() { - g_szModels[0] = precache_model("sprites/zerogxplode.spr"); - g_szModels[1] = precache_model("sprites/eexplo.spr"); - g_szModels[2] = precache_model("sprites/fexplo.spr"); + Models[0] = precache_model("sprites/zerogxplode.spr"); + Models[1] = precache_model("sprites/eexplo.spr"); + Models[2] = precache_model("sprites/fexplo.spr"); CreateCvars(); @@ -34,32 +35,32 @@ public plugin_precache() { } public plugin_init() { - register_plugin(PLUGIN, VERSION, AUTHORS); + register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHORS); - register_dictionary("rt_library.txt"); + register_dictionary(PLUGIN_DICTIONARY); RegisterHookChain(RG_CSGameRules_CleanUpMap, "CSGameRules_CleanUpMap_Post", true); } public CSGameRules_CleanUpMap_Post() { - arrayset(g_ePlayerData[0][_:0], 0, sizeof(g_ePlayerData) * sizeof(g_ePlayerData[])); + arrayset(PlayerData[0][_:0], 0, sizeof(PlayerData) * sizeof(PlayerData[])); } -public client_disconnected(iPlayer) { - g_ePlayerData[iPlayer][PLANTING_COUNT] = 0; +public client_disconnected(playerId) { + PlayerData[playerId][PLANTING_COUNT] = 0; } -public rt_revive_start(const iEnt, const iPlayer, const iActivator, const Modes:eMode) { - new Modes:iMode = Modes:get_entvar(iEnt, var_iuser3); +public rt_revive_start(const entId, const playerId, const activatorId, const Modes:mode) { + new Modes:entMode = Modes:get_entvar(entId, var_iuser3); - if(eMode == MODE_PLANT) { - if(g_ePlayerData[iActivator][PLANTING_COUNT] >= g_eCvars[MAX_PLANTING]) { - NotifyClient(iActivator, print_team_red, "RT_PLANTING_COUNT"); + if(mode == MODE_PLANT) { + if(PlayerData[activatorId][PLANTING_COUNT] >= Cvars[MAX_PLANTING]) { + NotifyClient(activatorId, print_team_red, "RT_PLANTING_COUNT"); return PLUGIN_HANDLED; } - if(iMode == MODE_PLANT) { - NotifyClient(iActivator, print_team_red, "RT_IS_PLANTED", iPlayer); + if(entMode == MODE_PLANT) { + NotifyClient(activatorId, print_team_red, "RT_IS_PLANTED", playerId); return PLUGIN_HANDLED; } } @@ -67,77 +68,77 @@ public rt_revive_start(const iEnt, const iPlayer, const iActivator, const Modes: return PLUGIN_CONTINUE; } -public rt_revive_end(const iEnt, const iPlayer, const iActivator, const Modes:eMode) { - switch(eMode) { +public rt_revive_end(const entId, const playerId, const activatorId, const Modes:mode) { + switch(mode) { case MODE_REVIVE: { - new Modes:iMode = Modes:get_entvar(iEnt, var_iuser3); + new Modes:entMode = Modes:get_entvar(entId, var_iuser3); - if(iMode == MODE_PLANT) { - new Float:fVecOrigin[3]; - get_entvar(iActivator, var_origin, fVecOrigin); - MakeExplosionEffects(fVecOrigin); + if(entMode == MODE_PLANT) { + new Float:vecOrigin[3]; + get_entvar(activatorId, var_origin, vecOrigin); + MakeExplosionEffects(vecOrigin); - new iPlanter = get_entvar(iEnt, var_iuser4); + new planter = get_entvar(entId, var_iuser4); - for(new iVictim = 1, Float:fReduceDamage, Float:fVecEnd[3]; iVictim <= MaxClients; iVictim++) { - if(!is_user_alive(iVictim) || TeamName:get_member(iVictim, m_iTeam) != TeamName:get_member(iPlayer, m_iTeam)) + for(new victim = 1, Float:reduceDamage, Float:vecEnd[3]; victim <= MaxClients; victim++) { + if(!is_user_alive(victim) || TeamName:get_member(victim, m_iTeam) != TeamName:get_member(playerId, m_iTeam)) continue; - get_entvar(iVictim, var_origin, fVecEnd); + get_entvar(victim, var_origin, vecEnd); - if((fReduceDamage = (g_eCvars[DAMAGE] - vector_distance(fVecOrigin, fVecEnd) * (g_eCvars[DAMAGE] / g_eCvars[RADIUS]))) < 1.0) + if((reduceDamage = (Cvars[DAMAGE] - vector_distance(vecOrigin, vecEnd) * (Cvars[DAMAGE] / Cvars[RADIUS]))) < 1.0) continue; - set_member(iVictim, m_LastHitGroup, HITGROUP_GENERIC); + set_member(victim, m_LastHitGroup, HITGROUP_GENERIC); - ExecuteHamB(Ham_TakeDamage, iVictim, iEnt, iPlanter, fReduceDamage, DMG_GRENADE | DMG_ALWAYSGIB); + ExecuteHamB(Ham_TakeDamage, victim, entId, planter, reduceDamage, DMG_GRENADE | DMG_ALWAYSGIB); } - RemoveCorpses(iPlayer, DEAD_BODY_CLASSNAME); + RemoveCorpses(playerId, DEAD_BODY_CLASSNAME); } } case MODE_PLANT: { - NotifyClient(iActivator, print_team_blue, "RT_PLANTING", iPlayer); + NotifyClient(activatorId, print_team_blue, "RT_PLANTING", playerId); - g_ePlayerData[iActivator][PLANTING_COUNT]++; + PlayerData[activatorId][PLANTING_COUNT]++; - set_entvar(iEnt, var_iuser1, 0); - set_entvar(iEnt, var_iuser3, eMode); - set_entvar(iEnt, var_iuser4, iActivator); + set_entvar(entId, var_iuser1, 0); + set_entvar(entId, var_iuser3, mode); + set_entvar(entId, var_iuser4, activatorId); } } } -stock MakeExplosionEffects(const Float:fVecOrigin[3]) { - message_begin_f(MSG_PAS, SVC_TEMPENTITY, fVecOrigin); +stock MakeExplosionEffects(const Float:vecOrigin[3]) { + message_begin_f(MSG_PAS, SVC_TEMPENTITY, vecOrigin); write_byte(TE_EXPLOSION); - write_coord_f(fVecOrigin[0]); - write_coord_f(fVecOrigin[1]); - write_coord_f(fVecOrigin[2] + 20.0); - write_short(g_szModels[2]); + write_coord_f(vecOrigin[0]); + write_coord_f(vecOrigin[1]); + write_coord_f(vecOrigin[2] + 20.0); + write_short(Models[2]); write_byte(25); write_byte(30); write_byte(TE_EXPLFLAG_NONE); message_end(); - message_begin_f(MSG_PAS, SVC_TEMPENTITY, fVecOrigin); + message_begin_f(MSG_PAS, SVC_TEMPENTITY, vecOrigin); write_byte(TE_EXPLOSION); - write_coord_f(fVecOrigin[0] + random_float(-64.0, 64.0)); - write_coord_f(fVecOrigin[1] + random_float(-64.0, 64.0)); - write_coord_f(fVecOrigin[2] + random_float(30.0, 35.0)); - write_short(g_szModels[1]); + write_coord_f(vecOrigin[0] + random_float(-64.0, 64.0)); + write_coord_f(vecOrigin[1] + random_float(-64.0, 64.0)); + write_coord_f(vecOrigin[2] + random_float(30.0, 35.0)); + write_short(Models[1]); write_byte(30); write_byte(30); write_byte(TE_EXPLFLAG_NONE); message_end(); for(new i; i < 3; i++) { - message_begin_f(MSG_PAS, SVC_TEMPENTITY, fVecOrigin); + message_begin_f(MSG_PAS, SVC_TEMPENTITY, vecOrigin); write_byte(TE_SPRITE); - write_coord_f(fVecOrigin[0] + random_float(-256.0, 256.0)); - write_coord_f(fVecOrigin[1] + random_float(-256.0, 256.0)); - write_coord_f(fVecOrigin[2] + random_float(-10.0, 10.0)); - write_short(g_szModels[i]); + write_coord_f(vecOrigin[0] + random_float(-256.0, 256.0)); + write_coord_f(vecOrigin[1] + random_float(-256.0, 256.0)); + write_coord_f(vecOrigin[2] + random_float(-10.0, 10.0)); + write_short(Models[i]); write_byte(30); write_byte(150); message_end(); @@ -152,7 +153,7 @@ public CreateCvars() { "Explosion damage", true, 1.0), - g_eCvars[DAMAGE] + Cvars[DAMAGE] ); bind_pcvar_float(create_cvar( "rt_explosion_radius", @@ -161,7 +162,7 @@ public CreateCvars() { "Explosion radius", true, 1.0), - g_eCvars[RADIUS] + Cvars[RADIUS] ); bind_pcvar_num(create_cvar( "rt_max_planting", @@ -170,6 +171,6 @@ public CreateCvars() { "Maximum number of planting corpses per round", true, 1.0), - g_eCvars[MAX_PLANTING] + Cvars[MAX_PLANTING] ); } \ No newline at end of file diff --git a/addons/amxmodx/scripting/rt_restrictions.sma b/addons/amxmodx/scripting/rt_restrictions.sma index 8e75e7d..4d16385 100644 --- a/addons/amxmodx/scripting/rt_restrictions.sma +++ b/addons/amxmodx/scripting/rt_restrictions.sma @@ -2,10 +2,11 @@ #include #include -public stock const PLUGIN[] = "Revive Teammates: Restrictions"; -public stock const CFG_FILE[] = "addons/amxmodx/configs/rt_configs/rt_restrictions.cfg"; +#define PLUGIN_NAME "Revive Teammates: Restrictions" -#define m_iCurrentRound (get_member_game(m_iTotalRoundsPlayed) + 1) +#define CFG_FILE "addons/amxmodx/configs/rt_configs/rt_restrictions.cfg" + +#define CurrentRound (get_member_game(m_iTotalRoundsPlayed) + 1) enum CVARS { ACCESS[32], @@ -24,15 +25,15 @@ enum CVARS { FORCE_FWD_MODE }; -new g_eCvars[CVARS]; +new Cvars[CVARS]; -enum _:PlayerData { +enum _:PLAYER_DATA { REVIVE_COUNT }; const PREVENT_FLAGS = (PLAYER_PREVENT_CLIMB|PLAYER_PREVENT_JUMP); -new g_ePlayerData[MAX_PLAYERS + 1][PlayerData]; +new PlayerData[MAX_PLAYERS + 1][PLAYER_DATA]; public plugin_precache() { CreateCvars(); @@ -42,132 +43,132 @@ public plugin_precache() { } public plugin_init() { - register_plugin(PLUGIN, VERSION, AUTHORS); + register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHORS); - register_dictionary("rt_library.txt"); + register_dictionary(PLUGIN_DICTIONARY); RegisterHookChain(RG_CSGameRules_CleanUpMap, "CSGameRules_CleanUpMap_Post", true); } public plugin_cfg() { - if(g_eCvars[NO_MOVE] == 1) + if(Cvars[NO_MOVE] == 1) RegisterHookChain(RG_CBasePlayer_PreThink, "CBasePlayer_PreThink_Pre"); } public CSGameRules_CleanUpMap_Post() { - arrayset(g_ePlayerData[0][_:0], 0, sizeof(g_ePlayerData) * sizeof(g_ePlayerData[])); + arrayset(PlayerData[0][_:0], 0, sizeof(PlayerData) * sizeof(PlayerData[])); } -public client_disconnected(iPlayer) { - g_ePlayerData[iPlayer][REVIVE_COUNT] = 0; +public client_disconnected(playerId) { + PlayerData[playerId][REVIVE_COUNT] = 0; } -public CBasePlayer_PreThink_Pre(const iPlayer) { - if(is_user_alive(iPlayer) && (get_entvar(iPlayer, var_iuser3) & PREVENT_FLAGS)) - set_entvar(iPlayer, var_maxspeed, 1.0); +public CBasePlayer_PreThink_Pre(const playerId) { + if(is_user_alive(playerId) && (get_entvar(playerId, var_iuser3) & PREVENT_FLAGS)) + set_entvar(playerId, var_maxspeed, 1.0); } -public rt_revive_start(const iEnt, const iPlayer, const iActivator, const Modes:eMode) { - if( g_eCvars[ACCESS][0] && !(get_user_flags(iActivator) & read_flags(g_eCvars[ACCESS])) ) { - NotifyClient(iActivator, print_team_red, "RT_NO_ACCESS"); +public rt_revive_start(const entId, const playerId, const activatorId, const Modes:mode) { + if( Cvars[ACCESS][0] && !(get_user_flags(activatorId) & read_flags(Cvars[ACCESS])) ) { + NotifyClient(activatorId, print_team_red, "RT_NO_ACCESS"); return PLUGIN_HANDLED; } - if(m_iCurrentRound < g_eCvars[MIN_ROUND]) { - NotifyClient(iActivator, print_team_red, "RT_MIN_ROUND", g_eCvars[MIN_ROUND]); + if(CurrentRound < Cvars[MIN_ROUND]) { + NotifyClient(activatorId, print_team_red, "RT_MIN_ROUND", Cvars[MIN_ROUND]); return PLUGIN_HANDLED; } - if(g_eCvars[BOMB] && rg_is_bomb_planted()) { - NotifyClient(iActivator, print_team_red, "RT_BOMB"); + if(Cvars[BOMB] && rg_is_bomb_planted()) { + NotifyClient(activatorId, print_team_red, "RT_BOMB"); return PLUGIN_HANDLED; } - if(g_eCvars[DUEL] && rg_users_count(false)) { - NotifyClient(iActivator, print_team_red, "RT_DUEL"); + if(Cvars[DUEL] && rg_users_count(false)) { + NotifyClient(activatorId, print_team_red, "RT_DUEL"); return PLUGIN_HANDLED; } - if(g_eCvars[SURVIVOR] && rg_users_count(true)) { - NotifyClient(iActivator, print_team_red, "RT_SURVIVOR"); + if(Cvars[SURVIVOR] && rg_users_count(true)) { + NotifyClient(activatorId, print_team_red, "RT_SURVIVOR"); return PLUGIN_HANDLED; } - if(g_eCvars[REMAINING_TIME] && rg_get_remaining_time() <= g_eCvars[REMAINING_TIME]) { - NotifyClient(iActivator, print_team_red, "RT_REMAINING_TIME"); + if(Cvars[REMAINING_TIME] && rg_get_remaining_time() <= Cvars[REMAINING_TIME]) { + NotifyClient(activatorId, print_team_red, "RT_REMAINING_TIME"); return PLUGIN_HANDLED; } - if(g_eCvars[WIN_DIFF] && (rg_get_team_wins_row(g_eCvars[WIN_DIFF]) == TeamName:get_member(iActivator, m_iTeam))) { - NotifyClient(iActivator, print_team_red, "RT_WINS_DOMINATION"); + if(Cvars[WIN_DIFF] && (rg_get_team_wins_row(Cvars[WIN_DIFF]) == TeamName:get_member(activatorId, m_iTeam))) { + NotifyClient(activatorId, print_team_red, "RT_WINS_DOMINATION"); return PLUGIN_HANDLED; } - switch(eMode) { + switch(mode) { case MODE_REVIVE: { - if(g_ePlayerData[iActivator][REVIVE_COUNT] >= g_eCvars[MAX_REVIVES]) { - NotifyClient(iActivator, print_team_red, "RT_REVIVE_COUNT"); + if(PlayerData[activatorId][REVIVE_COUNT] >= Cvars[MAX_REVIVES]) { + NotifyClient(activatorId, print_team_red, "RT_REVIVE_COUNT"); return PLUGIN_HANDLED; } - if(get_member(iPlayer, m_iNumSpawns) > g_eCvars[MAX_SPAWNS]) { - NotifyClient(iActivator, print_team_red, "RT_MAX_SPAWNS"); + if(get_member(playerId, m_iNumSpawns) > Cvars[MAX_SPAWNS]) { + NotifyClient(activatorId, print_team_red, "RT_MAX_SPAWNS"); return PLUGIN_HANDLED; } - if(get_member(iActivator, m_iAccount) < g_eCvars[REVIVE_COST]) { - NotifyClient(iActivator, print_team_red, "RT_NO_MONEY"); + if(get_member(activatorId, m_iAccount) < Cvars[REVIVE_COST]) { + NotifyClient(activatorId, print_team_red, "RT_NO_MONEY"); return PLUGIN_HANDLED; } } case MODE_PLANT: { - if(get_member(iActivator, m_iAccount) < g_eCvars[PLANTING_COST]) { - NotifyClient(iActivator, print_team_red, "RT_NO_MONEY"); + if(get_member(activatorId, m_iAccount) < Cvars[PLANTING_COST]) { + NotifyClient(activatorId, print_team_red, "RT_NO_MONEY"); return PLUGIN_HANDLED; } } } - if(g_eCvars[NO_MOVE] == 1) { - set_entvar(iActivator, var_iuser3, get_entvar(iActivator, var_iuser3) | PREVENT_FLAGS); - set_entvar(iActivator, var_velocity, NULL_VECTOR); - set_entvar(iActivator, var_maxspeed, 1.0); + if(Cvars[NO_MOVE] == 1) { + set_entvar(activatorId, var_iuser3, get_entvar(activatorId, var_iuser3) | PREVENT_FLAGS); + set_entvar(activatorId, var_velocity, NULL_VECTOR); + set_entvar(activatorId, var_maxspeed, 1.0); } - if(g_eCvars[NO_FIRE]) - set_member(iActivator, m_bIsDefusing, true); + if(Cvars[NO_FIRE]) + set_member(activatorId, m_bIsDefusing, true); return PLUGIN_CONTINUE; } -public rt_revive_loop_pre(const iEnt, const iPlayer, const iActivator, const Float:fTimer, Modes:eMode) { - if(g_eCvars[BOMB] && rg_is_bomb_planted()) { - NotifyClient(iActivator, print_team_red, "RT_BOMB"); +public rt_revive_loop_pre(const entId, const playerId, const activatorId, const Float:timer, Modes:mode) { + if(Cvars[BOMB] && rg_is_bomb_planted()) { + NotifyClient(activatorId, print_team_red, "RT_BOMB"); return PLUGIN_HANDLED; } - if(g_eCvars[DUEL] && rg_users_count(false)) { - NotifyClient(iActivator, print_team_red, "RT_DUEL"); + if(Cvars[DUEL] && rg_users_count(false)) { + NotifyClient(activatorId, print_team_red, "RT_DUEL"); return PLUGIN_HANDLED; } - if(g_eCvars[SURVIVOR] && rg_users_count(true)) { - NotifyClient(iActivator, print_team_red, "RT_SURVIVOR"); + if(Cvars[SURVIVOR] && rg_users_count(true)) { + NotifyClient(activatorId, print_team_red, "RT_SURVIVOR"); return PLUGIN_HANDLED; } - if(g_eCvars[REMAINING_TIME] && rg_get_remaining_time() <= g_eCvars[REMAINING_TIME]) { - NotifyClient(iActivator, print_team_red, "RT_REMAINING_TIME"); + if(Cvars[REMAINING_TIME] && rg_get_remaining_time() <= Cvars[REMAINING_TIME]) { + NotifyClient(activatorId, print_team_red, "RT_REMAINING_TIME"); return PLUGIN_HANDLED; } - if(g_eCvars[NO_MOVE] == 2) { - new Float:fVecPlOrigin[3], Float:fVecEntOrigin[3]; - get_entvar(iActivator, var_origin, fVecPlOrigin); - get_entvar(iEnt, var_vuser4, fVecEntOrigin); + if(Cvars[NO_MOVE] == 2) { + new Float:vecPlOrigin[3], Float:vecEntOrigin[3]; + get_entvar(activatorId, var_origin, vecPlOrigin); + get_entvar(entId, var_vuser4, vecEntOrigin); - if(vector_distance(fVecPlOrigin, fVecEntOrigin) > Float:get_entvar(iEnt, var_fuser2)) { - NotifyClient(iActivator, print_team_red, "RT_MAX_DISTANCE"); + if(vector_distance(vecPlOrigin, vecEntOrigin) > Float:get_entvar(entId, var_fuser2)) { + NotifyClient(activatorId, print_team_red, "RT_MAX_DISTANCE"); return PLUGIN_HANDLED; } } @@ -175,55 +176,57 @@ public rt_revive_loop_pre(const iEnt, const iPlayer, const iActivator, const Flo return PLUGIN_CONTINUE; } -public rt_revive_loop_post(const iEnt, const iPlayer, const iActivator, const Float:fTimer, Modes:eMode) { - if(g_eCvars[FORCE_FWD_MODE] && g_eCvars[NO_MOVE] == 1) - set_entvar(iActivator, var_maxspeed, 1.0); +public rt_revive_loop_post(const entId, const playerId, const activatorId, const Float:timer, Modes:mode) { + if(Cvars[FORCE_FWD_MODE] && Cvars[NO_MOVE] == 1) + set_entvar(activatorId, var_maxspeed, 1.0); } -public rt_revive_cancelled(const iEnt, const iPlayer, const iActivator, const Modes:eMode) { - if(iActivator == RT_NULLENT) +public rt_revive_cancelled(const entId, const playerId, const activatorId, const Modes:mode) { + if(activatorId == RT_NULLENT) return; - if(g_eCvars[NO_MOVE] == 1) { - set_entvar(iActivator, var_iuser3, get_entvar(iActivator, var_iuser3) & ~PREVENT_FLAGS); - rg_reset_maxspeed(iActivator); + if(Cvars[NO_MOVE] == 1) { + set_entvar(activatorId, var_iuser3, get_entvar(activatorId, var_iuser3) & ~PREVENT_FLAGS); + rg_reset_maxspeed(activatorId); } - if(g_eCvars[NO_FIRE]) - set_member(iActivator, m_bIsDefusing, false); + if(Cvars[NO_FIRE]) + set_member(activatorId, m_bIsDefusing, false); } -public rt_revive_end(const iEnt, const iPlayer, const iActivator, const Modes:eMode) { - switch(eMode) { +public rt_revive_end(const entId, const playerId, const activatorId, const Modes:mode) { + switch(mode) { case MODE_REVIVE: { - new Modes:iMode = Modes:get_entvar(iEnt, var_iuser3); + new Modes:entMode = Modes:get_entvar(entId, var_iuser3); - if(iMode != MODE_PLANT) { - g_ePlayerData[iActivator][REVIVE_COUNT]++; + if(entMode != MODE_PLANT) { + PlayerData[activatorId][REVIVE_COUNT]++; - rg_add_account(iActivator, -g_eCvars[REVIVE_COST]); + rg_add_account(activatorId, -Cvars[REVIVE_COST]); } } - case MODE_PLANT: { rg_add_account(iActivator, -g_eCvars[PLANTING_COST]); } + case MODE_PLANT: { + rg_add_account(activatorId, -Cvars[PLANTING_COST]); + } } - if(g_eCvars[NO_MOVE] == 1) { - set_entvar(iActivator, var_iuser3, get_entvar(iActivator, var_iuser3) & ~PREVENT_FLAGS); - rg_reset_maxspeed(iActivator); + if(Cvars[NO_MOVE] == 1) { + set_entvar(activatorId, var_iuser3, get_entvar(activatorId, var_iuser3) & ~PREVENT_FLAGS); + rg_reset_maxspeed(activatorId); } - if(g_eCvars[NO_FIRE]) - set_member(iActivator, m_bIsDefusing, false); + if(Cvars[NO_FIRE]) + set_member(activatorId, m_bIsDefusing, false); } -stock rg_users_count(const bool:bMode1x1 = false) { - new iAliveTs, iAliveCTs; - rg_initialize_player_counts(iAliveTs, iAliveCTs); +stock rg_users_count(const bool:mode1x1 = false) { + new aliveTTs, aliveCTs; + rg_initialize_player_counts(aliveTTs, aliveCTs); - if(!bMode1x1 && (iAliveTs == 1 && iAliveCTs == 1)) + if(!mode1x1 && (aliveTTs == 1 && aliveCTs == 1)) return 1; - if(bMode1x1 && (iAliveTs == 1 || iAliveCTs == 1)) + if(mode1x1 && (aliveTTs == 1 || aliveCTs == 1)) return 1; return 0; @@ -233,11 +236,11 @@ stock Float:rg_get_remaining_time() { return (float(get_member_game(m_iRoundTimeSecs)) - get_gametime() + Float:get_member_game(m_fRoundStartTimeReal)); } -stock TeamName:rg_get_team_wins_row(const iWins) { - if(get_member_game(m_iNumConsecutiveCTLoses) >= iWins) +stock TeamName:rg_get_team_wins_row(const wins) { + if(get_member_game(m_iNumConsecutiveCTLoses) >= wins) return TEAM_TERRORIST; - if(get_member_game(m_iNumConsecutiveTerroristLoses) >= iWins) + if(get_member_game(m_iNumConsecutiveTerroristLoses) >= wins) return TEAM_CT; return TEAM_UNASSIGNED; @@ -249,8 +252,8 @@ public CreateCvars() { "", FCVAR_NONE, "Access flags for resurrection/planting"), - g_eCvars[ACCESS], - charsmax(g_eCvars[ACCESS]) + Cvars[ACCESS], + charsmax(Cvars[ACCESS]) ); bind_pcvar_num(create_cvar( "rt_max_revives", @@ -259,7 +262,7 @@ public CreateCvars() { "Maximum number of resurrections per round", true, 1.0), - g_eCvars[MAX_REVIVES] + Cvars[MAX_REVIVES] ); bind_pcvar_num(create_cvar( "rt_max_spawns", @@ -268,7 +271,7 @@ public CreateCvars() { "Maximum number of spawns per player per round", true, 1.0), - g_eCvars[MAX_SPAWNS] + Cvars[MAX_SPAWNS] ); bind_pcvar_num(create_cvar( "rt_no_fire", @@ -279,7 +282,7 @@ public CreateCvars() { 0.0, true, 1.0), - g_eCvars[NO_FIRE] + Cvars[NO_FIRE] ); bind_pcvar_num(create_cvar( "rt_bomb", @@ -290,7 +293,7 @@ public CreateCvars() { 0.0, true, 1.0), - g_eCvars[BOMB] + Cvars[BOMB] ); bind_pcvar_num(create_cvar( "rt_duel", @@ -301,7 +304,7 @@ public CreateCvars() { 0.0, true, 1.0), - g_eCvars[DUEL] + Cvars[DUEL] ); bind_pcvar_num(create_cvar( "rt_survivor", @@ -312,7 +315,7 @@ public CreateCvars() { 0.0, true, 1.0), - g_eCvars[SURVIVOR] + Cvars[SURVIVOR] ); bind_pcvar_num(create_cvar( "rt_min_round", @@ -321,7 +324,7 @@ public CreateCvars() { "From which round is resurrection/planting available", true, 1.0), - g_eCvars[MIN_ROUND] + Cvars[MIN_ROUND] ); bind_pcvar_num(create_cvar( "rt_no_move", @@ -332,7 +335,7 @@ public CreateCvars() { 0.0, true, 2.0), - g_eCvars[NO_MOVE] + Cvars[NO_MOVE] ); bind_pcvar_num(create_cvar( "rt_revive_cost", @@ -341,7 +344,7 @@ public CreateCvars() { "Cost of resurrection", true, 0.0), - g_eCvars[REVIVE_COST] + Cvars[REVIVE_COST] ); bind_pcvar_num(create_cvar( "rt_planting_cost", @@ -350,7 +353,7 @@ public CreateCvars() { "Cost of planting", true, 0.0), - g_eCvars[PLANTING_COST] + Cvars[PLANTING_COST] ); bind_pcvar_num(create_cvar( "rt_wins_domination", @@ -359,7 +362,7 @@ public CreateCvars() { "Prohibition of resurrection/planting for the dominant team(consecutive wins)", true, 0.0), - g_eCvars[WIN_DIFF] + Cvars[WIN_DIFF] ); bind_pcvar_float(create_cvar( "rt_remaining_time", @@ -368,11 +371,11 @@ public CreateCvars() { "Prohibition of resurrection/planting until the end of the round", true, 0.0), - g_eCvars[REMAINING_TIME] + Cvars[REMAINING_TIME] ); - new pCvar = get_cvar_pointer("rt_force_fwd_mode"); + new cvar = get_cvar_pointer("rt_force_fwd_mode"); - if(pCvar) - bind_pcvar_num(pCvar, g_eCvars[FORCE_FWD_MODE]); + if(cvar) + bind_pcvar_num(cvar, Cvars[FORCE_FWD_MODE]); } \ No newline at end of file diff --git a/addons/amxmodx/scripting/rt_revive_model.sma b/addons/amxmodx/scripting/rt_revive_model.sma index af1ad7c..be240d8 100644 --- a/addons/amxmodx/scripting/rt_revive_model.sma +++ b/addons/amxmodx/scripting/rt_revive_model.sma @@ -4,14 +4,15 @@ #include #include -public stock const PLUGIN[] = "Revive Teammates: Model"; -public stock const CFG_FILE[] = "addons/amxmodx/configs/rt_configs/rt_revive_model.cfg"; +#define PLUGIN_NAME "Revive Teammates: Model" + +#define CFG_FILE "addons/amxmodx/configs/rt_configs/rt_revive_model.cfg" enum CVARS { MODEL_V[96], }; -new g_eCvars[CVARS]; +new Cvars[CVARS]; public plugin_precache() { CreateCvars(); @@ -19,183 +20,167 @@ public plugin_precache() { server_cmd("exec %s", CFG_FILE); server_exec(); - if(g_eCvars[MODEL_V][0]) { - precache_model(g_eCvars[MODEL_V]); - UTIL_PrecacheSoundsFromModel(g_eCvars[MODEL_V]); + if(Cvars[MODEL_V][0]) { + precache_model(Cvars[MODEL_V]); + UTIL_PrecacheSoundsFromModel(Cvars[MODEL_V]); } } public plugin_init() { - register_plugin(PLUGIN, VERSION, "mx?!"); + register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHORS); - if(g_eCvars[MODEL_V][0]) { + if(Cvars[MODEL_V][0]) RegisterHookChain(RG_CBasePlayerWeapon_DefaultDeploy, "CBasePlayerWeapon_DefaultDeploy_Post", true); - } } public plugin_cfg() { - if(!g_eCvars[MODEL_V][0]) { + if(!Cvars[MODEL_V][0]) return; - } - new pCvar = get_cvar_pointer("rt_force_fwd_mode"); // from rt_core.sma + new cvar = get_cvar_pointer("rt_force_fwd_mode"); - if(!pCvar) { + if(!cvar) return; - } - if(!get_pcvar_num(pCvar)) { - set_pcvar_num(pCvar, 1); + if(!get_pcvar_num(cvar)) { + set_pcvar_num(cvar, 1); log_amx("Forcing 'rt_force_fwd_mode' cvar value to ^"1^" !"); } } -public rt_revive_start_post(const iEnt, const iPlayer, const iActivator, const Modes:eMode) { - if(!g_eCvars[MODEL_V][0] || eMode != MODE_REVIVE) { +public rt_revive_start_post(const entId, const playerId, const activatorId, const Modes:mode) { + if(!Cvars[MODEL_V][0] || mode != MODE_REVIVE) return; - } - set_entvar(iActivator, var_viewmodel, g_eCvars[MODEL_V]); + set_entvar(activatorId, var_viewmodel, Cvars[MODEL_V]); - set_entvar(iActivator, var_weaponmodel, ""); - set_member(iActivator, m_szAnimExtention, "knife"); + set_entvar(activatorId, var_weaponmodel, ""); + set_member(activatorId, m_szAnimExtention, "knife"); const ANIM_DRAW = 3; - SetWeaponAnim(iActivator, ANIM_DRAW); + SetWeaponAnim(activatorId, ANIM_DRAW); - set_member(iActivator, m_flNextAttack, 9999.0); + set_member(activatorId, m_flNextAttack, 9999.0); - new pWeapon = get_member(iActivator, m_pActiveItem); - if(pWeapon > 0) { - set_member(pWeapon, m_Weapon_flTimeWeaponIdle, 9999.0); - //set_member(pWeapon, m_Weapon_flNextPrimaryAttack, 9999.0); - //set_member(pWeapon, m_Weapon_flNextSecondaryAttack, 9999.0); + new weapon = get_member(activatorId, m_pActiveItem); + + if(weapon > 0) { + set_member(weapon, m_Weapon_flTimeWeaponIdle, 9999.0); + //set_member(weapon, m_Weapon_flNextPrimaryAttack, 9999.0); + //set_member(weapon, m_Weapon_flNextSecondaryAttack, 9999.0); } } -public rt_revive_loop_post(const iEnt, const iPlayer, const iActivator, const Float:fTimer, Modes:eMode) { - const Float:fAnimTime = 0.6; // 23 frames / 30 fps = 0.766, но нам не нужна полная анимация, обрезаем 0.166 +public rt_revive_loop_post(const entId, const playerId, const activatorId, const Float:timer, Modes:mode) { + const Float:animTime = 0.6; // 23 frames / 30 fps = 0.766, но нам не нужна полная анимация, обрезаем 0.166 const ANIM_USE = 1; - new Float:fGameTime = get_gametime(); - new Float:fEndTime = fGameTime + fTimer; + new Float:gameTime = get_gametime(); + new Float:endTime = gameTime + timer; - if(g_eCvars[MODEL_V][0] && eMode == MODE_REVIVE && fGameTime > (fEndTime - fAnimTime) && get_entvar(iActivator, var_weaponanim) != ANIM_USE) { - SetWeaponAnim(iActivator, ANIM_USE); - } + if(Cvars[MODEL_V][0] && mode == MODE_REVIVE && gameTime > (endTime - animTime) && get_entvar(activatorId, var_weaponanim) != ANIM_USE) + SetWeaponAnim(activatorId, ANIM_USE); } -public rt_revive_cancelled(const iEnt, const iPlayer, const iActivator, const Modes:eMode) { - if(eMode == MODE_REVIVE && iActivator != RT_NULLENT) { - TryResetReviveModel(iActivator); - } +public rt_revive_cancelled(const entId, const playerId, const activatorId, const Modes:mode) { + if(mode == MODE_REVIVE && activatorId != RT_NULLENT) + TryResetReviveModel(activatorId); } -public rt_revive_end(const iEnt, const iPlayer, const iActivator, const Modes:eMode) { - if(eMode == MODE_REVIVE/* && iActivator != RT_NULLENT*/) { - TryResetReviveModel(iActivator); - } +public rt_revive_end(const entId, const playerId, const activatorId, const Modes:mode) { + if(mode == MODE_REVIVE/* && activatorId != RT_NULLENT*/) + TryResetReviveModel(activatorId); } -TryResetReviveModel(pPlayer) { - if(!g_eCvars[MODEL_V][0] || !IsRiviveModelActive(pPlayer)) { +TryResetReviveModel(playerId) { + if(!Cvars[MODEL_V][0] || !IsRiviveModelActive(playerId)) return; - } - new pWeapon = get_member(pPlayer, m_pActiveItem); + new weapon = get_member(playerId, m_pActiveItem); - if(!is_nullent(pWeapon)) { - ExecuteHamB(Ham_Item_Deploy, pWeapon); - } + if(!is_nullent(weapon)) + ExecuteHamB(Ham_Item_Deploy, weapon); } -bool:IsRiviveModelActive(pPlayer) { +bool:IsRiviveModelActive(playerId) { /* - if(!g_eCvars[MODEL_V][0]) { + if(!Cvars[MODEL_V][0]) return false; - } */ - static szModel[96] - get_entvar(pPlayer, var_viewmodel, szModel, charsmax(szModel)); + static model[96] + get_entvar(playerId, var_viewmodel, model, charsmax(model)); - return bool:equal(szModel, g_eCvars[MODEL_V]); + return bool:equal(model, Cvars[MODEL_V]); } -public CBasePlayerWeapon_DefaultDeploy_Post(pWeapon, szViewModel[], szWeaponModel[], iAnim, szAnimExt[], skiplocal) { - if(!is_entity(pWeapon)) { +public CBasePlayerWeapon_DefaultDeploy_Post(weapon, viewModel[], weaponModel[], animId, animExt[], skiplocal) { + if(!is_entity(weapon)) return; - } - new pPlayer = get_member(pWeapon, m_pPlayer); + new playerId = get_member(weapon, m_pPlayer); - if(rt_get_user_mode(pPlayer) == MODE_REVIVE) { - rt_reset_use(pPlayer); - } -} - -CreateCvars() { - bind_pcvar_string(create_cvar( - "rt_revive_model_v", - "", - FCVAR_NONE, - "1st persion view model for revive process"), - g_eCvars[MODEL_V], - charsmax(g_eCvars[MODEL_V]) - ); + if(rt_get_user_mode(playerId) == MODE_REVIVE) + rt_reset_use(playerId); } -SetWeaponAnim(pPlayer, iAnimNum) { - set_entvar(pPlayer, var_weaponanim, iAnimNum); +stock SetWeaponAnim(playerId, animNum) { + set_entvar(playerId, var_weaponanim, animNum); - message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = pPlayer); - write_byte(iAnimNum); // sequence number + message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = playerId); + write_byte(animNum); // sequence number write_byte(0); // weaponmodel bodygroup. message_end(); } // Автопрекеш звуков из модели: https://dev-cs.ru/resources/914/field?field=source -stock UTIL_PrecacheSoundsFromModel(const szModelPath[]) -{ - new iFile; - - if((iFile = fopen(szModelPath, "rt"))) - { - new szSoundPath[64]; - - new iNumSeq, iSeqIndex; - new iEvent, iNumEvents, iEventIndex; - - fseek(iFile, 164, SEEK_SET); - fread(iFile, iNumSeq, BLOCK_INT); - fread(iFile, iSeqIndex, BLOCK_INT); - - for(new k, i = 0; i < iNumSeq; i++) - { - fseek(iFile, iSeqIndex + 48 + 176 * i, SEEK_SET); - fread(iFile, iNumEvents, BLOCK_INT); - fread(iFile, iEventIndex, BLOCK_INT); - fseek(iFile, iEventIndex + 176 * i, SEEK_SET); - - for(k = 0; k < iNumEvents; k++) - { - fseek(iFile, iEventIndex + 4 + 76 * k, SEEK_SET); - fread(iFile, iEvent, BLOCK_INT); - fseek(iFile, 4, SEEK_CUR); - - if(iEvent != 5004) +stock UTIL_PrecacheSoundsFromModel(const modelPath[]) { + new file; + + if((file = fopen(modelPath, "rt"))) { + new soundPath[64]; + + new numSeq, seqIndex; + new event, numEvents, eventIndex; + + fseek(file, 164, SEEK_SET); + fread(file, numSeq, BLOCK_INT); + fread(file, seqIndex, BLOCK_INT); + + for(new k, i = 0; i < numSeq; i++) { + fseek(file, seqIndex + 48 + 176 * i, SEEK_SET); + fread(file, numEvents, BLOCK_INT); + fread(file, eventIndex, BLOCK_INT); + fseek(file, eventIndex + 176 * i, SEEK_SET); + + for(k = 0; k < numEvents; k++) { + fseek(file, eventIndex + 4 + 76 * k, SEEK_SET); + fread(file, event, BLOCK_INT); + fseek(file, 4, SEEK_CUR); + + if(event != 5004) continue; - fread_blocks(iFile, szSoundPath, 64, BLOCK_CHAR); + fread_blocks(file, soundPath, 64, BLOCK_CHAR); - if(strlen(szSoundPath)) - { - strtolower(szSoundPath); - engfunc(EngFunc_PrecacheSound, szSoundPath); + if(strlen(soundPath)) { + strtolower(soundPath); + engfunc(EngFunc_PrecacheSound, soundPath); } } } } - fclose(iFile); + fclose(file); +} + +public CreateCvars() { + bind_pcvar_string(create_cvar( + "rt_revive_model_v", + "", + FCVAR_NONE, + "1st persion view model for revive process"), + Cvars[MODEL_V], + charsmax(Cvars[MODEL_V]) + ); } \ No newline at end of file diff --git a/addons/amxmodx/scripting/rt_sounds.sma b/addons/amxmodx/scripting/rt_sounds.sma index fbdc418..526618c 100644 --- a/addons/amxmodx/scripting/rt_sounds.sma +++ b/addons/amxmodx/scripting/rt_sounds.sma @@ -4,9 +4,10 @@ #include #include -public stock const PLUGIN[] = "Revive Teammates: Sounds"; -public stock const CFG_FILE[] = "addons/amxmodx/configs/rt_configs/rt_sounds.cfg"; -public stock const INI_FILE[] = "addons/amxmodx/configs/rt_configs/rt_sounds.ini"; +#define PLUGIN_NAME "Revive Teammates: Sounds" + +#define CFG_FILE "addons/amxmodx/configs/rt_configs/rt_sounds.cfg" +#define INI_FILE "addons/amxmodx/configs/rt_configs/rt_sounds.ini" #define MAX_SOUNDS_PER_SECTION 10 #define MAX_SOUND_LENGTH 64 @@ -17,7 +18,7 @@ enum CVARS { FORCE_FWD_MODE }; -new g_eCvars[CVARS]; +new Cvars[CVARS]; enum sections_struct { SECTION_REVIVE_START, @@ -28,23 +29,23 @@ enum sections_struct { SECTION_PLANT_END }; -new sections_struct:g_eCurrentSection; -new g_iSounds[sections_struct]; -new g_szSounds[sections_struct][MAX_SOUNDS_PER_SECTION][MAX_SOUND_LENGTH]; -new g_iTicks[MAX_PLAYERS + 1]; +new sections_struct:CurrentSection; +new SoundsNum[sections_struct]; +new Sounds[sections_struct][MAX_SOUNDS_PER_SECTION][MAX_SOUND_LENGTH]; +new Ticks[MAX_PLAYERS + 1]; public plugin_precache() { - register_plugin(PLUGIN, VERSION, AUTHORS); + register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHORS); if(!file_exists(INI_FILE)) { set_fail_state("[RT Sounds] File ^"%s^" not found", INI_FILE); return; } - new INIParser:iParser = INI_CreateParser(); - INI_SetReaders(iParser, "ReadKeyValue", "ReadNewSection"); - INI_ParseFile(iParser, INI_FILE); - INI_DestroyParser(iParser); + new INIParser:parser = INI_CreateParser(); + INI_SetReaders(parser, "ReadKeyValue", "ReadNewSection"); + INI_ParseFile(parser, INI_FILE); + INI_DestroyParser(parser); CreateCvars(); @@ -52,101 +53,101 @@ public plugin_precache() { server_exec(); } -public rt_revive_start(const iEnt, const iPlayer, const iActivator, const Modes:eMode) { - g_iTicks[iActivator] = 0; +public rt_revive_start(const entId, const playerId, const activatorId, const Modes:mode) { + Ticks[activatorId] = 0; - switch(eMode) { - case MODE_REVIVE: { PlaybackSound(iEnt, iPlayer, iActivator, SECTION_REVIVE_START); } - case MODE_PLANT: { PlaybackSound(iEnt, iPlayer, iActivator, SECTION_PLANT_START); } + switch(mode) { + case MODE_REVIVE: { PlaybackSound(entId, playerId, activatorId, SECTION_REVIVE_START); } + case MODE_PLANT: { PlaybackSound(entId, playerId, activatorId, SECTION_PLANT_START); } } } -public rt_revive_loop_post(const iEnt, const iPlayer, const iActivator, const Float:fTimer, Modes:eMode) { - if(!g_eCvars[FORCE_FWD_MODE] || ++g_iTicks[iActivator] == 10) { - g_iTicks[iActivator] = 0; +public rt_revive_loop_post(const entId, const playerId, const activatorId, const Float:timer, Modes:mode) { + if(!Cvars[FORCE_FWD_MODE] || ++Ticks[activatorId] == 10) { + Ticks[activatorId] = 0; - switch(eMode) { - case MODE_REVIVE: { PlaybackSound(iEnt, iPlayer, iActivator, SECTION_REVIVE_LOOP); } - case MODE_PLANT: { PlaybackSound(iEnt, iPlayer, iActivator, SECTION_PLANT_LOOP); } + switch(mode) { + case MODE_REVIVE: { PlaybackSound(entId, playerId, activatorId, SECTION_REVIVE_LOOP); } + case MODE_PLANT: { PlaybackSound(entId, playerId, activatorId, SECTION_PLANT_LOOP); } } } } -public rt_revive_end(const iEnt, const iPlayer, const iActivator, const Modes:eMode) { - switch(eMode) { +public rt_revive_end(const entId, const playerId, const activatorId, const Modes:mode) { + switch(mode) { case MODE_REVIVE: { - new Modes:iMode = Modes:get_entvar(iEnt, var_iuser3); + new Modes:entMode = Modes:get_entvar(entId, var_iuser3); - if(iMode != MODE_PLANT) - PlaybackSound(iEnt, iPlayer, iActivator, SECTION_REVIVE_END); + if(entMode != MODE_PLANT) + PlaybackSound(entId, playerId, activatorId, SECTION_REVIVE_END); } - case MODE_PLANT: { PlaybackSound(iEnt, iPlayer, iActivator, SECTION_PLANT_END); } + case MODE_PLANT: { PlaybackSound(entId, playerId, activatorId, SECTION_PLANT_END); } } } -public bool:ReadNewSection(INIParser:iParser, const szSection[], bool:bInvalidTokens, bool:bCloseBracket) { - if(!bCloseBracket) { - log_error(AMX_ERR_NATIVE, "Closing bracket was not detected! Current section name '%s'.", szSection); +public bool:ReadNewSection(INIParser:parser, const section[], bool:invalidTokens, bool:closeBracket) { + if(!closeBracket) { + log_error(AMX_ERR_NATIVE, "Closing bracket was not detected! Current section name '%s'.", section); return false; } - if(equal(szSection, "revive_start")) { - g_eCurrentSection = SECTION_REVIVE_START; + if(equal(section, "revive_start")) { + CurrentSection = SECTION_REVIVE_START; return true; - } else if(equal(szSection, "revive_loop")) { - g_eCurrentSection = SECTION_REVIVE_LOOP; + } else if(equal(section, "revive_loop")) { + CurrentSection = SECTION_REVIVE_LOOP; return true; - } else if(equal(szSection, "revive_end")) { - g_eCurrentSection = SECTION_REVIVE_END; + } else if(equal(section, "revive_end")) { + CurrentSection = SECTION_REVIVE_END; return true; - } else if(equal(szSection, "plant_start")) { - g_eCurrentSection = SECTION_PLANT_START; + } else if(equal(section, "plant_start")) { + CurrentSection = SECTION_PLANT_START; return true; - } else if(equal(szSection, "plant_loop")) { - g_eCurrentSection = SECTION_PLANT_LOOP; + } else if(equal(section, "plant_loop")) { + CurrentSection = SECTION_PLANT_LOOP; return true; - } else if(equal(szSection, "plant_end")) { - g_eCurrentSection = SECTION_PLANT_END; + } else if(equal(section, "plant_end")) { + CurrentSection = SECTION_PLANT_END; return true; } return false; } -public bool:ReadKeyValue(INIParser:iParser, const szKey[], const szValue[]) { - if(szKey[0] == EOS) +public bool:ReadKeyValue(INIParser:parser, const key[], const value[]) { + if(key[0] == EOS) return false; - new szSound[MAX_SOUND_LENGTH]; - copy(szSound, charsmax(szSound), szKey); - trim(szSound); - copy(g_szSounds[g_eCurrentSection][g_iSounds[g_eCurrentSection]++], charsmax(g_szSounds[][]), szSound); + new sound[MAX_SOUND_LENGTH]; + copy(sound, charsmax(sound), key); + trim(sound); + copy(Sounds[CurrentSection][SoundsNum[CurrentSection]++], charsmax(Sounds[][]), sound); - precache_sound(szSound); + precache_sound(sound); return true; } -stock PlaybackSound(const iEnt, const iPlayer, const iActivator, const sections_struct:iSoundSection) { - if(g_iSounds[iSoundSection]) { - if(g_eCvars[NEARBY_PLAYERS] == 2 || (g_eCvars[NEARBY_PLAYERS] && (iSoundSection == SECTION_REVIVE_END || iSoundSection == SECTION_PLANT_END))) - PlaybackSoundNearbyPlayers(iEnt, g_szSounds[iSoundSection][random(g_iSounds[iSoundSection])]); - else if(!g_eCvars[NEARBY_PLAYERS]) { - rg_send_audio(iActivator, g_szSounds[iSoundSection][random(g_iSounds[iSoundSection])]); - rg_send_audio(iPlayer, g_szSounds[iSoundSection][random(g_iSounds[iSoundSection])]); +stock PlaybackSound(const entId, const playerId, const activatorId, const sections_struct:soundSection) { + if(SoundsNum[soundSection]) { + if(Cvars[NEARBY_PLAYERS] == 2 || (Cvars[NEARBY_PLAYERS] && (soundSection == SECTION_REVIVE_END || soundSection == SECTION_PLANT_END))) + PlaybackSoundNearbyPlayers(entId, Sounds[soundSection][random(SoundsNum[soundSection])]); + else if(!Cvars[NEARBY_PLAYERS]) { + rg_send_audio(activatorId, Sounds[soundSection][random(SoundsNum[soundSection])]); + rg_send_audio(playerId, Sounds[soundSection][random(SoundsNum[soundSection])]); } } } -stock PlaybackSoundNearbyPlayers(const iPlayer, const szSound[]) { - new iEnt = RT_NULLENT; +stock PlaybackSoundNearbyPlayers(const playerId, const sound[]) { + new entId = RT_NULLENT; - new Float:fVecOrigin[3]; - get_entvar(iPlayer, var_vuser4, fVecOrigin); + new Float:vecOrigin[3]; + get_entvar(playerId, var_vuser4, vecOrigin); - while((iEnt = engfunc(EngFunc_FindEntityInSphere, iEnt, fVecOrigin, g_eCvars[SOUND_RADIUS])) > 0) - if(ExecuteHam(Ham_IsPlayer, iEnt)) - rg_send_audio(iEnt, szSound); + while((entId = engfunc(EngFunc_FindEntityInSphere, entId, vecOrigin, Cvars[SOUND_RADIUS])) > 0) + if(ExecuteHam(Ham_IsPlayer, entId)) + rg_send_audio(entId, sound); } public CreateCvars() { @@ -157,7 +158,7 @@ public CreateCvars() { "The radius in which to count the nearest players", true, 1.0), - g_eCvars[SOUND_RADIUS] + Cvars[SOUND_RADIUS] ); bind_pcvar_num(create_cvar( "rt_nearby_players", @@ -168,11 +169,11 @@ public CreateCvars() { 0.0, true, 2.0), - g_eCvars[NEARBY_PLAYERS] + Cvars[NEARBY_PLAYERS] ); - new pCvar = get_cvar_pointer("rt_force_fwd_mode"); + new cvar = get_cvar_pointer("rt_force_fwd_mode"); - if(pCvar) - bind_pcvar_num(pCvar, g_eCvars[FORCE_FWD_MODE]); + if(cvar) + bind_pcvar_num(cvar, Cvars[FORCE_FWD_MODE]); } \ No newline at end of file diff --git a/addons/amxmodx/scripting/rt_timer.sma b/addons/amxmodx/scripting/rt_timer.sma index 29a3def..583bcec 100644 --- a/addons/amxmodx/scripting/rt_timer.sma +++ b/addons/amxmodx/scripting/rt_timer.sma @@ -2,8 +2,9 @@ #include #include -public stock const PLUGIN[] = "Revive Teammates: Timer"; -public stock const CFG_FILE[] = "addons/amxmodx/configs/rt_configs/rt_timer.cfg"; +#define PLUGIN_NAME "Revive Teammates: Timer" + +#define CFG_FILE "addons/amxmodx/configs/rt_configs/rt_timer.cfg" enum CVARS { TIMER_TYPE, @@ -14,9 +15,9 @@ enum CVARS { FORCE_FWD_MODE }; -new g_eCvars[CVARS]; +new Cvars[CVARS]; -enum HudData { +enum HUD_DATA { COLOR_R, COLOR_G, COLOR_B, @@ -24,25 +25,25 @@ enum HudData { Float:COORD_Y }; -new g_eHudData[Modes][HudData]; +new HudData[Modes][HUD_DATA]; -enum TimeData { +enum TIME_DATA { Float:GLOBAL_TIME, CEIL_TIME, Float:START_TIME, }; -new g_eTimeData[TimeData]; +new TimeData[TIME_DATA]; -new const TIMER_BEGIN[] = "[ | "; -new const TIMER_ADD[] = "- "; -new const TIMER_END[] = "]"; -new const TIMER_REPLACE_SYMB[] = "| -"; -new const TIMER_REPLACE_WITH[] = "| |"; +new const TIMER_BEGIN[] = "[ | "; +new const TIMER_ADD[] = "- "; +new const TIMER_END[] = "]"; +new const TIMER_REPLACE_SYMB[] = "| -"; +new const TIMER_REPLACE_WITH[] = "| |"; -new g_szTimer[MAX_PLAYERS + 1][64]; -new g_iHudSyncObj; -new g_iTicks[MAX_PLAYERS + 1]; +new Timer[MAX_PLAYERS + 1][64]; +new HudSyncObj; +new Ticks[MAX_PLAYERS + 1]; public plugin_precache() { CreateCvars(); @@ -50,103 +51,103 @@ public plugin_precache() { server_cmd("exec %s", CFG_FILE); server_exec(); - new szHudColors[3][4]; + new hudColors[3][4]; - if(parse(g_eCvars[REVIVE_COLORS], szHudColors[0], charsmax(szHudColors[]), - szHudColors[1], charsmax(szHudColors[]), szHudColors[2], charsmax(szHudColors[])) == 3) { - g_eHudData[MODE_REVIVE][COLOR_R] = str_to_num(szHudColors[0]); - g_eHudData[MODE_REVIVE][COLOR_G] = str_to_num(szHudColors[1]); - g_eHudData[MODE_REVIVE][COLOR_B] = str_to_num(szHudColors[2]); + if(parse(Cvars[REVIVE_COLORS], hudColors[0], charsmax(hudColors[]), + hudColors[1], charsmax(hudColors[]), hudColors[2], charsmax(hudColors[])) == 3) { + HudData[MODE_REVIVE][COLOR_R] = str_to_num(hudColors[0]); + HudData[MODE_REVIVE][COLOR_G] = str_to_num(hudColors[1]); + HudData[MODE_REVIVE][COLOR_B] = str_to_num(hudColors[2]); } - if(parse(g_eCvars[PLANTING_COLORS], szHudColors[0], charsmax(szHudColors[]), - szHudColors[1], charsmax(szHudColors[]), szHudColors[2], charsmax(szHudColors[])) == 3) { - g_eHudData[MODE_PLANT][COLOR_R] = str_to_num(szHudColors[0]); - g_eHudData[MODE_PLANT][COLOR_G] = str_to_num(szHudColors[1]); - g_eHudData[MODE_PLANT][COLOR_B] = str_to_num(szHudColors[2]); + if(parse(Cvars[PLANTING_COLORS], hudColors[0], charsmax(hudColors[]), + hudColors[1], charsmax(hudColors[]), hudColors[2], charsmax(hudColors[])) == 3) { + HudData[MODE_PLANT][COLOR_R] = str_to_num(hudColors[0]); + HudData[MODE_PLANT][COLOR_G] = str_to_num(hudColors[1]); + HudData[MODE_PLANT][COLOR_B] = str_to_num(hudColors[2]); } - new szHudCoords[2][8]; + new hudCoords[2][8]; - if(parse(g_eCvars[REVIVE_COORDS], szHudCoords[0], charsmax(szHudCoords[]), szHudCoords[1], charsmax(szHudCoords[])) == 2) { - g_eHudData[MODE_REVIVE][COORD_X] = str_to_float(szHudCoords[0]); - g_eHudData[MODE_REVIVE][COORD_Y] = str_to_float(szHudCoords[1]); + if(parse(Cvars[REVIVE_COORDS], hudCoords[0], charsmax(hudCoords[]), hudCoords[1], charsmax(hudCoords[])) == 2) { + HudData[MODE_REVIVE][COORD_X] = str_to_float(hudCoords[0]); + HudData[MODE_REVIVE][COORD_Y] = str_to_float(hudCoords[1]); } - if(parse(g_eCvars[PLANTING_COORDS], szHudCoords[0], charsmax(szHudCoords[]), szHudCoords[1], charsmax(szHudCoords[])) == 2) { - g_eHudData[MODE_PLANT][COORD_X] = str_to_float(szHudCoords[0]); - g_eHudData[MODE_PLANT][COORD_Y] = str_to_float(szHudCoords[1]); + if(parse(Cvars[PLANTING_COORDS], hudCoords[0], charsmax(hudCoords[]), hudCoords[1], charsmax(hudCoords[])) == 2) { + HudData[MODE_PLANT][COORD_X] = str_to_float(hudCoords[0]); + HudData[MODE_PLANT][COORD_Y] = str_to_float(hudCoords[1]); } } public plugin_init() { - register_plugin(PLUGIN, VERSION, AUTHORS); + register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHORS); - register_dictionary("rt_library.txt"); + register_dictionary(PLUGIN_DICTIONARY); - if(!g_eCvars[TIMER_TYPE]) - g_iHudSyncObj = CreateHudSyncObj(); + if(!Cvars[TIMER_TYPE]) + HudSyncObj = CreateHudSyncObj(); - g_eTimeData[GLOBAL_TIME] = get_pcvar_float(get_cvar_pointer("rt_revive_time")); - g_eTimeData[CEIL_TIME] = floatround(g_eTimeData[GLOBAL_TIME], floatround_ceil); - g_eTimeData[START_TIME] = (1.0 - g_eTimeData[GLOBAL_TIME] / float(g_eTimeData[CEIL_TIME])) * 100.0; + TimeData[GLOBAL_TIME] = get_pcvar_float(get_cvar_pointer("rt_revive_time")); + TimeData[CEIL_TIME] = floatround(TimeData[GLOBAL_TIME], floatround_ceil); + TimeData[START_TIME] = (1.0 - TimeData[GLOBAL_TIME] / float(TimeData[CEIL_TIME])) * 100.0; } -public rt_revive_start(const iEnt, const iPlayer, const iActivator, const Modes:eMode) { - g_iTicks[iActivator] = 0; +public rt_revive_start(const entId, const playerId, const activatorId, const Modes:mode) { + Ticks[activatorId] = 0; - switch(g_eCvars[TIMER_TYPE]) { + switch(Cvars[TIMER_TYPE]) { case 0: { - formatex(g_szTimer[iPlayer], charsmax(g_szTimer[]), TIMER_BEGIN); + formatex(Timer[playerId], charsmax(Timer[]), TIMER_BEGIN); - for(new i; i < floatround(g_eTimeData[GLOBAL_TIME]); i++) - add(g_szTimer[iPlayer], charsmax(g_szTimer[]), TIMER_ADD); + for(new i; i < floatround(TimeData[GLOBAL_TIME]); i++) + add(Timer[playerId], charsmax(Timer[]), TIMER_ADD); - add(g_szTimer[iPlayer], charsmax(g_szTimer[]), TIMER_END); + add(Timer[playerId], charsmax(Timer[]), TIMER_END); - DisplayHudMessage(iPlayer, iActivator, eMode); + DisplayHudMessage(playerId, activatorId, mode); } case 1: { - rg_send_bartime2(iActivator, g_eTimeData[CEIL_TIME], g_eTimeData[START_TIME]); + rg_send_bartime2(activatorId, TimeData[CEIL_TIME], TimeData[START_TIME]); - if(eMode == MODE_REVIVE && is_user_connected(iPlayer)) - rg_send_bartime2(iPlayer, g_eTimeData[CEIL_TIME], g_eTimeData[START_TIME]); + if(mode == MODE_REVIVE && is_user_connected(playerId)) + rg_send_bartime2(playerId, TimeData[CEIL_TIME], TimeData[START_TIME]); } } } -public rt_revive_loop_post(const iEnt, const iPlayer, const iActivator, const Float:fTimer, Modes:eMode) { - if(!g_eCvars[FORCE_FWD_MODE] || ++g_iTicks[iActivator] == 10) { - g_iTicks[iActivator] = 0; +public rt_revive_loop_post(const entId, const playerId, const activatorId, const Float:timer, Modes:mode) { + if(!Cvars[FORCE_FWD_MODE] || ++Ticks[activatorId] == 10) { + Ticks[activatorId] = 0; - if(!g_eCvars[TIMER_TYPE]) { - replace(g_szTimer[iPlayer], charsmax(g_szTimer[]), TIMER_REPLACE_SYMB, TIMER_REPLACE_WITH); + if(!Cvars[TIMER_TYPE]) { + replace(Timer[playerId], charsmax(Timer[]), TIMER_REPLACE_SYMB, TIMER_REPLACE_WITH); - DisplayHudMessage(iPlayer, iActivator, eMode); + DisplayHudMessage(playerId, activatorId, mode); } } } -public rt_revive_cancelled(const iEnt, const iPlayer, const iActivator, const Modes:eMode) { - switch(g_eCvars[TIMER_TYPE]) { +public rt_revive_cancelled(const entId, const playerId, const activatorId, const Modes:mode) { + switch(Cvars[TIMER_TYPE]) { case 0: { - if(iActivator != RT_NULLENT) - ClearSyncHud(iActivator, g_iHudSyncObj); + if(activatorId != RT_NULLENT) + ClearSyncHud(activatorId, HudSyncObj); } case 1: { - if(iActivator != RT_NULLENT) - rg_send_bartime(iActivator, 0); + if(activatorId != RT_NULLENT) + rg_send_bartime(activatorId, 0); - if(eMode == MODE_REVIVE && iPlayer != RT_NULLENT) - rg_send_bartime(iPlayer, 0); + if(mode == MODE_REVIVE && playerId != RT_NULLENT) + rg_send_bartime(playerId, 0); } } } -stock DisplayHudMessage(const iPlayer, const iActivator, const Modes:eMode) { - set_hudmessage(g_eHudData[eMode][COLOR_R], g_eHudData[eMode][COLOR_G], g_eHudData[eMode][COLOR_B], - g_eHudData[eMode][COORD_X], g_eHudData[eMode][COORD_Y], .holdtime = g_eTimeData[GLOBAL_TIME]); - ShowSyncHudMsg(iActivator, g_iHudSyncObj, g_szTimer[iPlayer]); +stock DisplayHudMessage(const playerId, const activatorId, const Modes:mode) { + set_hudmessage(HudData[mode][COLOR_R], HudData[mode][COLOR_G], HudData[mode][COLOR_B], + HudData[mode][COORD_X], HudData[mode][COORD_Y], .holdtime = TimeData[GLOBAL_TIME]); + ShowSyncHudMsg(activatorId, HudSyncObj, Timer[playerId]); } public CreateCvars() { @@ -159,43 +160,43 @@ public CreateCvars() { 0.0, true, 1.0), - g_eCvars[TIMER_TYPE] + Cvars[TIMER_TYPE] ); bind_pcvar_string(create_cvar( "rt_revive_hud_colors", "0 255 0", FCVAR_NONE, "HUD's colors at resurrection"), - g_eCvars[REVIVE_COLORS], - charsmax(g_eCvars[REVIVE_COLORS]) + Cvars[REVIVE_COLORS], + charsmax(Cvars[REVIVE_COLORS]) ); bind_pcvar_string(create_cvar( "rt_revive_hud_coords", "-1.0 0.6", FCVAR_NONE, "HUD's coordinates at resurrection"), - g_eCvars[REVIVE_COORDS], - charsmax(g_eCvars[REVIVE_COORDS]) + Cvars[REVIVE_COORDS], + charsmax(Cvars[REVIVE_COORDS]) ); bind_pcvar_string(create_cvar( "rt_planting_hud_colors", "255 0 0", FCVAR_NONE, "HUD's colors at planting"), - g_eCvars[PLANTING_COLORS], - charsmax(g_eCvars[PLANTING_COLORS]) + Cvars[PLANTING_COLORS], + charsmax(Cvars[PLANTING_COLORS]) ); bind_pcvar_string(create_cvar( "rt_planting_hud_coords", "-1.0 0.6", FCVAR_NONE, "HUD's coordinates at planting"), - g_eCvars[PLANTING_COORDS], - charsmax(g_eCvars[PLANTING_COORDS]) + Cvars[PLANTING_COORDS], + charsmax(Cvars[PLANTING_COORDS]) ); - new pCvar = get_cvar_pointer("rt_force_fwd_mode"); + new cvar = get_cvar_pointer("rt_force_fwd_mode"); - if(pCvar) - bind_pcvar_num(pCvar, g_eCvars[FORCE_FWD_MODE]); + if(cvar) + bind_pcvar_num(cvar, Cvars[FORCE_FWD_MODE]); } \ No newline at end of file