Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <amxmisc>
- #include <hamsandwich>
- #include <engine>
- #include <fakemeta>
- #define PLUGIN "[Hns] Anti-BodyBlock"
- #define VERSION "1.0"
- #define AUTHOR "Xalus"
- #define Tag "[Hide 'n Seek]"
- new Blocked[33], Touched[33];
- new cStatus, cClassname, cBunnyhop, cNSBunnyhop, cTrampoline, cDmgBunnyhop, cBhopTask, cTrampTask;
- public plugin_init() {
- register_plugin(PLUGIN, VERSION, AUTHOR);
- /* Cvar */
- cStatus = register_cvar("bodyblock_status", "1");
- cClassname = register_cvar("bodyblock_classname", "bm_block");
- /* Blockmaker Number */
- /* Bunnyhops */
- cBunnyhop = register_cvar("bodyblock_bunnyhop", "1");
- cNSBunnyhop = register_cvar("bodyblock_noslowdownbunnyhop", "22");
- cDmgBunnyhop = register_cvar("bodyblock_damagebunnyhop", "999");
- /* Trampoline */
- cTrampoline = register_cvar("bodyblock_trampoline", "6");
- /* Task's */
- cBhopTask = register_cvar("bodyblock_bunnyhoptask", "4.0")
- cTrampTask = register_cvar("bodyblock_trampolinetask", "7.5")
- /* Detect Touching */
- RegisterHam(Ham_Touch, "player", "PlayerTouch");
- /* Player Damaged */
- RegisterHam(Ham_TakeDamage, "player", "FwdHamTakeDamage", 0);
- }
- /*
- Hns:
- - Player Touched Player
- - Reset Blocked
- */
- public PlayerTouch(id, player) {
- if(is_user_alive(id) && is_user_alive(player) && get_user_team(id) == 1 && get_pcvar_num(cStatus)) {
- if(Touched[id] && Touched[player])
- return PLUGIN_HANDLED;
- Blocked[player] = id;
- set_task(2.0, "ResetBlocked", player);
- }
- return PLUGIN_CONTINUE;
- }
- public ResetBlocked(id)
- Blocked[id]=0;
- /*
- Hns:
- - Touch Bunnyhop / Trampoline block
- */
- public pfn_touch(ent, id) {
- if(get_pcvar_num(cStatus) && is_user_alive(id)) {
- if(isBlock(ent) && is_user_alive(id)) {
- new block_type = entity_get_int(ent, EV_INT_body);
- if ( block_type == get_pcvar_num(cBunnyhop) || block_type == get_pcvar_num(cNSBunnyhop) || block_type == get_pcvar_num(cDmgBunnyhop) || block_type == get_pcvar_num(cTrampoline) ) {
- if(!Touched[id])
- Touched[id]=true;
- remove_task(id);
- if(block_type == get_pcvar_num(cTrampoline))
- set_task(get_pcvar_float(cTrampTask), "Touching", id)
- else
- set_task(get_pcvar_float(cBhopTask), "Touching", id);
- }
- }
- }
- }
- /*
- Hns:
- - Bhoping
- - On Trampoline
- */
- public Touching(id) {
- Touched[id]=false
- }
- /*
- Hns:
- - Player Damaged
- */
- public FwdHamTakeDamage(iVictim, iInflictor, iAttacker, Float:flDamage, iDamageBits) {
- if(is_user_alive(iVictim) && Blocked[iVictim] && iDamageBits & DMG_FALL && Touched[iVictim] && !Touched[Blocked[iVictim]]) {
- SetHamParamFloat(4, 0.0);
- /* Uber Slap! */
- user_slap(Blocked[iVictim], 1);
- user_slap(Blocked[iVictim], 1);
- /* Get Names */
- new szName[32]; get_user_name(Blocked[iVictim], szName, 31);
- new szName2[32]; get_user_name(iVictim, szName2, 31)
- /* Print Chat */
- ChatColor(0, "!g%s!team %s!y bodyblocked!team %s!y!", Tag, szName, szName2);
- /* Remove Task for no bugs */
- remove_task(iVictim);
- Touched[iVictim]=false
- }
- }
- /*
- Hns:
- - Is Block
- */
- bool:isBlock(ent) {
- if (is_valid_ent(ent)) {
- new szClassname[32]; pev(ent, pev_classname, szClassname, 32);
- new gClassname[32]; get_pcvar_string(cClassname, gClassname, 31);
- if (equal(szClassname, gClassname))
- return true;
- }
- return false;
- }
- /*
- Hns:
- - Chat Color
- */
- stock ChatColor(const id, const input[], any:...) {
- new count = 1, players[32];
- static msg[191];
- vformat(msg, 190, input, 3);
- replace_all(msg, 190, "!g", "^4"); // Green Color
- replace_all(msg, 190, "!y", "^1"); // Default Color
- replace_all(msg, 190, "!team", "^3"); // Team Color
- if (id) players[0] = id; else get_players(players, count, "ch");
- {
- for (new i = 0; i < count; i++)
- {
- message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
- write_byte(players[i]);
- write_string(msg);
- message_end();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement