08-09-2020, 03:59 PM
author
Mistrick
compatibility
Amx Mod X 1.8.2
The basis for creating a surf mod
Features:
Necessary functionality to organize the mod
Fall damage block
Blocking damage in the buy zone
Spawn protection
DM mode
Auto joiner
Installation
2. Compile the plugin (instruction).
3. Copy the compiled surfmod_core.amxx file to the directory: amxmodx / plugins /
4. Add surfmod_core.amxx in the /amxmodx/configs/plugins.ini file
Settings
Quar:
surf_deathmatch: DM mode: 0 - disable, 1 - enable.
surf_spawn_protection: Spawn Protection: 0 - disable, 1 - enable.
surf_block_dmg_by_protected: Blocking damage from someone who is in defense: 0 - disable, 1- enable.
surf_protective_glow: Player lighting when spawn'e: 0 - off, 1 - on.
surf_no_fall_damage: Fall Damage Blocking: 0 - disable, 1 - enable.
surf_dont_sit_in_buyzone: Deal damage in the buy zone after n-amount of time: 0 - disable, 1 - enable.
surf_block_dmg_in_buyzone: Blocking damage in the buy zone: 0 - disable, 1 - enable.
Customizable macros:
#define FUNCTION_AUTOJOIN - automatic distribution by command upon connection.
#define RESPAWN_TIME 5.0 - the time after which the player will be revived.
#define PROTECTION_TIME 5.0 - how long will immortality last after rebirth.
#define MAX_IN_BUYZONE_TIME 15.0 - after how much damage will be done in the buy zone.
#define DAMAGE_REPEAT_TIME 5.0 - after what time interval the damage will be dealt in the buy zone.
#define DAMAGE_IN_BUYZONE 10.0 - how much damage will be done in the buy zone
Mistrick
compatibility
Amx Mod X 1.8.2
The basis for creating a surf mod
Features:
Necessary functionality to organize the mod
Fall damage block
Blocking damage in the buy zone
Spawn protection
DM mode
Auto joiner
Installation
2. Compile the plugin (instruction).
3. Copy the compiled surfmod_core.amxx file to the directory: amxmodx / plugins /
4. Add surfmod_core.amxx in the /amxmodx/configs/plugins.ini file
Settings
Quar:
surf_deathmatch: DM mode: 0 - disable, 1 - enable.
surf_spawn_protection: Spawn Protection: 0 - disable, 1 - enable.
surf_block_dmg_by_protected: Blocking damage from someone who is in defense: 0 - disable, 1- enable.
surf_protective_glow: Player lighting when spawn'e: 0 - off, 1 - on.
surf_no_fall_damage: Fall Damage Blocking: 0 - disable, 1 - enable.
surf_dont_sit_in_buyzone: Deal damage in the buy zone after n-amount of time: 0 - disable, 1 - enable.
surf_block_dmg_in_buyzone: Blocking damage in the buy zone: 0 - disable, 1 - enable.
Customizable macros:
#define FUNCTION_AUTOJOIN - automatic distribution by command upon connection.
#define RESPAWN_TIME 5.0 - the time after which the player will be revived.
#define PROTECTION_TIME 5.0 - how long will immortality last after rebirth.
#define MAX_IN_BUYZONE_TIME 15.0 - after how much damage will be done in the buy zone.
#define DAMAGE_REPEAT_TIME 5.0 - after what time interval the damage will be dealt in the buy zone.
#define DAMAGE_IN_BUYZONE 10.0 - how much damage will be done in the buy zone
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN "Surfmod: Core"
#define VERSION "0.3f"
#define AUTHOR "Mistrick"
#pragma semicolon 1
#define FUNCTION_AUTOJOIN
#define RESPAWN_TIME 5.0 //seconds
#define PROTECTION_TIME 5.0 //seconds
#define MAX_IN_BUYZONE_TIME 15.0 //seconds
#define DAMAGE_REPEAT_TIME 5.0 //seconds
#define DAMAGE_IN_BUYZONE 10.0 //health
enum (+=100)
{
TASK_DELAYED_RESPAWN = 100,
TASK_REMOVE_PROTECTION,
TASK_DONT_SIT_IN_BUYZONE,
TASK_TAKEDAMAGE_IN_BUYZONE
};
enum _:CVARS
{
DEATHMATCH,
SPAWN_PROTECTION,
BLOCK_DAMAGE_BY_PROTECTED,
PROTECTIVE_GLOW,
NO_FALL_DAMAGE,
BLOCK_DAMAGE_IN_BUYZONE,
DONT_SIT_IN_BUYZONE
};
new g_iColors[2][3] =
{
{ 250, 0, 0 },
{ 0, 0, 250 }
};
new g_pCvars[CVARS];
new g_bInBuyZone[33];
new g_bProtected[33];
new HamHook:g_iHamPreThink;
new g_msgShowMenu, g_msgVGUIMenu;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
g_pCvars[DEATHMATCH] = register_cvar("surf_deathmatch", "1");
g_pCvars[SPAWN_PROTECTION] = register_cvar("surf_spawn_protection", "1");
g_pCvars[BLOCK_DAMAGE_BY_PROTECTED] = register_cvar("surf_block_dmg_by_protected", "1");
g_pCvars[PROTECTIVE_GLOW] = register_cvar("surf_protective_glow", "1");
g_pCvars[NO_FALL_DAMAGE] = register_cvar("surf_no_fall_damage", "1");
g_pCvars[DONT_SIT_IN_BUYZONE] = register_cvar("surf_dont_sit_in_buyzone", "1");
g_pCvars[BLOCK_DAMAGE_IN_BUYZONE] = register_cvar("surf_block_dmg_in_buyzone", "1");
register_event("StatusIcon", "Event_BuyZone_In", "b", "1=1", "2=buyzone");
register_event("StatusIcon", "Event_BuyZone_Out", "b", "1=0", "2=buyzone");
RegisterHam(Ham_Spawn, "player", "Ham_PlayerSpawn_Post", true);
RegisterHam(Ham_Killed, "player", "Ham_PlayerKilled_Post", true);
RegisterHam(Ham_TakeDamage, "player", "Ham_PlayerTakeDamage_Pre", false);
#if defined FUNCTION_AUTOJOIN
register_message((g_msgVGUIMenu = get_user_msgid("VGUIMenu")), "Message_Menu");
register_message((g_msgShowMenu = get_user_msgid("ShowMenu")), "Message_Menu");
DisableHamForward((g_iHamPreThink = RegisterHam(Ham_Player_PreThink, "player", "Ham_PlayerPreThink_Post", true)));
#endif
}
#if defined FUNCTION_AUTOJOIN
public client_putinserver(id)
{
block_user_spawn(id);
}
#endif
public client_disconnect(id)
{
g_bProtected[id] = false;
g_bInBuyZone[id] = false;
remove_task(id + TASK_DELAYED_RESPAWN);
remove_task(id + TASK_REMOVE_PROTECTION);
remove_task(id + TASK_DONT_SIT_IN_BUYZONE);
remove_task(id + TASK_TAKEDAMAGE_IN_BUYZONE);
}
#if defined FUNCTION_AUTOJOIN
public Message_Menu(const msg, const nDest, const nClient)
{
const MENU_TEAM = 2;
const SHOWTEAMSELECT = 3;
const Menu_ChooseTeam = 1;
const m_iJoiningState = 121;
const m_iMenu = 205;
if (msg == g_msgShowMenu)
{
new szMsg[13];
get_msg_arg_string(4, szMsg, charsmax(szMsg));
if (!equal(szMsg, "#Team_Select"))
{
return PLUGIN_CONTINUE;
}
}
else if (get_msg_arg_int(1) != MENU_TEAM || get_msg_arg_int(2) & MENU_KEY_0)
{
return PLUGIN_CONTINUE;
}
// safe checks
if (get_pdata_int(nClient, m_iMenu) == Menu_ChooseTeam || get_pdata_int(nClient, m_iJoiningState) != SHOWTEAMSELECT)
{
return PLUGIN_CONTINUE;
}
EnableHamForward(g_iHamPreThink);
return PLUGIN_HANDLED;
}
public Ham_PlayerPreThink_Post(id)
{
DisableHamForward(g_iHamPreThink);
static const szTeam[][] = {"1", "2"};
new ct_count, tt_count; get_players_count(ct_count, tt_count);
new team = ct_count > tt_count ? 0 : 1;
new iOldShowMenuBlock = get_msg_block(g_msgShowMenu);
new iOldVGUIMenuBlock = get_msg_block(g_msgVGUIMenu);
set_msg_block(g_msgShowMenu, BLOCK_SET);
set_msg_block(g_msgVGUIMenu, BLOCK_SET);
engclient_cmd(id, "jointeam", szTeam[team]);
engclient_cmd(id, "joinclass", "5");
set_msg_block(g_msgVGUIMenu, iOldVGUIMenuBlock);
set_msg_block(g_msgShowMenu, iOldShowMenuBlock);
set_task(RESPAWN_TIME, "Task_PlayerRespawn", id + TASK_DELAYED_RESPAWN);
}
#endif
public Event_BuyZone_In(id)
{
g_bInBuyZone[id] = true;
if(get_pcvar_num(g_pCvars[DONT_SIT_IN_BUYZONE]))
{
set_task(MAX_IN_BUYZONE_TIME, "Task_DontSitInBuyZone", id + TASK_DONT_SIT_IN_BUYZONE);
}
}
public Task_DontSitInBuyZone(id)
{
id -= TASK_DONT_SIT_IN_BUYZONE;
Task_TakeDamageInBuyZone(id + TASK_TAKEDAMAGE_IN_BUYZONE);
}
public Task_TakeDamageInBuyZone(id)
{
id -= TASK_TAKEDAMAGE_IN_BUYZONE;
ExecuteHam(Ham_TakeDamage, id, 0, id, DAMAGE_IN_BUYZONE, DMG_BURN);
set_task(DAMAGE_REPEAT_TIME, "Task_TakeDamageInBuyZone", id + TASK_TAKEDAMAGE_IN_BUYZONE);
}
public Event_BuyZone_Out(id)
{
g_bInBuyZone[id] = false;
remove_task(id + TASK_DONT_SIT_IN_BUYZONE);
remove_task(id + TASK_TAKEDAMAGE_IN_BUYZONE);
}
public Ham_PlayerSpawn_Post(id)
{
if(is_user_alive(id) && get_pcvar_num(g_pCvars[SPAWN_PROTECTION]))
{
new CsTeams:team = cs_get_user_team(id);
if((team == CS_TEAM_CT || team == CS_TEAM_T))
{
g_bProtected[id] = true;
set_user_godmode(id, 1);
if(get_pcvar_num(g_pCvars[PROTECTIVE_GLOW]))
{
set_user_rendering(id, kRenderFxGlowShell, g_iColors[_:team - 1][0], g_iColors[_:team - 1][1], g_iColors[_:team - 1][2], kRenderNormal, 30);
}
set_task(PROTECTION_TIME, "Task_PlayerRemoveProtection", id + TASK_REMOVE_PROTECTION);
}
}
}
public Task_PlayerRemoveProtection(id)
{
id -= TASK_REMOVE_PROTECTION;
set_user_godmode(id, 0);
set_user_rendering(id);
g_bProtected[id] = false;
}
public Ham_PlayerKilled_Post(id)
{
g_bInBuyZone[id] = false;
new CsTeams:team = cs_get_user_team(id);
if(get_pcvar_num(g_pCvars[DEATHMATCH]) && (team == CS_TEAM_CT || team == CS_TEAM_T))
{
set_task(RESPAWN_TIME, "Task_PlayerRespawn", id + TASK_DELAYED_RESPAWN);
}
remove_task(id + TASK_DONT_SIT_IN_BUYZONE);
remove_task(id + TASK_TAKEDAMAGE_IN_BUYZONE);
}
public Task_PlayerRespawn(id)
{
id -= TASK_DELAYED_RESPAWN;
new CsTeams:team = cs_get_user_team(id);
if(!is_user_alive(id) && (team == CS_TEAM_CT || team == CS_TEAM_T))
{
ExecuteHamB(Ham_CS_RoundRespawn, id);
}
}
public Ham_PlayerTakeDamage_Pre(id, inflictor, attacker, Float:damage, damage_bits)
{
if(get_pcvar_num(g_pCvars[NO_FALL_DAMAGE]) && damage_bits & DMG_FALL)
{
return HAM_SUPERCEDE;
}
if(get_pcvar_num(g_pCvars[BLOCK_DAMAGE_IN_BUYZONE]) && g_bInBuyZone[id])
{
return HAM_SUPERCEDE;
}
if(get_pcvar_num(g_pCvars[BLOCK_DAMAGE_BY_PROTECTED]) && attacker && attacker <= 32 && g_bProtected[attacker])
{
return HAM_SUPERCEDE;
}
return HAM_IGNORED;
}
stock block_user_spawn(id)
{
const m_iSpawnCount = 365;
set_pdata_int(id, m_iSpawnCount, 1);
}
stock get_players_count(&ct_count, &tt_count)
{
new players[32];
get_players(players, ct_count, "e", "CT");
get_players(players, tt_count, "e", "TERRORIST");
}