AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   amx grab (https://forums.alliedmods.net/showthread.php?t=332741)

Ace67 05-30-2021 06:12

amx grab
 
Hello, on my server i have a plugin for grab player, but he doesn't work.
I use it for my basebuilder server, i put here my bb lines + grab lines
Someone can combine the plugins for he works ?


AMX GRAB:
Code:

/*
Grab+ v1.2.5
Copyright (C) 2011 Ian (Juan) Cammarata

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------------

http://ian.cammarata.us/projects/grab_plus
?19 ?February, ?2011


Description:
This is a remake from scratch of SpaceDude's Jedi Force Grab plugin.  It has many additional features and optimizations, is less spammy, multilingual and requires fewer binds.


Features:
Multilingual
Screenfade to indicate grab activity instead of chat spam.
Can grab players off a ladder.
Automatically choke by holding down +pull while at min distance.
Choke with use key.
Throw with drop.
Can't have mutliple admins grabbing the same player.
Auto drop on death.
Grab entities other than players, such as bombs, weapons, and hostages.


Commands:

+grab : Grab something for as long as you hold down the key.
grab_toggle : Same as +grab but toggles.
amx_grab <name> : Grab client by name or id and teleport them to you.  Use +grab or grab_toggle key to release.

+pull/+push (or invnext/invprev): Pulls/pushes the grabbed towards/away from you as you hold the button.

+use : Chokes the grabbed (it damages the grabbed with 5 (cvar: gp_choke_dmg) hp per 1.5 (cvar: gp_choke_time) seconds)
drop - Throws the grabbed with 1500 velocity. (cvar: gp_throw_force)


Cvars (First value is default):
gp_enabled <1|0> Enables all plugin functionality.
gp_players_only <0|1> Disables admins grabbing entities other than players.

gp_min_dist <90|...> Min distance between the grabber and grabbed.
gp_grab_force <8|...> Sets the amount of force used when grabbing players.
gp_throw_force <1500|...> Sets the power used when throwing players.
gp_speed <5|...> How fast the grabbed moves when using push and pull.

gp_choke_time <1.5|...> Time frequency for choking.
gp_choke_dmg <5|...> Amount of damage done with each choke.
gp_auto_choke <1|0> Enable/disable choking automatically with +pull command.

gp_screen_fade <1|0> Enables/disables screenfade when grabbing.
gp_glow <1|0> Enables/disables glowing for grabbed objects.

gp_glow_r <50|0-255> Sets red amount for glow and screenfade.
gp_glow_g <0|0-255> Sets green amount for glow and screenfade.
gp_glow_b <0|0-255> Sets blue amount for glow and screenfade.
gp_glow_a <0|0-255> Sets alpha for glow and screenfade.


Notes:
Make sure you place the grab_plus.txt file in addons\amxmodx\data\lang


Credits:
Thanks to vittu for contributing code (changed all engine/fun module stuff to fakemeta).
 
Thanks to all the coders who worked on the original Jedi Force Grab plugin for all their ideas:
SpaceDude
KCE
KRoTaL
BOB_SLAYER
kosmo111


Supported Languages:
1337 (100%) - Thanks to l337newb
Brazilian Portuguese (100%) - Thanks to Arion
Danish (100%) - Thanks to nellerbabz
Dutch (100%) - Thanks to BlackMilk
English (100%)
Finnish (100%) - Thanks to Pro Patria Finland
French (100%) - Thanks to connorr
German (100%) - Thanks to SchlumPF*
Russian (100%) - Thanks to `666
Spanish (100%) - Thanks to RenXO
Swedish (100%) - Thanks to Bend3r


Change Log:
Key (+ added | - removed | c changed | f fixed)

v1.2.5 (Feb 19, 2011)
f: Applied fix mailed to me on Allied Modders site several years ago.  (Maybe I should sign up for new mail notifications.)
Thanks to ConnorMcLeod

v1.2.4 (Feb 18, 2007)
f: Killing player with choke in some mods bugged out really bad.

v1.2.3 (Nov 21, 2007)
c: A few more small optimizations.
f: Bloodstream for choke wasn't aligned with player.
f: Bad message disconnect error when players were choked. ( stupid SVC_DAMAGE define )

v1.2.2 (Nov 16, 2007)
c: A few small code optimizations.

v1.2.1 (Nov 12, 2007)
f: Eliminated two run time warnings in the player prethink function.

v1.2 (Nov 06, 2007)
+: Cvars gp_screen_fade and gp_glow to enable/disable these features.
+: Cvar gp_glow_a controls to control alpha of screenfade and glow.
+: Cvar gp_auto_choke to enable/disable choking automatically with +pull command.
c: Removed dependency of engine and fun modules.  Thanks to vittu for doing most of the work.
c: Made cvar names more consistent by adding more underscores.
f: Fixed compile bug with amxx 1.8.0 (Compiles with 1.7.x as well).

v1.1 (Oct 16, 2007)
+: Grab a few types of entities other than players.
+: Cvar gp_players_only.

v1.0 (Oct 13, 2007)
!: Initial release

*/

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

new const VERSION[ ] = "1.2.4b1"
new const TRKCVAR[ ] = "grab_plus_version"
#define ADMIN ADMIN_LEVEL_A

#define TSK_CHKE 50

#define SF_FADEOUT 0

new client_data[33][4]
#define GRABBED  0
#define GRABBER  1
#define GRAB_LEN 2
#define FLAGS    3

#define m_bitsDamageType 76

#define CDF_IN_PUSH  (1<<0)
#define CDF_IN_PULL  (1<<1)
#define CDF_NO_CHOKE  (1<<2)

//Cvar Pointers
new p_enabled, p_players_only
new p_throw_force, p_min_dist, p_speed, p_grab_force
new p_choke_time, p_choke_dmg, p_auto_choke
new p_glow_r, p_glow_b, p_glow_g, p_glow_a
new p_fade, p_glow

//Pseudo Constants
new MAXPLAYERS
new SVC_SCREENFADE, SVC_SCREENSHAKE, WTF_DAMAGE

public plugin_init( )
{
        register_plugin( "Grab+", VERSION, "Ian Cammarata" )
        register_cvar( TRKCVAR, VERSION, FCVAR_SERVER )
        set_cvar_string( TRKCVAR, VERSION )
       
        p_enabled = register_cvar( "gp_enabled", "1" )
        p_players_only = register_cvar( "gp_players_only", "0" )
       
        p_min_dist = register_cvar ( "gp_min_dist", "90" )
        p_throw_force = register_cvar( "gp_throw_force", "1500" )
        p_grab_force = register_cvar( "gp_grab_force", "8" )
        p_speed = register_cvar( "gp_speed", "5" )
       
        p_choke_time = register_cvar( "gp_choke_time", "1.5" )
        p_choke_dmg = register_cvar( "gp_choke_dmg", "5" )
        p_auto_choke = register_cvar( "gp_auto_choke", "1" )
       
        p_glow_r = register_cvar( "gp_glow_r", "50" )
        p_glow_g = register_cvar( "gp_glow_g", "0" )
        p_glow_b = register_cvar( "gp_glow_b", "0" )
        p_glow_a = register_cvar( "gp_glow_a", "200" )
       
        p_fade = register_cvar( "gp_screen_fade", "1" )
        p_glow = register_cvar( "gp_glow", "1" )
       
        register_clcmd( "amx_grab", "force_grab", ADMIN, "Grab client & teleport to you." )
        register_clcmd( "grab_toggle", "grab_toggle", ADMIN, "press once to grab and again to release" )
        register_clcmd( "+grab", "grab", ADMIN, "bind a key to +grab" )
        register_clcmd( "-grab", "unset_grabbed" )
       
        register_clcmd( "+push", "push", ADMIN, "bind a key to +push" )
        register_clcmd( "-push", "push" )
        register_clcmd( "+pull", "pull", ADMIN, "bind a key to +pull" )
        register_clcmd( "-pull", "pull" )
        register_clcmd( "push", "push2" )
        register_clcmd( "pull", "pull2" )
       
        register_clcmd( "drop" ,"throw" )
       
        register_event( "DeathMsg", "DeathMsg", "a" )
       
        register_forward( FM_PlayerPreThink, "fm_player_prethink" )
       
        register_dictionary( "grab_plus.txt" )
       
        MAXPLAYERS = get_maxplayers()
       
        SVC_SCREENFADE = get_user_msgid( "ScreenFade" )
        SVC_SCREENSHAKE = get_user_msgid( "ScreenShake" )
        WTF_DAMAGE = get_user_msgid( "Damage" )
}

public plugin_precache( )
{
        precache_sound( "player/PL_PAIN2.WAV" )
}

public fm_player_prethink( id )
{
        new target
        //Search for a target
        if ( client_data[id][GRABBED] == -1 )
        {
                new Float:orig[3], Float:ret[3]
                get_view_pos( id, orig )
                ret = vel_by_aim( id, 9999 )
               
                ret[0] += orig[0]
                ret[1] += orig[1]
                ret[2] += orig[2]
               
                target = traceline( orig, ret, id, ret )
               
                if( 0 < target <= MAXPLAYERS )
                {
                        if( is_grabbed( target, id ) ) return FMRES_IGNORED
                        set_grabbed( id, target )
                }
                else if( !get_pcvar_num( p_players_only ) )
                {
                        new movetype
                        if( target && pev_valid( target ) )
                        {
                                movetype = pev( target, pev_movetype )
                                if( !( movetype == MOVETYPE_WALK || movetype == MOVETYPE_STEP || movetype == MOVETYPE_TOSS ) )
                                        return FMRES_IGNORED
                        }
                        else
                        {
                                target = 0
                                new ent = engfunc( EngFunc_FindEntityInSphere, -1, ret, 12.0 )
                                while( !target && ent > 0 )
                                {
                                        movetype = pev( ent, pev_movetype )
                                        if( ( movetype == MOVETYPE_WALK || movetype == MOVETYPE_STEP || movetype == MOVETYPE_TOSS )
                                                        && ent != id  )
                                                target = ent
                                        ent = engfunc( EngFunc_FindEntityInSphere, ent, ret, 12.0 )
                                }
                        }
                        if( target )
                        {
                                if( is_grabbed( target, id ) ) return FMRES_IGNORED
                                set_grabbed( id, target )
                        }
                }
        }
       
        target = client_data[id][GRABBED]
        //If they've grabbed something
        if( target > 0 )
        {
                if( !pev_valid( target ) || ( pev( target, pev_health ) < 1 && pev( target, pev_max_health ) ) )
                {
                        unset_grabbed( id )
                        return FMRES_IGNORED
                }
               
                //Use key choke
                if( pev( id, pev_button ) & IN_USE )
                        do_choke( id )
               
                //Push and pull
                new cdf = client_data[id][FLAGS]
                if ( cdf & CDF_IN_PULL )
                        do_pull( id )
                else if ( cdf & CDF_IN_PUSH )
                        do_push( id )
               
                if( target > MAXPLAYERS ) grab_think( id )
        }
       
        //If they're grabbed
        target = client_data[id][GRABBER]
        if( target > 0 ) grab_think( target )
       
        return FMRES_IGNORED
}

public grab_think( id ) //id of the grabber
{
        new target = client_data[id][GRABBED]
       
        //Keep grabbed clients from sticking to ladders
        if( pev( target, pev_movetype ) == MOVETYPE_FLY && !(pev( target, pev_button ) & IN_JUMP ) ) client_cmd( target, "+jump;wait;-jump" )
       
        //Move targeted client
        new Float:tmpvec[3], Float:tmpvec2[3], Float:torig[3], Float:tvel[3]
       
        get_view_pos( id, tmpvec )
       
        tmpvec2 = vel_by_aim( id, client_data[id][GRAB_LEN] )
       
        torig = get_target_origin_f( target )
       
        new force = get_pcvar_num( p_grab_force )
       
        tvel[0] = ( ( tmpvec[0] + tmpvec2[0] ) - torig[0] ) * force
        tvel[1] = ( ( tmpvec[1] + tmpvec2[1] ) - torig[1] ) * force
        tvel[2] = ( ( tmpvec[2] + tmpvec2[2] ) - torig[2] ) * force
       
        set_pev( target, pev_velocity, tvel )
}

stock Float:get_target_origin_f( id )
{
        new Float:orig[3]
        pev( id, pev_origin, orig )
       
        //If grabbed is not a player, move origin to center
        if( id > MAXPLAYERS )
        {
                new Float:mins[3], Float:maxs[3]
                pev( id, pev_mins, mins )
                pev( id, pev_maxs, maxs )
               
                if( !mins[2] ) orig[2] += maxs[2] / 2
        }
       
        return orig
}

public grab_toggle( id, level, cid )
{
        if( !client_data[id][GRABBED] ) grab( id, level, cid )
        else unset_grabbed( id )
       
        return PLUGIN_HANDLED
}

public grab( id, level, cid )
{
        if( !cmd_access( id, level, cid, 1 ) || !get_pcvar_num( p_enabled ) ) return PLUGIN_HANDLED
       
        if ( !client_data[id][GRABBED] ) client_data[id][GRABBED] = -1       
        screenfade_in( id )
       
        return PLUGIN_HANDLED
}

public screenfade_in( id )
{
        if( get_pcvar_num( p_fade ) )
        {
                message_begin( MSG_ONE, SVC_SCREENFADE, _, id )
                write_short( 10000 ) //duration
                write_short( 0 ) //hold
                write_short( SF_FADE_IN + SF_FADE_ONLYONE ) //flags
                write_byte( get_pcvar_num( p_glow_r ) ) //r
                write_byte( get_pcvar_num( p_glow_g ) ) //g
                write_byte( get_pcvar_num( p_glow_b ) ) //b
                write_byte( get_pcvar_num( p_glow_a ) / 2 ) //a
                message_end( )
        }
}

public throw( id )
{
        new target = client_data[id][GRABBED]
        if( target > 0 )
        {
                set_pev( target, pev_velocity, vel_by_aim( id, get_pcvar_num(p_throw_force) ) )
                unset_grabbed( id )
                return PLUGIN_HANDLED
        }

        return PLUGIN_CONTINUE
}

public unset_grabbed( id )
{
        new target = client_data[id][GRABBED]
        if( target > 0 && pev_valid( target ) )
        {
                set_pev( target, pev_renderfx, kRenderFxNone )
                set_pev( target, pev_rendercolor, {255.0, 255.0, 255.0} )
                set_pev( target, pev_rendermode, kRenderNormal )
                set_pev( target, pev_renderamt, 16.0 )
               
                if( 0 < target <= MAXPLAYERS )
                        client_data[target][GRABBER] = 0
        }
        client_data[id][GRABBED] = 0
       
        if( get_pcvar_num( p_fade ) )
        {
                message_begin( MSG_ONE, SVC_SCREENFADE, _, id )
                write_short( 10000 ) //duration
                write_short( 0 ) //hold
                write_short( SF_FADEOUT ) //flags
                write_byte( get_pcvar_num( p_glow_r ) ) //r
                write_byte( get_pcvar_num( p_glow_g ) ) //g
                write_byte( get_pcvar_num( p_glow_b ) ) //b
                write_byte( get_pcvar_num( p_glow_a ) / 2 ) //a
                message_end( )
        }
}

//Grabs onto someone
public set_grabbed( id, target )
{
        if( get_pcvar_num( p_glow ) )
        {
                new Float:color[3]
                color[0] = get_pcvar_float( p_glow_r )
                color[1] = get_pcvar_float( p_glow_g )
                color[2] = get_pcvar_float( p_glow_b )
                set_pev( target, pev_renderfx, kRenderFxGlowShell )
                set_pev( target, pev_rendercolor, color )
                set_pev( target, pev_rendermode, kRenderTransColor )
                set_pev( target, pev_renderamt, get_pcvar_float( p_glow_a ) )
        }
       
        if( 0 < target <= MAXPLAYERS )
                client_data[target][GRABBER] = id
        client_data[id][FLAGS] = 0
        client_data[id][GRABBED] = target
        new Float:torig[3], Float:orig[3]
        pev( target, pev_origin, torig )
        pev( id, pev_origin, orig )
        client_data[id][GRAB_LEN] = floatround( get_distance_f( torig, orig ) )
        if( client_data[id][GRAB_LEN] < get_pcvar_num( p_min_dist ) ) client_data[id][GRAB_LEN] = get_pcvar_num( p_min_dist )
}

public push( id )
{
        client_data[id][FLAGS] ^= CDF_IN_PUSH
        return PLUGIN_HANDLED
}

public pull( id )
{
        client_data[id][FLAGS] ^= CDF_IN_PULL
        return PLUGIN_HANDLED
}

public push2( id )
{
        if( client_data[id][GRABBED] > 0 )
        {
                do_push( id )
                return PLUGIN_HANDLED
        }
        return PLUGIN_CONTINUE
}

public pull2( id )
{
        if( client_data[id][GRABBED] > 0 )
        {
                do_pull( id )
                return PLUGIN_HANDLED
        }
        return PLUGIN_CONTINUE
}

public do_push( id )
        if( client_data[id][GRAB_LEN] < 9999 )
                client_data[id][GRAB_LEN] += get_pcvar_num( p_speed )

public do_pull( id )
{
        new mindist = get_pcvar_num( p_min_dist )
        new len = client_data[id][GRAB_LEN]
       
        if( len > mindist )
        {
                len -= get_pcvar_num( p_speed )
                if( len < mindist ) len = mindist
                client_data[id][GRAB_LEN] = len
        }
        else if( get_pcvar_num( p_auto_choke ) )
                do_choke( id )
}

public do_choke( id )
{
        new target = client_data[id][GRABBED]
        if( client_data[id][FLAGS] & CDF_NO_CHOKE || id == target || target > MAXPLAYERS) return
       
        new dmg = get_pcvar_num( p_choke_dmg )
        new vec[3]
        FVecIVec( get_target_origin_f( target ), vec )
       
        message_begin( MSG_ONE, SVC_SCREENSHAKE, _, target )
        write_short( 999999 ) //amount
        write_short( 9999 ) //duration
        write_short( 999 ) //frequency
        message_end( )
       
        message_begin( MSG_ONE, SVC_SCREENFADE, _, target )
        write_short( 9999 ) //duration
        write_short( 100 ) //hold
        write_short( SF_FADE_MODULATE ) //flags
        write_byte( get_pcvar_num( p_glow_r ) ) //r
        write_byte( get_pcvar_num( p_glow_g ) ) //g
        write_byte( get_pcvar_num( p_glow_b ) ) //b
        write_byte( 200 ) //a
        message_end( )
       
        message_begin( MSG_ONE, WTF_DAMAGE, _, target )
        write_byte( 0 ) //damage armor
        write_byte( dmg ) //damage health
        write_long( DMG_CRUSH ) //damage type
        write_coord( vec[0] ) //origin[x]
        write_coord( vec[1] ) //origin[y]
        write_coord( vec[2] ) //origin[z]
        message_end( )
               
        message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
        write_byte( TE_BLOODSTREAM )
        write_coord( vec[0] ) //pos.x
        write_coord( vec[1] ) //pos.y
        write_coord( vec[2] + 15 ) //pos.z
        write_coord( random_num( 0, 255 ) ) //vec.x
        write_coord( random_num( 0, 255 ) ) //vec.y
        write_coord( random_num( 0, 255 ) ) //vec.z
        write_byte( 70 ) //col index
        write_byte( random_num( 50, 250 ) ) //speed
        message_end( )
       
        //Thanks to ConnorMcLeod for making this block of code more proper
        new Float:health
        pev( target, pev_health , health)
        health -= dmg
        if( health < 1 ) dllfunc( DLLFunc_ClientKill, target )
        else {
                set_pev( target, pev_health, health )
                set_pdata_int(target, m_bitsDamageType, DMG_CRUSH) // m_bitsDamageType = 76 // found by VEN
                set_pev(target, pev_dmg_take, dmg)
                set_pev(target, pev_dmg_inflictor, id)
        }
       
        client_data[id][FLAGS] ^= CDF_NO_CHOKE
        set_task( get_pcvar_float( p_choke_time ), "clear_no_choke", TSK_CHKE + id )
}

public clear_no_choke( tskid )
{
        new id = tskid - TSK_CHKE
        client_data[id][FLAGS] ^= CDF_NO_CHOKE
}

//Grabs the client and teleports them to the admin
public force_grab(id, level, cid)
{
        if( !cmd_access( id, level, cid, 1 ) || !get_pcvar_num( p_enabled ) ) return PLUGIN_HANDLED

        new arg[33]
        read_argv( 1, arg, 32 )

        new targetid = cmd_target( id, arg, 1 )
       
        if( is_grabbed( targetid, id ) ) return PLUGIN_HANDLED
        if( !is_user_alive( targetid ) )
        {
                client_print( id, print_console, "[AMXX] %L", id, "COULDNT" )
                return PLUGIN_HANDLED
        }
       
        //Safe to tp target to aim spot?
        new Float:tmpvec[3], Float:orig[3], Float:torig[3], Float:trace_ret[3]
        new bool:safe = false, i
       
        get_view_pos( id, orig )
        tmpvec = vel_by_aim( id, get_pcvar_num( p_min_dist ) )
       
        for( new j = 1; j < 11 && !safe; j++ )
        {
                torig[0] = orig[0] + tmpvec[i] * j
                torig[1] = orig[1] + tmpvec[i] * j
                torig[2] = orig[2] + tmpvec[i] * j
               
                traceline( tmpvec, torig, id, trace_ret )
               
                if( get_distance_f( trace_ret, torig ) ) break
               
                engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 )
                if ( !get_tr2( 0, TR_StartSolid ) && !get_tr2( 0, TR_AllSolid ) && get_tr2( 0, TR_InOpen ) )
                        safe = true
        }
       
        //Still not safe? Then find another safe spot somewhere around the grabber
        pev( id, pev_origin, orig )
        new try[3]
        orig[2] += 2
        while( try[2] < 3 && !safe )
        {
                for( i = 0; i < 3; i++ )
                        switch( try[i] )
                        {
                                case 0 : torig[i] = orig[i] + ( i == 2 ? 80 : 40 )
                                case 1 : torig[i] = orig[i]
                                case 2 : torig[i] = orig[i] - ( i == 2 ? 80 : 40 )
                        }
               
                traceline( tmpvec, torig, id, trace_ret )
               
                engfunc( EngFunc_TraceHull, torig, torig, 0, HULL_HUMAN, 0, 0 )
                if ( !get_tr2( 0, TR_StartSolid ) && !get_tr2( 0, TR_AllSolid ) && get_tr2( 0, TR_InOpen )
                                && !get_distance_f( trace_ret, torig ) ) safe = true
               
                try[0]++
                if( try[0] == 3 )
                {
                        try[0] = 0
                        try[1]++
                        if( try[1] == 3 )
                        {
                                try[1] = 0
                                try[2]++
                        }
                }
        }
       
        if( safe )
        {
                set_pev( targetid, pev_origin, torig )
                set_grabbed( id, targetid )
                screenfade_in( id )       
        }
        else client_print( id, print_chat, "[AMXX] %L", id, "COULDNT" )

        return PLUGIN_HANDLED
}

public is_grabbed( target, grabber )
{
        for( new i = 1; i <= MAXPLAYERS; i++ )
                if( client_data[i][GRABBED] == target )
                {
                        client_print( grabber, print_chat, "[AMXX] %L", grabber, "ALREADY" )
                        unset_grabbed( grabber )
                        return true
                }
        return false
}

public DeathMsg( )
        kill_grab( read_data( 2 ) )

public client_disconnect( id )
{
        kill_grab( id )
        return PLUGIN_CONTINUE
}

public kill_grab( id )
{
        //If given client has grabbed, or has a grabber, unset it
        if( client_data[id][GRABBED] )
                unset_grabbed( id )
        else if( client_data[id][GRABBER] )
                unset_grabbed( client_data[id][GRABBER] )
}

stock traceline( const Float:vStart[3], const Float:vEnd[3], const pIgnore, Float:vHitPos[3] )
{
        engfunc( EngFunc_TraceLine, vStart, vEnd, 0, pIgnore, 0 )
        get_tr2( 0, TR_vecEndPos, vHitPos )
        return get_tr2( 0, TR_pHit )
}

stock get_view_pos( const id, Float:vViewPos[3] )
{
        new Float:vOfs[3]
        pev( id, pev_origin, vViewPos )
        pev( id, pev_view_ofs, vOfs )               
       
        vViewPos[0] += vOfs[0]
        vViewPos[1] += vOfs[1]
        vViewPos[2] += vOfs[2]
}

stock Float:vel_by_aim( id, speed = 1 )
{
        new Float:v1[3], Float:vBlah[3]
        pev( id, pev_v_angle, v1 )
        engfunc( EngFunc_AngleVectors, v1, v1, vBlah, vBlah )
       
        v1[0] *= speed
        v1[1] *= speed
        v1[2] *= speed
       
        return v1
}

BB:
Code:

/*
Base Builder Zombie Mod
By: Tirant
*/

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <basebuilder>
#include <fakemeta>
#include <engine>
#include <hamsandwich>
#include <fun>
#include <csstats>
#include <csx>
#include <xs>

// Plugin Version
new VERSION[]="5.4"
new formatmodname[] = "^x01 [^x04 Base Builder^x01 ]"

//Models
new const g_ZombieModel[] = "classic2"
new const g_ZombieKnifeModel[] = "models/bb/x_knife.mdl"

//Sounds
new g_RoundStart[] = "basebuilder/round_start.wav"

#define MAX_PLAYERS 32
#define AMMO_SLOT 376
#define MODELSET_TASK 100
#define MODELCHANGE_DELAY 0.5
#define MAXENTS 1365
#define TASK_ROUND 1023
#define AUTO_TEAM_JOIN_DELAY 0.1
#define TEAM_SELECT_VGUI_MENU_ID 2

#define AFTER_BUILD ADMIN_MAP
#define DEAD_BUILD ADMIN_LEVEL_B
#define REMOVE_BLOCK ADMIN_LEVEL_C
#define DEAD_REMOVE ADMIN_LEVEL_D
#define LOCK_BLOCKS ADMIN_RESERVATION
#define PAIN_SHOCK_FREE ADMIN_KICK
#define BAD_SPAWN ADMIN_KICK
#define BUILD_BAN ADMIN_KICK
#define REVIVE ADMIN_KICK
#define SWAP ADMIN_KICK
#define START_ROUND ADMIN_BAN

#if cellbits == 32
    #define OFFSET_BUYZONE 235
#else
    #define OFFSET_BUYZONE 268
#endif

#define LockBlock(%1)    ( entity_set_int( %1, EV_INT_iuser1, 1 ) )
#define UnlockBlock(%1)  ( entity_set_int( %1, EV_INT_iuser1, 0 ) )
#define IsBlockLocked(%1) ( entity_get_int( %1, EV_INT_iuser1 ) == 1 )

// CS Weapon CBase Offsets (win32)
const OFFSET_WEAPONOWNER = 41

// Linux diff's
const OFFSET_LINUX_WEAPONS = 4

new gmsgStatusText
new gmsgSayText
new gHudSyncInfo
new g_MaxPlayers
const fPainShock = 108

new bool:g_CanBuild
new bool:g_ZombiesReleased
new g_RoundNum
new g_iEntBarrier
new bool:g_BuildBan[MAX_PLAYERS+1]
new g_pEnt[MAX_PLAYERS+1], g_pDist[MAX_PLAYERS+1]
new bool:g_MovingEnt[MAXENTS]
new g_EntMover[MAXENTS]
new g_LastMover[MAXENTS]
new g_EntOwner[MAXENTS]
new g_OwnedEnts[33]

//Custom Model Stuff
new Float:g_ModelsTargetTime, Float:g_RoundStartTime
new g_HasCustomModel[MAX_PLAYERS+1], g_PlayerModel[MAX_PLAYERS+1][32]

new g_ModName[32]
new g_CurrentWeapon[MAX_PLAYERS+1]
new g_PrimaryWeapon[MAX_PLAYERS+1]

// Allowed weapons for zombies
const ZOMBIE_ALLOWED_WEAPONS_BITSUM = (1<<CSW_KNIFE)

new g_pcvar_team, g_pcvar_class, g_pcvar_buildtime, g_pcvar_zombiehp, g_pcvar_maxrounds, g_pcvar_basecalc,
        g_pcvar_givenades, g_pcvar_allowedweps, g_pcvar_tournymode, g_pcvar_showmovers, g_pcvar_healthtime,
        g_pcvar_blockgrav, g_pcvar_knockback, g_pcvar_entmindist, g_pcvar_entsetdist, g_pcvar_entmaxdist,
        g_pcvar_roundnum, g_pcvar_roundtime, g_pcvar_resetent, g_pcvar_zresptime, g_pcvar_maxclaimable,
        g_pcvar_claimable
       
new g_friend[MAX_PLAYERS+1]

//Cached Stuff for Players
new g_isconnected[MAX_PLAYERS+1]
new g_isalive[MAX_PLAYERS+1]
new g_ishuman[MAX_PLAYERS+1]
new g_iszombie[MAX_PLAYERS+1]

//CSDM-Style Weapons Menu
new bool:firsttime[MAX_PLAYERS+1],bool:ask[MAX_PLAYERS+1]
new weapon_picked[2][MAX_PLAYERS+1],cur_offset[MAX_PLAYERS+1],options_on_menu[8][MAX_PLAYERS+1]

new count_down

// Weapon entity names
new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
                        "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
                        "weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
                        "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
                        "weapon_ak47", "weapon_knife", "weapon_p90" }
                       
static const WEAPONNAMES[24][23] = { "Schmidt Scout", "XM1014 M4", "Ingram MAC-10", "Steyr AUG A1", "UMP 45", "SG-550 Auto-Sniper",
                        "IMI Galil", "Famas", "AWP Magnum Sniper", "MP5 Navy", "M249 Para Machinegun", "M3 Super 90", "M4A1 Carbine",
                        "Schmidt TMP", "G3SG1 Auto-Sniper", "SG-552 Commando", "AK-47 Kalashnikov", "ES P90", "P228 Compact",
                        "Dual Elite Berettas", "Fiveseven", "USP .45 ACP Tactical", "Glock 18C", "Desert Eagle .50 AE"
}

public plugin_init()
{
        register_plugin("Base Builder Zombie Mod", VERSION, "Tirant")
        register_cvar("base_builder", VERSION, FCVAR_SPONLY|FCVAR_SERVER)
        set_cvar_string("base_builder", VERSION)
       
        g_pcvar_buildtime = register_cvar("bb_build_time", "150")
        g_pcvar_zombiehp = register_cvar("bb_zombie_health", "6500")
        g_pcvar_basecalc = register_cvar("bb_calc_maxbase", "0")
        g_pcvar_tournymode = register_cvar("bb_tournament_mode", "0")
        g_pcvar_showmovers = register_cvar("bb_show_moving", "1")
        g_pcvar_blockgrav = register_cvar("bb_block_gravity", "0")
        g_pcvar_knockback = register_cvar("bb_pain_shock_free", "0")
        g_pcvar_entmaxdist = register_cvar("bb_max_move_dist", "99999999")
        g_pcvar_entmindist = register_cvar("bb_min_move_dist", "1")
        g_pcvar_entsetdist = register_cvar("bb_min_dist_set", "1")
        g_pcvar_healthtime = register_cvar("bb_health_time", "12")
        g_pcvar_resetent = register_cvar("bb_reset_blocks", "1")
        g_pcvar_roundtime = register_cvar("bb_roundtime", "8")
        g_pcvar_zresptime = register_cvar("bb_zombie_respawn_time", "0.01")
        g_pcvar_roundnum = register_cvar("bb_rounds", "6")
        g_pcvar_maxrounds = get_cvar_num("mp_maxrounds")
        g_pcvar_maxclaimable = register_cvar("bb_claim_max", "6")
        g_pcvar_claimable = register_cvar("bb_claim_mode", "0")
               
        //AJC for auto team (if needed)
        g_pcvar_team = register_cvar("bb_team", "5")
        g_pcvar_class = register_cvar("bb_class", "5")
               
        //Guns Menu
        g_pcvar_givenades = register_cvar("bb_give_nades","h") //h f s, put multiple letters for multiple nades
        g_pcvar_allowedweps = register_cvar("bb_weapons","abcdeghijlmnqrstuvwx")
       
        //Client Commands
        register_clcmd("+grab","cmdMoveEnt",_," - Starts moving the selected object")                //command to move stuff around
        register_clcmd("-grab","cmdStopEnt",_," - Stops moving the selected object")                //command to move stuff around
        register_clcmd("say /respawn","Respawn_Zombie",_," - Respawn while dead (Zombie)")        //command to respawn (zombies only)
        register_clcmd("say /fixspawn","cmdBadSpawn",_," - Respawn while dead (Survivor)")        //command to respawn (humans only before buildtime)
        register_clcmd("say /help","cmdHelp",_," - Displays the help hud")                        //command to see /help menu
        register_clcmd("say /rules","cmdHelp",_," - Displays the help hud")                        //command to see /help menu
        register_clcmd("say /round","cmdCheckRound",_," - Displays the round number")                //command to see the current round number
        register_clcmd("say round","cmdCheckRound",_," - Displays the round number")                //command to see the current round number
       
        //Guns Menu
        register_clcmd("say guns","cmdGuns",_," - Opens the guns menu")                                //Guns Menu CMD
        register_clcmd("say_team guns","cmdGuns",_," - Opens the guns menu")                        //Guns Menu CMD
        register_clcmd("say /guns","cmdGuns",_," - Opens the guns menu")                        //Guns Menu CMD
        register_clcmd("say_team /guns","cmdGuns",_," - Opens the guns menu")                        //Guns Menu CMD
       
        //Admin Commands
        register_concmd("removeaim","cmdRemoveEnt",_," - Deletes an object")                        //Removes an object (C alive, D dead)
        register_concmd("lockaim","cmdLockBlock",_," - Locks/Unlocks an object from moving")        //Once to lock, again to unlock
        register_concmd("unclaimaim","cmdRemoveClaim",_," - Removes a claim on an object")        //Makes block claimable by everyone
        register_concmd("say /fixspawns","cmdBadSpawn_Survivor",_," - Respawns all dead CTs")        //Global /fixspawn command (Kick)
        register_concmd("say /respawns","cmdBadSpawn_Zombie",_," - Respawns all dead Ts")        //Global /respawn command (Kick)
        register_concmd("bb_buildban","cmdBuildBan",_,"<player>")                                //Bans targeted player from building
        register_concmd("bb_unbuildban","cmdBuildUnban",_,"<player>")                                //Unbans  "          "    "    "
        register_concmd("bb_revive","cmdRevive",_,"<player>")                                        //revives targetted player
        register_concmd("bb_swap","cmdSwap",_,"<player>")                                        //swaps the selected player to the opposite team
        register_concmd("bb_startround","cmdStartRound",_," - Ends the build phase")                //do i really have to explain this?
       
        //Blocked Commands
        register_clcmd("drop", "clcmd_drop")
        register_clcmd("buy", "clcmd_buy")
       
        new tournymode = get_pcvar_num(g_pcvar_tournymode)
        if (tournymode != 1)
        {
                register_clcmd("chooseteam", "clcmd_changeteam")
                register_clcmd("jointeam", "clcmd_changeteam")
        }
       
        register_forward(FM_GetGameDescription, "fw_GetGameDescription")
        register_forward(FM_SetClientKeyValue, "fw_SetClientKeyValue")
        register_forward(FM_ClientUserInfoChanged, "fw_ClientUserInfoChanged")
        register_forward(FM_PlayerPreThink, "fw_Player_PreThink")
        register_forward(FM_ClientKill, "fw_Suicide")
        //register_forward(FM_CmdStart, "fw_CmdStart")
        if (get_pcvar_num(g_pcvar_showmovers) == 1)
                register_forward(FM_TraceLine, "fw_Traceline")
       
        RegisterHam(Ham_Touch, "weapon_shield", "ham_WeaponCleaner_Post", 1)
        RegisterHam(Ham_Touch, "weaponbox", "ham_WeaponCleaner_Post", 1)
        RegisterHam(Ham_Spawn, "player", "ham_PlayerSpawn_Post", 1)
        for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
                if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "ham_ItemDeploy_Post", 1)

       
        register_message(get_user_msgid("TextMsg"), "msgRoundEnd")
        register_message(get_user_msgid("StatusIcon"), "msgStatusIcon")
        register_message(get_user_msgid("StatusValue"), "msgStatusValue");
        if (tournymode != 1)
        {
                register_message(get_user_msgid("ShowMenu"), "message_show_menu")
                register_message(get_user_msgid("VGUIMenu"), "message_vgui_menu")
        }
       
        register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
        register_event("AmmoX", "ev_AmmoX", "be", "1=1", "1=2", "1=3", "1=4", "1=5", "1=6", "1=7", "1=8", "1=9", "1=10")
        register_event("StatusValue", "ev_SetTeam", "be", "1=1");
        register_event("StatusValue", "ev_ShowStatus", "be", "1=2", "2!0");
        register_event("StatusValue", "ev_HideStatus", "be", "1=1", "2=0");
        register_event("Health", "ev_Health", "be", "1>0");
        register_event("CurWeapon", "CurrentWeapon", "be", "1=1");
       
        register_logevent("logevent_round_start",2, "1=Round_Start")
        register_logevent("logevent_round_end", 2, "1=Round_End")
       
        register_menucmd(register_menuid("WeaponMethodMenu"),(1<<0)|(1<<1)|(1<<2),"weapon_method_pushed")
        register_menucmd(register_menuid("PrimaryWeaponSelect"),(1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9),"prim_weapons_pushed")
        register_menucmd(register_menuid("SecWeaponSelect"),(1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7),"sec_weapons_pushed")

        set_msg_block(get_user_msgid("ClCorpse"), BLOCK_SET)
       
        //Formats the Mod Name
        formatex(g_ModName, charsmax(g_ModName), "Base Builder %s", VERSION)
       
        register_dictionary("basebuilder.txt");
       
        gmsgSayText = get_user_msgid("SayText")
        gmsgStatusText = get_user_msgid("StatusText");
        gHudSyncInfo = CreateHudSyncObj();
        g_MaxPlayers = get_maxplayers()

        if (tournymode != 1)
        {
                server_cmd("mp_limitteams 1")
                server_cmd("mp_autoteambalance 1")
        }
        else
        {
                server_cmd("mp_limitteams 0")
                server_cmd("mp_autoteambalance 0")               
        }
        new roundnum = get_pcvar_num(g_pcvar_roundnum)
        server_cmd("mp_freezetime 0")
        server_cmd("mp_flashlight 0")
        server_cmd("mp_maxrounds %d", roundnum)
        server_cmd("mp_winlimit %d", roundnum)
        server_cmd("mp_roundtime %d", get_pcvar_num(g_pcvar_roundtime))
       
        g_iEntBarrier = find_ent_by_tname( -1, "barrier" );
}

public plugin_natives()
{       
        register_native("bb_build_time","native_build_time", 1)
}


public plugin_precache()
{
        new szModel[ 64 ];
        formatex( szModel, charsmax( szModel ), "models/player/%s/%s.mdl", g_ZombieModel, g_ZombieModel );
        engfunc( EngFunc_PrecacheModel, szModel );
       
        new szKnifeModel[ 64 ];
        formatex( szKnifeModel, charsmax( szKnifeModel ), "%s", g_ZombieKnifeModel );
        engfunc( EngFunc_PrecacheModel, szKnifeModel );
       
        engfunc( EngFunc_PrecacheSound, g_RoundStart )

        new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_bomb_target"))
        if (ent)
        {
                dllfunc(DLLFunc_Spawn, ent)
                set_pev(ent, pev_solid, SOLID_NOT)
        }
       
        new iBuyZone = create_entity("info_map_parameters");
        DispatchKeyValue(iBuyZone, "bombradius", "0");
        DispatchKeyValue(iBuyZone, "buying", "3");
        DispatchSpawn(iBuyZone);
}

public CurrentWeapon(id)
{
        if (g_iszombie[id])
        {
              set_pev(id, pev_viewmodel2, g_ZombieKnifeModel);
        }
        return PLUGIN_HANDLED;
}

// Event Round Start (This is before freeze time)
public event_round_start()
{
        g_RoundStartTime = get_gametime()
        g_ZombiesReleased = false
       
        if (get_pcvar_num(g_pcvar_resetent) == 1)
        {
                new cname[10], tname[7];
                for (new iEnt = g_MaxPlayers+1; iEnt < MAXENTS; iEnt++)
                {
                        if( is_valid_ent(iEnt) )
                        {
                                entity_get_string(iEnt, EV_SZ_classname, cname, 9);
                                entity_get_string(iEnt, EV_SZ_targetname, tname, 6);
                                if ( !IsBlockLocked(iEnt) && iEnt != g_iEntBarrier && equal(cname, "func_wall") && !equal(tname, "ignore"))
                                        engfunc( EngFunc_SetOrigin, iEnt, Float:{ 0.0, 0.0, 0.0 } );
                        }
                }
        }
}

public cmdHelp(id)
{
        set_hudmessage(255, 255, 255, -1.0, 0.45, 0, 1.0, 15.0, 0.1, 0.2, 2)
        new nLen, szHelp[512]
        nLen += format( szHelp[nLen], 511-nLen, "%L", LANG_SERVER, "WELCOME_MSG", VERSION);
        nLen += format( szHelp[nLen], 511-nLen, "%L", LANG_SERVER, "BIND_KEY");
        nLen += format( szHelp[nLen], 511-nLen, "%L", LANG_SERVER, "RULE1");
        nLen += format( szHelp[nLen], 511-nLen, "%L", LANG_SERVER, "RULE2");
        nLen += format( szHelp[nLen], 511-nLen, "%L", LANG_SERVER, "RULE3");
        nLen += format( szHelp[nLen], 511-nLen, "%L", LANG_SERVER, "RULE4");
        nLen += format( szHelp[nLen], 511-nLen, "%L", LANG_SERVER, "RULE5");
        show_hudmessage(id, szHelp);
}

// Log Event Round Start (This is AFTER freeze time)
public logevent_round_start()
{
        set_pev(g_iEntBarrier,pev_solid,SOLID_BSP)
        set_pev(g_iEntBarrier,pev_rendermode,1)
        DispatchKeyValue(g_iEntBarrier, "renderamt", "255");
       
        set_hudmessage(255, 255, 255, -1.0, 0.45, 0, 1.0, 10.0, 0.1, 0.2, 1)
        new nLen, szMsg[128]
        nLen += format( szMsg[nLen], 127-nLen, "%L", LANG_SERVER, "WELCOME_MSG", VERSION);
        nLen += format( szMsg[nLen], 127-nLen, "%L", LANG_SERVER, "BIND_KEY");
        show_hudmessage(0, szMsg);
       
        print_color(0, "%s %s ^x04- ^x01%L", formatmodname, VERSION, LANG_SERVER, "ROUND_MSG")
        print_color(0, "%s Round: %d of %d", formatmodname, (g_RoundNum+1), g_pcvar_maxrounds)
       
        remove_task(TASK_ROUND)
        remove_task(30000)
       
        new iBuildTime = get_pcvar_num( g_pcvar_buildtime );
        set_task(1.0, "CountDown", 30000, "", 0, "a", iBuildTime);
        count_down = (iBuildTime-1);
        set_task(float(iBuildTime), "Release_Zombies", TASK_ROUND)
       
        if (get_pcvar_num(g_pcvar_basecalc) == 1)
                set_task(5.0, "Base_Calc")
               
        set_task(5.0, "Fix_Spawns")
       
        g_CanBuild = true

        arrayset(g_MovingEnt, false, MAXENTS)
        arrayset(g_EntOwner, 0, MAXENTS)
        arrayset(g_OwnedEnts, 0, g_MaxPlayers+1)
}

public native_build_time() return g_CanBuild

public CountDown()
{
        set_hudmessage(255, 255, 255, -1.0, 0.0, 0, 0.1, 0.9, 0.1, 0.2, 3)
        show_hudmessage(0, "%L", LANG_SERVER, "BUILD_TIME", count_down--);
       
        if (count_down < 0)
        {
                remove_task(30000);
        }
}

//Resets stuff and swaps teams so they respawn correctly
public logevent_round_end()
{
        if (!g_CanBuild && get_pcvar_num(g_pcvar_tournymode) != 1)
        {
                new players[32], num
                get_players(players, num)
               
                new player
                for (new i = 0; i < num; i++)
                {
                        player = players[i]
                        cs_set_user_team(player, cs_get_user_team(player) == CS_TEAM_T ? CS_TEAM_CT:CS_TEAM_T)
                       
                        if (cs_get_user_team(player) == CS_TEAM_T)
                        {
                                g_iszombie[player] = true
                                g_ishuman[player] = false
                        }
                        if (cs_get_user_team(player) == CS_TEAM_CT)
                        {
                                g_ishuman[player] = true
                                g_iszombie[player] = false
                        }
                }
                print_color(0, "^x04%L", LANG_SERVER, "TEAMS_SWAPPED")
        }
       
        remove_task(TASK_ROUND)
        remove_task(30000)
               
        return PLUGIN_HANDLED
}

//Death events for respanws and HUD information
public client_death(g_attacker, g_victim, wpnindex, hitplace, TK)
{
        cmdStopEnt(g_victim)
       
        set_hudmessage(_, _, _, _, _, _, _, _, _, _, 4);
        show_hudmessage(g_victim, "");
       
        g_isalive[g_victim] = false
       
        if (g_iszombie[g_victim])
        {
                set_hudmessage(255, 255, 255, -1.0, 0.45, 0, 1.0, 10.0, 0.1, 0.2, 1)
                show_hudmessage(g_victim, "%L", LANG_SERVER, "DEAD_ZOMBIE", get_pcvar_num(g_pcvar_zresptime));
                set_task(get_pcvar_float(g_pcvar_zresptime), "Respawn_Zombie", g_victim)
        }
        if (g_ishuman[g_victim])
        {
                set_hudmessage(255, 255, 255, -1.0, 0.45, 0, 1.0, 10.0, 0.1, 0.2, 1)
                show_hudmessage(g_victim, "%L", LANG_SERVER, "DEAD_SURVIVOR");
        }
}

public ham_TakeDamage_Post(victim, inflictor, attacker, Float:damage, bits)
{
        if(get_pcvar_num(g_pcvar_knockback) == 1 && access(victim, PAIN_SHOCK_FREE) && g_iszombie[victim])
        {
                set_pdata_float(victim, fPainShock, 1.0, 5)
        }
}

public client_disconnect(id)
{
        cmdStopEnt(id)

        g_isconnected[id] = false
        g_isalive[id] = false
        g_ishuman[id] = false
        g_iszombie[id] = false

        return PLUGIN_CONTINUE
}

//Respawns late joiners, cts only if build time is still on
public client_putinserver(id)
{
        set_task(7.0,"Respawn_Human",id);
        g_isconnected[id] = true
        firsttime[id] = true
        ask[id] = true
}

public Release_Zombies()
{
        g_CanBuild = false
        g_ZombiesReleased = true
        remove_task(30000);
       
        new players[32], num
        get_players(players, num)

        new player
        for(new i = 0; i < num; i++)
        {
                player = players[i]
                if (g_isalive[player])
                {
                        if (get_user_godmode(player))
                                set_user_godmode(player, 0)
                        if (g_ishuman[player])
                        {
                                cmdStopEnt(player)

                                new weapon[32]
                                get_pcvar_string(g_pcvar_givenades,weapon,31)
                       
                                new he, flash, smoke
                                for(new i=0;i<strlen(weapon);i++)
                                {
                                        switch(weapon[i])
                                        {
                                                case 'h': he++
                                                case 'f': flash++
                                                case 's': smoke++
                                        }
                                }
                                if(he) give_item(player,"weapon_hegrenade"), cs_set_user_bpammo(player,CSW_HEGRENADE,he)
                                if(flash) give_item(player,"weapon_flashbang"), cs_set_user_bpammo(player,CSW_FLASHBANG,flash)
                                if(smoke) give_item(player,"weapon_smokegrenade"), cs_set_user_bpammo(player,CSW_SMOKEGRENADE,smoke)
                               
                                if (g_PrimaryWeapon[player])
                                {
                                        get_weaponname(g_PrimaryWeapon[player],weapon,31)
                                        engclient_cmd(player, weapon);
                                }
                        }
                }
        }
                       
        set_pev(g_iEntBarrier,pev_solid,SOLID_NOT)
        DispatchKeyValue(g_iEntBarrier, "renderamt", "0");
       
        g_RoundNum++
        set_hudmessage(255, 255, 255, -1.0, 0.45, 0, 1.0, 10.0, 0.1, 0.2, 1)
        show_hudmessage(0, "%L", LANG_SERVER, "RELEASE_MSG");
        client_cmd(0, "spk %s", g_RoundStart)
}

//Called on zombie death function
public Respawn_Zombie(id)
{
        if (g_isconnected[id] && cs_get_user_team(id) == CS_TEAM_T)
        {
                if (get_user_health(id) == get_pcvar_float(g_pcvar_zombiehp) || !is_user_alive(id))
                        ExecuteHamB(Ham_CS_RoundRespawn, id)
                else
                        client_print(id, print_center, "%L", LANG_SERVER, "FAIL_RESPAWN");
        }
}

//Called on all players for late joiners, parent is above
public Respawn_Human(id)
{
        if (!g_isconnected[id] || g_isalive[id] || cs_get_user_team(id) == CS_TEAM_SPECTATOR || cs_get_user_team(id) == CS_TEAM_UNASSIGNED)
                return PLUGIN_HANDLED
               
        if (!g_isalive[id] && g_iszombie[id])
                ExecuteHamB(Ham_CS_RoundRespawn, id)
                               
        if (!g_isalive[id] && g_iszombie[id])
                set_task(3.0,"Respawn_Human",id)
                       
        if (g_CanBuild)
        {
                if (!g_isalive[id])
                        ExecuteHamB(Ham_CS_RoundRespawn, id)
                               
                if (!g_isalive[id])
                        set_task(3.0,"Respawn_Human",id)
        }
        return PLUGIN_HANDLED
}

//Sets player health and weapons
public Add_Effects(id)
{
        if (!g_isconnected[id] || !g_isalive[id])
                return PLUGIN_HANDLED
       
        strip_user_weapons(id)
        give_item(id, "weapon_knife")
       
        if (cs_get_user_team(id) == CS_TEAM_T)
        {
                if (g_CanBuild)
                        set_user_godmode(id, 1)

                set_pev(id, pev_health, get_pcvar_float(g_pcvar_zombiehp)) // use decimal number
        }
        if (cs_get_user_team(id) == CS_TEAM_CT)
        {
                weapon_method_menu(id)
        }
        ShowHealth(id)
        return PLUGIN_HANDLED
}

//AmmoX Ensures BackPack ammo is always full
public ev_AmmoX(id)
{
        set_pdata_int(id, AMMO_SLOT + read_data(1), 200, 5)
}

public fw_GetGameDescription()
{
        forward_return(FMV_STRING, g_ModName)
       
        return FMRES_SUPERCEDE;
}

public ham_PlayerSpawn_Post(id)
{
        if (!is_user_alive(id) || !cs_get_user_team(id))
                return
               
        set_task(1.0, "Add_Effects", id)
        if (cs_get_user_team(id) == CS_TEAM_CT)
        {
                g_ishuman[id] = true
                g_iszombie[id] = false
        }
        if (cs_get_user_team(id) == CS_TEAM_T)
        {
                g_iszombie[id] = true
                g_ishuman[id] = false
        }
               
        g_isalive[id] = true
        remove_task(id + MODELSET_TASK)
        if (g_iszombie[id])
        {
                copy(g_PlayerModel[id], charsmax(g_PlayerModel[]), g_ZombieModel)
                new currentmodel[32]
                fm_get_user_model(id, currentmodel, charsmax(currentmodel))
                if (!equal(currentmodel, g_PlayerModel[id]))
                {
                        if (get_gametime() - g_RoundStartTime < 5.0)
                                set_task(5.0 * MODELCHANGE_DELAY, "fm_user_model_update", id + MODELSET_TASK)
                        else
                                fm_user_model_update(id + MODELSET_TASK)
                }
        }
        else if (g_HasCustomModel[id])
        {
                fm_reset_user_model(id)
        }
}

public fw_SetClientKeyValue(id, const infobuffer[], const key[])

        if (g_HasCustomModel[id] && equal(key, "model"))
                return FMRES_SUPERCEDE
        return FMRES_IGNORED
}

public fw_ClientUserInfoChanged(id)
{
        if (!g_HasCustomModel[id])
                return FMRES_IGNORED
        static currentmodel[32]
        fm_get_user_model(id, currentmodel, charsmax(currentmodel))
        if (!equal(currentmodel, g_PlayerModel[id]) && !task_exists(id + MODELSET_TASK))
                fm_set_user_model(id + MODELSET_TASK)
        return FMRES_IGNORED
}

public fm_user_model_update(taskid)
{
        static Float:current_time
        current_time = get_gametime()
       
        if (current_time - g_ModelsTargetTime >= MODELCHANGE_DELAY)
        {
                fm_set_user_model(taskid)
                g_ModelsTargetTime = current_time
        }
        else
        {
                set_task((g_ModelsTargetTime + MODELCHANGE_DELAY) - current_time, "fm_set_user_model", taskid)
                g_ModelsTargetTime = g_ModelsTargetTime + MODELCHANGE_DELAY
        }
}

public fm_set_user_model(player)
{
        player -= MODELSET_TASK
        engfunc(EngFunc_SetClientKeyValue, player, engfunc(EngFunc_GetInfoKeyBuffer, player), "model", g_PlayerModel[player])
        g_HasCustomModel[player] = true
}

stock fm_get_user_model(player, model[], len)
{
        engfunc(EngFunc_InfoKeyValue, engfunc(EngFunc_GetInfoKeyBuffer, player), "model", model, len)
}

stock fm_reset_user_model(player)
{
        g_HasCustomModel[player] = false
        dllfunc(DLLFunc_ClientUserInfoChanged, player, engfunc(EngFunc_GetInfoKeyBuffer, player))
}

public cmdMoveEnt(id)
{
        if (g_BuildBan[id] == true)
                return PLUGIN_HANDLED
       
        if (g_iszombie[id] && !access(id, AFTER_BUILD))
                      return PLUGIN_HANDLED
                       
        if (!g_CanBuild && !access(id, AFTER_BUILD))
        {
                client_print (id, print_center, "%L", LANG_SERVER, "FAIL_TIME_UP")
                return PLUGIN_HANDLED
        }
       
        if (!g_isalive[id] && !access(id, DEAD_BUILD))
        {
                client_print (id, print_center, "%L", LANG_SERVER, "FAIL_DEAD")
                return PLUGIN_HANDLED
        }

        if (g_pEnt[id] && is_valid_ent(g_pEnt[id]))
                cmdStopEnt(id)
       
        new ent, bodypart
        get_user_aiming (id,ent,bodypart)
       
        if (!is_valid_ent(ent) || ent == g_iEntBarrier)
        {
                return PLUGIN_HANDLED
        }
       
        if (ent <= g_MaxPlayers && g_isalive[ent])
        {       
                return PLUGIN_HANDLED
        }
               
        if (IsBlockLocked(ent) || g_MovingEnt[ent])
        {
                return PLUGIN_HANDLED
        }

        if (get_pcvar_num(g_pcvar_claimable) == 1)
        {
                if (!g_EntOwner[ent])
                {
                        if ((g_OwnedEnts[id]<get_pcvar_num(g_pcvar_maxclaimable)) || get_pcvar_num(g_pcvar_maxclaimable) == 0)
                        {
                                g_EntOwner[ent] = id
                                g_OwnedEnts[id]++
                        }
                        else
                        {
                                client_print (id, print_center, "%L", LANG_SERVER, "FAIL_MAXOWNED", get_pcvar_num(g_pcvar_maxclaimable))
                                //return PLUGIN_HANDLED
                        }
                }
                else if (g_EntOwner[ent] != id && !access(id, AFTER_BUILD))
                {
                        client_print (id, print_center, "%L", LANG_SERVER, "FAIL_ALREADYOWNED")
                        return PLUGIN_HANDLED
                }
        }
       
        new tname[7], cname[10];
        entity_get_string(ent, EV_SZ_targetname, tname, 6);
        entity_get_string(ent, EV_SZ_classname, cname, 9);
        if (!equal(cname, "func_wall") || equal(tname, "ignore"))
        {
                return PLUGIN_HANDLED
        }
       
        new origin[3], entOrigin[3], Float:orig[3], Float:mins[3], Float:maxs[3], dist
       
        entity_get_vector(ent, EV_VEC_origin, orig);
        entity_get_vector(ent, EV_VEC_mins, mins);
        entity_get_vector(ent, EV_VEC_maxs, maxs);

        entOrigin[0] = floatround((mins[0] + maxs[0]) / 2 + orig[0]);
        entOrigin[1] = floatround((mins[1] + maxs[1]) / 2 + orig[1]);
        entOrigin[2] = floatround((mins[2] + maxs[2]) / 2 + orig[2]);
       
        get_user_origin(id, origin);

        dist = get_distance(origin, entOrigin);
       
        new max = get_pcvar_num(g_pcvar_entmaxdist)
        new min = get_pcvar_num(g_pcvar_entmindist)
        if (min) //min
        {
                if(dist < min) //minimum
                        dist = get_pcvar_num(g_pcvar_entsetdist);
        }

        if (max) //maximum
        {
                if (dist > max)
                        return PLUGIN_HANDLED
        }
       
        DispatchKeyValue(ent, "rendermode", "1");
        DispatchKeyValue(ent, "renderamt", "100");
        DispatchKeyValue(ent, "rendercolor", "135.0 206.0 235.0");

        g_MovingEnt[ent] = true
        g_EntMover[ent] = id
        g_pEnt[id] = ent
        g_pDist[id] = dist
       
        if (!g_CanBuild && access(id, AFTER_BUILD))
        {
                new adminauthid[35],adminname[35]
                get_user_authid (id,adminauthid,34)
                get_user_name(id,adminname,34)
                Log("[MOVE] Admin: %s || SteamID: %s moved an entity", adminname, adminauthid)
        }
       
        return PLUGIN_HANDLED
}

/*public fw_CmdStart(id, uc, random)
{
        new buttons = get_uc(uc, UC_Buttons)
        if(g_CanBuild && (buttons & IN_ATTACK))
        {
                buttons &= ~IN_ATTACK
                set_uc(uc, UC_Buttons, buttons)
                return FMRES_SUPERCEDE
        }
        return FMRES_IGNORED
}*/

public fw_Player_PreThink(id)
{
        if (!g_pEnt[id] || !is_valid_ent(g_pEnt[id]))
                return FMRES_HANDLED
       
        new buttons = pev(id, pev_button)
        if(buttons & IN_ATTACK)
        {
                g_pDist[id] += 3;
               
                if (g_pDist[id] > get_pcvar_num(g_pcvar_entmaxdist))
                {
                        g_pDist[id] = get_pcvar_num(g_pcvar_entmaxdist)
                        client_print(id, print_center, "%L", LANG_SERVER, "OBJECT_MAX")
                }
                else
                        client_print(id, print_center, "%L", LANG_SERVER, "OBJECT_PUSH")
        }
        else if(buttons & IN_ATTACK2)
        {
                g_pDist[id] -= 3;
                       
                if (g_pDist[id] < get_pcvar_num(g_pcvar_entsetdist))
                {
                        g_pDist[id] = get_pcvar_num(g_pcvar_entsetdist)
                        client_print(id, print_center, "%L", LANG_SERVER, "OBJECT_MIN")
                }
                else
                        client_print(id, print_center, "%L", LANG_SERVER, "OBJECT_PULL")
        }
       
        GrabThink(id)
       
        return FMRES_HANDLED
}

public GrabThink(id)
{
        new Float:aiming[3], origin[3], Float:mins[3], Float:maxs[3], Float:neworigin[3], ent
       
        ent = g_pEnt[id]

        if (!g_isconnected[id] || (ent <= g_MaxPlayers)? !g_isconnected[id]:!is_valid_ent(ent))
        {
                cmdStopEnt(id)
                return PLUGIN_HANDLED
        }
       
        entity_get_vector(ent, EV_VEC_mins, mins);
        entity_get_vector(ent, EV_VEC_maxs, maxs);
       
        get_user_origin(id, origin, 3);
        IVecFVec(origin, aiming);
        get_user_origin(id, origin);
       
        aiming[0] -= float(origin[0]);
        aiming[1] -= float(origin[1]);
        aiming[2] -= float(origin[2]);

        new Float:scalar = float(g_pDist[id]) / vector_length(aiming);

        origin[0] += floatround(aiming[0] * scalar - (mins[0] + maxs[0]) / 2);
        origin[1] += floatround(aiming[1] * scalar - (mins[1] + maxs[1]) / 2);
        origin[2] += floatround(aiming[2] * scalar - (mins[2] + maxs[2]) / 2);
       
        IVecFVec(origin, neworigin);
        entity_set_origin(ent, neworigin);
       
        return PLUGIN_CONTINUE
}

public cmdStopEnt(id)
{
        g_MovingEnt[g_pEnt[id]] = false
        DispatchKeyValue(g_pEnt[id], "rendermode", "0");
        DispatchKeyValue(g_pEnt[id], "renderamt", "255");
        DispatchKeyValue(g_pEnt[id], "rendercolor", "0.0 0.0 0.0");
        if (get_pcvar_num(g_pcvar_blockgrav) == 1)
                drop_to_floor(g_pEnt[id])
        g_EntMover[g_pEnt[id]] = 0
        g_LastMover[g_pEnt[id]] = id
        g_pEnt[id] = 0
}

public fw_Traceline(Float:start[3], Float:end[3], conditions, id, trace)
{
        if (!is_user_connected(id)) return PLUGIN_HANDLED
       
        new ent = get_tr2(trace, TR_pHit)
       
        if (pev_valid(ent))
        {
                new ent,body
                get_user_aiming(id,ent,body)
               
                new cname[10], tname[7];
                entity_get_string(ent, EV_SZ_classname, cname, 9);
                entity_get_string(ent, EV_SZ_targetname, tname, 6);
                if (equal(cname, "func_wall") && !equal(tname, "ignore") && ent != g_iEntBarrier && get_pcvar_num(g_pcvar_showmovers) == 1)
                {
                        if (g_CanBuild || access(id, ADMIN_KICK))
                        {
                                if (IsBlockLocked(ent))
                                {
                                        set_hudmessage(255, 0, 0, -1.0, 0.55, 1, 0.01, 3.0, 0.01, 0.01);
                                        ShowSyncHudMsg(id, gHudSyncInfo, "%L", LANG_SERVER, "OBJECT_LOCKED");
                                        return PLUGIN_HANDLED
                                }
                                set_hudmessage(0, 50, 255, -1.0, 0.55, 1, 0.01, 3.0, 0.01, 0.01);
                                if (get_pcvar_num(g_pcvar_claimable) == 0)
                                {
                                        new currentmover[35], lastmover[35]
                                        if (g_EntMover[ent])
                                        {
                                                get_user_name(g_EntMover[ent],currentmover,34)
                                                if (!g_LastMover[ent]) ShowSyncHudMsg(id, gHudSyncInfo, "%L", LANG_SERVER, "OBJECT_INFO1", currentmover);
                                        }
                                        if (g_LastMover[ent])
                                        {
                                                get_user_name(g_LastMover[ent],lastmover,34)
                                                if (!g_EntMover[ent]) ShowSyncHudMsg(id, gHudSyncInfo, "%L", LANG_SERVER, "OBJECT_INFO2", lastmover);
                                        }
                                        if (g_LastMover[ent] && g_EntMover[ent]) ShowSyncHudMsg(id, gHudSyncInfo, "%L", LANG_SERVER, "OBJECT_INFO3", currentmover, lastmover);
                                        else if (!g_LastMover[ent] && !g_EntMover[ent]) ShowSyncHudMsg(id, gHudSyncInfo, "%L", LANG_SERVER, "OBJECT_INFO4");
                                }
                                else
                                {
                                        if (g_EntOwner[ent])
                                        {
                                                new entowner[35]
                                                get_user_name(g_EntOwner[ent],entowner,34)
                                                ShowSyncHudMsg(id, gHudSyncInfo, "%L", LANG_SERVER, "OBJECT_OWNER", entowner);
                                        }
                                        else
                                        {
                                                ShowSyncHudMsg(id, gHudSyncInfo, "%L", LANG_SERVER, "OBJECT_OWNER_NONE");
                                        }
                                }
                        }
                }
        }
        if (!pev_valid(ent)) ClearSyncHud(id, gHudSyncInfo);
       
        return PLUGIN_HANDLED
}

public cmdLockBlock(id)
{
        if (!access(id, LOCK_BLOCKS))
                return PLUGIN_HANDLED
               
        new ent, bodypart
        get_user_aiming (id,ent,bodypart)
       
        new tname[7], cname[10];
        entity_get_string(ent, EV_SZ_targetname, tname, 6);
        entity_get_string(ent, EV_SZ_classname, cname, 9);

        if (!ent || !is_valid_ent(ent) || is_user_alive(ent) || ent == g_iEntBarrier || !equal(cname, "func_wall") || equal(tname, "ignore")) return PLUGIN_HANDLED
       
        if (!IsBlockLocked(ent) && !g_MovingEnt[ent])
        {
                LockBlock(ent)
                DispatchKeyValue(ent, "rendermode", "1");
                DispatchKeyValue(ent, "rendercolor", "125.0 0.0 0.0");
               
                g_OwnedEnts[g_EntOwner[ent]]--
                g_EntOwner[ent] = 0
        }
        else if (IsBlockLocked(ent))
        {
                UnlockBlock(ent)
                DispatchKeyValue(ent, "rendermode", "0");
        }
        return PLUGIN_HANDLED
}

public cmdRemoveClaim(id)
{
        if (!access(id, LOCK_BLOCKS))
                      return PLUGIN_HANDLED
               
        new ent, bodypart
        get_user_aiming (id,ent,bodypart)
       
        new tname[7], cname[10];
        entity_get_string(ent, EV_SZ_targetname, tname, 6);
        entity_get_string(ent, EV_SZ_classname, cname, 9);

        if (!ent || !is_valid_ent(ent) || is_user_alive(ent) || ent == g_iEntBarrier || !equal(cname, "func_wall") || equal(tname, "ignore") || IsBlockLocked(ent)) return PLUGIN_HANDLED

        g_OwnedEnts[g_EntOwner[ent]]--
        g_EntOwner[ent] = 0
       
        return PLUGIN_HANDLED
}

public cmdRemoveEnt(id)
{
        if (!access(id, REMOVE_BLOCK))
                      return PLUGIN_HANDLED

        if (!g_isalive[id] && !access(id, DEAD_REMOVE))
        {
                client_print (id, print_center, "%L", LANG_SERVER, "FAIL_REMOVE")
                return PLUGIN_HANDLED
        }
             
        new ent, bodypart
        get_user_aiming (id,ent,bodypart)
       
        if(!is_valid_ent(ent) || ent == g_iEntBarrier || (ent <= g_MaxPlayers && g_isalive[ent]))
                return PLUGIN_HANDLED
       
        if(IsBlockLocked(ent) || g_MovingEnt[ent])
                return PLUGIN_HANDLED

        new tname[7], cname[10];
        entity_get_string(ent, EV_SZ_targetname, tname, 6);
        entity_get_string(ent, EV_SZ_classname, cname, 9);
        if(!equal(cname, "func_wall"))
                return PLUGIN_HANDLED
       
        if(equal(tname, "ignore"))
                return PLUGIN_HANDLED
               
        g_OwnedEnts[g_EntOwner[ent]]--
        g_EntOwner[ent] = 0
       
        remove_entity(ent)
       
        new adminauthid[35],adminname[35]
        get_user_authid (id,adminauthid,34)
        get_user_name(id,adminname,34)
        Log("[REMOVE] Admin: %s || SteamID: %s removed an entity", adminname, adminauthid)
       
        return PLUGIN_HANDLED
}

// Ham Weapon Deploy Forward (forces knife only)
public ham_ItemDeploy_Post(weapon_ent)
{
        static owner
        owner = get_pdata_cbase(weapon_ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS);
       
        static weaponid
        weaponid = cs_get_weapon_id(weapon_ent)
       
        g_CurrentWeapon[owner] = weaponid
       
        if (g_iszombie[owner] && !((1<<weaponid) & ZOMBIE_ALLOWED_WEAPONS_BITSUM))
        {
                g_CurrentWeapon[owner] = CSW_KNIFE
                engclient_cmd(owner, "weapon_knife")
        }
        else if (g_CanBuild && g_ishuman[owner])
        {
                g_CurrentWeapon[owner] = CSW_KNIFE
                engclient_cmd(owner, "weapon_knife")
                client_print(owner, print_center, "%L", LANG_SERVER, "FAIL_KNIFE_ONLY");
        }
}

public msgRoundEnd(const MsgId, const MsgDest, const MsgEntity)
{
        static Message[192]
        get_msg_arg_string(2, Message, 191)
       
        set_hudmessage(255, 255, 255, -1.0, 0.40, 0, 6.0, 6.0, 0.1, 0.2, 1)
       
        if(equal(Message, "#Game_bomb_drop"))
                return PLUGIN_HANDLED
       
        if (equal(Message, "#Terrorists_Win"))
        {
                show_hudmessage(0, "Zombies Win!")
                set_msg_arg_string(2, "")
                switch (random_num(1, 4))
                {
                        case 1: client_cmd(0, "spk ambience/the_horror1.wav")
                        case 2: client_cmd(0, "spk ambience/the_horror2.wav")
                        case 3: client_cmd(0, "spk ambience/the_horror3.wav")
                        case 4: client_cmd(0, "spk ambience/the_horror4.wav")
                }
                return PLUGIN_HANDLED
        }
        else if (equal(Message, "#Target_Saved") || equal(Message, "#CTs_Win"))
        {
                show_hudmessage(0, "Builders Win!")
                set_msg_arg_string(2, "")
                switch (random_num(1, 3))
                {
                        case 1: client_cmd(0, "spk barney/ba_another.wav")
                        case 2: client_cmd(0, "spk barney/ba_firepl.wav")
                        case 3: client_cmd(0, "spk barney/ba_seethat.wav")
                }
                return PLUGIN_HANDLED
        }
        return PLUGIN_HANDLED
}

public ham_WeaponCleaner_Post(iEntity)
{
        call_think(iEntity)
}

public message_show_menu(msgid, dest, id)
{
        if (!should_autojoin(id))
                return PLUGIN_CONTINUE

        static team_select[] = "#Team_Select"
        static menu_text_code[sizeof team_select]
        get_msg_arg_string(4, menu_text_code, sizeof menu_text_code - 1)
        if (!equal(menu_text_code, team_select))
                return PLUGIN_CONTINUE

        set_force_team_join_task(id, msgid)

        return PLUGIN_HANDLED
}

public message_vgui_menu(msgid, dest, id)
{
        if (get_msg_arg_int(1) != TEAM_SELECT_VGUI_MENU_ID || !should_autojoin(id))
                return PLUGIN_CONTINUE
               
        set_force_team_join_task(id, msgid)

        return PLUGIN_HANDLED
}

bool:should_autojoin(id)
{
        return (!get_user_team(id))
}

set_force_team_join_task(id, menu_msgid)
{
        static param_menu_msgid[2]
        param_menu_msgid[0] = menu_msgid
        set_task(AUTO_TEAM_JOIN_DELAY, "task_force_team_join", id, param_menu_msgid, sizeof param_menu_msgid)
}

public task_force_team_join(menu_msgid[], id)
{
        if (get_user_team(id))
                return

        static team[2], class[2]
        get_pcvar_string(g_pcvar_team, team, sizeof team - 1)
        get_pcvar_string(g_pcvar_class, class, sizeof class - 1)
        force_team_join(id, menu_msgid[0], team, class)
}

stock force_team_join(id, menu_msgid, /* const */ team[] = "5", /* const */ class[] = "0")
{
        static jointeam[] = "jointeam"
        if (class[0] == '0') {
                engclient_cmd(id, jointeam, team)
                return
        }

        static msg_block, joinclass[] = "joinclass"
        msg_block = get_msg_block(menu_msgid)
        set_msg_block(menu_msgid, BLOCK_SET)
        engclient_cmd(id, jointeam, team)
        engclient_cmd(id, joinclass, class)
        set_msg_block(menu_msgid, msg_block)
}

public clcmd_changeteam(id)
{
        if (g_CanBuild)
                weapon_method_menu(id)
        else
                client_print (id, print_center, "%L", LANG_SERVER, "FAIL_WEAPONS")
       
        if (g_iszombie[id])
                client_print (id, print_center, "%L", LANG_SERVER, "FAIL_ZOMBIE")
               
        return PLUGIN_HANDLED
}

public clcmd_drop(id)
{
        client_print (id, print_center, "%L", LANG_SERVER, "FAIL_DROP")
        return PLUGIN_HANDLED
}

public clcmd_buy(id)
{
        client_print (id, print_center, "%L", LANG_SERVER, "FAIL_BUY")
        return PLUGIN_HANDLED
}

public fw_Suicide(id)
{
        client_print (id, print_center, "%L", LANG_SERVER, "FAIL_SUICIDE")
        console_print (id, "%L", LANG_SERVER, "FAIL_SUICIDE")
        return FMRES_SUPERCEDE;
}

public Base_Calc()
{
        new players[32], num, ct, basenum
        get_players(players, num)
        new player
        for(new i = 0; i < num; i++)
        {
                player = players[i]
                if (cs_get_user_team(player) == CS_TEAM_CT)
                        ct++

                if (ct < 6)
                        basenum = 2
                else
                        basenum = (ct/3)
        }
        print_color(0, "%s %L", formatmodname, LANG_SERVER, "BASE_CALC", basenum)
}

public cmdBadSpawn_Survivor(id)
{
        if (access(id, BAD_SPAWN))
        {
                new players[32], num
                get_players(players, num)
                       
                new player
                for(new i = 0; i < num; i++)
                {
                        player = players[i]
                        if (cs_get_user_team(player) == CS_TEAM_CT && !is_user_alive(player) && g_isconnected[player] && g_CanBuild)
                                ExecuteHamB(Ham_CS_RoundRespawn, player)
                }
        }
}

public Fix_Spawns()
{
        new players[32], num
        get_players(players, num)
                       
        new player
        for(new i = 0; i < num; i++)
        {
                player = players[i]
                if (cs_get_user_team(player) == CS_TEAM_CT && !is_user_alive(player) && g_isconnected[player] && g_CanBuild)
                        ExecuteHamB(Ham_CS_RoundRespawn, player)
        }
}

public cmdBadSpawn(id)
{
        if (g_isconnected[id] && g_ishuman[id] && g_CanBuild)
                ExecuteHamB(Ham_CS_RoundRespawn, id)
}

public cmdBadSpawn_Zombie(id)
{
        if (access(id, BAD_SPAWN))
        {
                new players[32], num
                get_players(players, num)
                       
                new player
                for(new i = 0; i < num; i++)
                {
                        player = players[i]
                        if (cs_get_user_team(player) == CS_TEAM_T && !is_user_alive(player) && g_isconnected[player])
                                ExecuteHamB(Ham_CS_RoundRespawn, player)
                }
        }
}

public msgStatusIcon(const iMsgId, const iMsgDest, const iPlayer)
{
        if(is_user_alive(iPlayer))
        {
                static szMsg[8]
                get_msg_arg_string(2, szMsg, 7)
   
                if(equal(szMsg, "buyzone"))
                {
                        set_pdata_int(iPlayer, OFFSET_BUYZONE, get_pdata_int(iPlayer, OFFSET_BUYZONE) & ~(1<<0))
                        return PLUGIN_HANDLED
                }
        }
        return PLUGIN_CONTINUE
}

public cmdBuildBan(id)
{
        if (access(id, BUILD_BAN))
        {
                new arg[32]
                read_argv(1, arg, 31)
                new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY)
                g_BuildBan[player] = true
                cmdStopEnt(player)
               
                new adminauthid[35],adminname[35],playername[35],playerauthid[35]
                get_user_name(id,adminname,34)
                get_user_authid (id,adminauthid,34)
                get_user_name(player, playername, 34)
                get_user_authid (player,playerauthid,34)
                Log("[MOVE] Admin: %s || SteamID: %s banned Player: %s || SteamID: %s from building", adminname, adminauthid, playername, playerauthid)
               
                client_print(id, print_console, "%L", LANG_SERVER, "BUILD_BAN1", playername)
                client_print(player, print_center, "%L", LANG_SERVER, "BUILD_BAN2")
        }
}

public cmdBuildUnban(id)
{
        if (access(id, BUILD_BAN))
        {
                new arg[32], playername[35]
       
                read_argv(1, arg, 31)
                new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY)
                get_user_name(player, playername, 34)
                client_print(id, print_console, "%L", LANG_SERVER, "UNBUILD_BAN1", playername)
                g_BuildBan[player] = false
                print_color(player, "%s %L", formatmodname, LANG_SERVER, "UNBUILD_BAN2")
        }
}

public cmdRevive(id)
{
        if (access(id, REVIVE))
        {
                new arg[32]
                read_argv(1, arg, 31)
                new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY)

                if (is_user_alive(player))
                {
                        client_print(id, print_console, "%L", LANG_SERVER, "FAIL_REVIVE")
                        return PLUGIN_HANDLED
                }
               
                ExecuteHamB(Ham_CS_RoundRespawn, player)
               
                new adminauthid[35],adminname[35],playername[35],playerauthid[35]
                get_user_name(id,adminname,34)
                get_user_authid (id,adminauthid,34)
                get_user_name(player, playername, 34)
                get_user_authid (player,playerauthid,34)
                Log("[REVIVE] Admin: %s || SteamID: %s revived Player: %s || SteamID: %s", adminname, adminauthid, playername, playerauthid)
               
                client_print(id, print_console, "%L", LANG_SERVER, "REVIVE1", playername)
                client_print(player, print_center, "%L", LANG_SERVER, "REVIVE2")
        }
        return PLUGIN_HANDLED
}

public cmdSwap(id)
{
        if (access(id, SWAP))
        {
                new arg[32]
                read_argv(1, arg, 31)
                new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY)

                if (!is_user_connected(player)) return PLUGIN_HANDLED
               
                cs_set_user_team(player, cs_get_user_team(player) == CS_TEAM_T ? CS_TEAM_CT:CS_TEAM_T)
                       
                if (cs_get_user_team(player) == CS_TEAM_T)
                {
                        g_iszombie[player] = true
                        g_ishuman[player] = false
                }
                if (cs_get_user_team(player) == CS_TEAM_CT)
                {
                        g_ishuman[player] = true
                        g_iszombie[player] = false
                }
               
                if (is_user_alive(player))
                        ExecuteHamB(Ham_CS_RoundRespawn, player)
               
                new adminauthid[35],adminname[35],playername[35],playerauthid[35]
                get_user_name(id,adminname,34)
                get_user_authid (id,adminauthid,34)
                get_user_name(player, playername, 34)
                get_user_authid (player,playerauthid,34)
                Log("[TEAM-SWAP] Admin: %s || SteamID: %s swapped Player: %s || SteamID: %s", adminname, adminauthid, playername, playerauthid)
               
                client_print(id, print_console, "%L", LANG_SERVER, "SWAP1", playername)
                client_print(player, print_center, "%L", LANG_SERVER, "SWAP2")
        }
        return PLUGIN_HANDLED
}

public cmdStartRound(id)
{
        if (access(id, START_ROUND))
        {
                if (count_down<10)
                {
                        client_print(id, print_console, "%L", LANG_SERVER, "FAIL_START_ROUND")
                        return PLUGIN_HANDLED
                }
               
                Release_Zombies()
               
                new adminauthid[35],adminname[35]
                get_user_name(id,adminname,34)
                get_user_authid (id,adminauthid,34)
                Log("[START_ROUND] Admin: %s || SteamID: %s started the round", adminname, adminauthid)
               
                client_print(id, print_center, "%L", LANG_SERVER, "START_ROUND")
                client_print(id, print_chat, "^x04%L", LANG_SERVER, "START_ROUND")
        }
        return PLUGIN_HANDLED
}

public cmdCheckRound(id)
{
        if (g_ZombiesReleased) print_color(id, "%s Round: %d of %d", formatmodname, (g_RoundNum), g_pcvar_maxrounds)
        else if (!g_ZombiesReleased) print_color(id, "%s Round: %d of %d", formatmodname, (g_RoundNum+1), g_pcvar_maxrounds)
}

public msgStatusValue()
{
        //Block the name info, of person you aim at
        set_msg_block(gmsgStatusText, BLOCK_SET);
}

public ev_SetTeam(id)
{
        g_friend[id] = read_data(2)
}

public ev_ShowStatus(id) //called when id looks at someone
{
        new name[32], pid = read_data(2);
        new stats[8],bodyhits[8]
       
        get_user_name(pid, name, 31);
        new color1 = 0, color2 = 0;

        if (get_user_team(pid) == 1)
                color1 = 255;
        else
                color2 = 255;

        new Float:height=0.35
        //height=0.60

        if (g_friend[id] == 1)        // friend
        {
                new clip, ammo, wpnid = get_user_weapon(pid, clip, ammo);
                new wpnname[32];

                if (wpnid)
                        xmod_get_wpnname(wpnid, wpnname, 31);

                new rank = get_user_stats(pid, stats, bodyhits)
               
                if(g_iszombie[id])
                {
                        set_hudmessage(color1, 50, color2, -1.0, height, 1, 0.01, 3.0, 0.01, 0.01);
                        ShowSyncHudMsg(id, gHudSyncInfo, "> [X] BaseBuilder <^n%L", LANG_SERVER, "PLAYER_INFO1", name, rank, get_user_health(pid), wpnname);
                }
                else if(g_ishuman[id])
                {
                        set_hudmessage(color1, 50, color2, -1.0, height, 1, 0.01, 3.0, 0.01, 0.01);
                        ShowSyncHudMsg(id, gHudSyncInfo, "> [X] BaseBuilder <^n%L", LANG_SERVER, "PLAYER_INFO1", name, rank, get_user_health(pid), wpnname);
                }
                       
        }
        if (g_friend[id] != 1) //enemy
        {
                new clip, ammo, wpnid = get_user_weapon(pid, clip, ammo);
                new wpnname[32];

                if (wpnid)
                        xmod_get_wpnname(wpnid, wpnname, 31);

                new rank = get_user_stats(pid, stats, bodyhits)
               
                if(g_iszombie[id])
                {
                        set_hudmessage(color1, 50, color2, -1.0, height, 1, 0.01, 3.0, 0.01, 0.01);
                        ShowSyncHudMsg(id, gHudSyncInfo, "> [X] BaseBuilder <^n%L", LANG_SERVER, "PLAYER_INFO2", name, rank, get_user_health(pid), wpnname);
                }
                else if(g_ishuman[id])
                {
                        set_hudmessage(color1, 50, color2, -1.0, height, 1, 0.01, 3.0, 0.01, 0.01);
                        ShowSyncHudMsg(id, gHudSyncInfo, "> [X] BaseBuilder <^n%L", LANG_SERVER, "PLAYER_INFO2", name, rank, get_user_health(pid), wpnname);
                }
        }
}

public ev_HideStatus(id)
{
        ClearSyncHud(id, gHudSyncInfo);
}

public weapon_method_menu(id)
{
        if(firsttime[id])
        {
                firsttime[id] = false
                prim_weapons_menu(id,0)
        }
        else
        {
                cur_offset[id] = 0
                if(ask[id])
                {
                        show_menu(id,(1<<0)|(1<<1)|(1<<2),"Weapon Selection Method^n^n1. New Guns^n2. Last Guns^n3. Last Guns + Save",-1,"WeaponMethodMenu")
                }
                else
                {
                        give_weapons(id)
                }
        }
}

public weapon_method_pushed(id,key)
{
        switch(key)
        {
                case 0:
                {
                        ask[id] = true
                        prim_weapons_menu(id,0)
                }       
                case 1:
                {
                        ask[id] = true
                        give_weapons(id)
                }
                case 2:
                {
                        print_color(id, "%s %L", formatmodname, LANG_SERVER, "GUNS_MSG")
                        ask[id] = false
                        give_weapons(id)
                }
        }
        return PLUGIN_HANDLED;
}

public prim_weapons_menu(id,offset)
{
        if(offset<0) offset = 0

        new cvar_value[32]
        get_pcvar_string(g_pcvar_allowedweps,cvar_value,31)
        new flags = read_flags(cvar_value)

        new keys, curnum, menu[2048]
        for(new i=offset;i<19;i++)
        {
                if(flags & power(2,i))
                {
                        options_on_menu[curnum][id] = i
                        keys += (1<<curnum)
       
                        curnum++
                        format(menu,2047,"%s^n%d. %s",menu,curnum,WEAPONNAMES[i])
       
                        if(curnum==8)
                        break;
                }
        }

        format(menu,2047,"\yPrimary Weapon:\w^n%s^n",menu)
        if(curnum==8 && offset<12)
        {
                keys += (1<<8)
                format(menu,2047,"%s^n9. Next",menu)
        }
        if(offset)
        {
                keys += (1<<9)
                format(menu,2047,"%s^n0. Back",menu)
        }

        show_menu(id,keys,menu,-1,"PrimaryWeaponSelect")
}

public prim_weapons_pushed(id,key)
{
        if(key<8)
        {
                weapon_picked[0][id] = options_on_menu[key][id]
                cur_offset[id] = 0
                sec_weapons_menu(id,0)
        }
        else
        {
                if(key==8)
                        cur_offset[id] += 8
                if(key==9)
                        cur_offset[id] -= 8
                prim_weapons_menu(id,cur_offset[id])
        }
        return ;
}

public sec_weapons_menu(id,offset)
{
        if(offset<0) offset = 0

        new cvar_value[32]
        get_pcvar_string(g_pcvar_allowedweps,cvar_value,31)
        new flags = read_flags(cvar_value)

        new keys, curnum, menu[2048]
        for(new i=18;i<24;i++)
        {
                if(flags & power(2,i))
                {
                options_on_menu[curnum][id] = i
                keys += (1<<curnum)

                curnum++
                format(menu,2047,"%s^n%d. %s",menu,curnum,WEAPONNAMES[i])
                }
        }

        format(menu,2047,"\ySecondary Weapon:\w^n%s",menu)

        show_menu(id,keys,menu,-1,"SecWeaponSelect")
}

public sec_weapons_pushed(id,key)
{
        if(key<8)
        {
                weapon_picked[1][id] = options_on_menu[key][id]
        }
        give_weapons(id)
        return ;
}

public give_weapons(id)
{
        strip_user_weapons(id)

        give_item(id,"weapon_knife")
 
        new weapon[32]
        new csw = csw_contant(weapon_picked[0][id])
        get_weaponname(csw,weapon,31)
        give_item(id,weapon)
        cs_set_user_bpammo(id,csw,999)
        g_PrimaryWeapon[id] = csw

        csw = csw_contant(weapon_picked[1][id])
        get_weaponname(csw,weapon,31)
        give_item(id,weapon)
        cs_set_user_bpammo(id,csw,999)
}

public csw_contant(weapon)
{
        new num = 29
        switch(weapon)
        {
                case 0: num = 3
                case 1: num = 5
                case 2: num = 7
                case 3: num = 8
                case 4: num = 12
                case 5: num = 13
                case 6: num = 14
                case 7: num = 15
                case 8: num = 18
                case 9: num = 19
                case 10: num = 20
                case 11: num = 21
                case 12: num = 22
                case 13: num = 23
                case 14: num = 24
                case 15: num = 27
                case 16: num = 28
                case 17: num = 30
                case 18: num = 1
                case 19: num = 10
                case 20: num = 11
                case 21: num = 16
                case 22: num = 17
                case 23: num = 26
                case 24:
                {
                        new s_weapon[32]
               
                        get_pcvar_string(g_pcvar_allowedweps,s_weapon,31)
                 
                        new flags = read_flags(s_weapon)
                        do
                        {
                                num = random_num(0,18)
                                if(!(num & flags))
                                {
                                        num = -1
                                }
                        }
                        while(num==-1)
                        num = csw_contant(num)
                }
                case 25:
                {
                        new s_weapon[32]

                        get_pcvar_string(g_pcvar_allowedweps,s_weapon,31)
               
                        new flags = read_flags(s_weapon)
                        do
                        {
                                num = random_num(18,23)
                                if(!(num & flags))
                                {
                                        num = -1
                                }
                        }
                        while(num==-1)
                        num = csw_contant(num)
                }
        }
        return num;
}


public cmdGuns(id)
{
        if(!g_isalive[id] || !g_isconnected[id] || !g_CanBuild)
                return PLUGIN_HANDLED
       
        if(!g_ishuman[id])
                return PLUGIN_HANDLED       

        ask[id] = true
        weapon_method_menu(id)
        return PLUGIN_HANDLED
}

public ev_Health(id)
{
        ShowHealth(id);
}

public ShowHealth(id)
{
        if (is_user_alive(id))
        {
                new Float:hud_time = get_pcvar_float(g_pcvar_healthtime);
               
                set_hudmessage(255, 255, 255, -1.0, 0.9, 0, hud_time, hud_time, 0.1, 0.2, 4);
                show_hudmessage(id, "%L", LANG_SERVER, "PLAYER_HEALTH", get_user_health(id));
               
                set_task(hud_time - 0.1, "ShowHealth", id);
        }
}

Log(const message_fmt[], any:...)
{
        static message[256];
        vformat(message, sizeof(message) - 1, message_fmt, 2);
       
        static filename[96];
        static dir[64];
        if( !dir[0] )
        {
                get_basedir(dir, sizeof(dir) - 1);
                add(dir, sizeof(dir) - 1, "/logs");
        }
       
        format_time(filename, sizeof(filename) - 1, "%m-%d-%Y");
        format(filename, sizeof(filename) - 1, "%s/BB_ACTIVITY_%s.log", dir, filename);
       
        log_to_file(filename, "%s", message);
}

print_color(target, const message[], any:...)
{
        static buffer[512], i, argscount
        argscount = numargs()
       
        // Send to everyone
        if (!target)
        {
                static player
                for (player = 1; player <= g_MaxPlayers; player++)
                {
                        if (!g_isconnected[player])
                                continue;

                        static changed[5], changedcount
                        changedcount = 0

                        for (i = 2; i < argscount; i++)
                        {
                                if (getarg(i) == LANG_PLAYER)
                                {
                                        setarg(i, 0, player)
                                        changed[changedcount] = i
                                        changedcount++
                                }
                        }
                        vformat(buffer, charsmax(buffer), message, 3)

                        message_begin(MSG_ONE_UNRELIABLE, gmsgSayText, _, player)
                        write_byte(player)
                        write_string(buffer)
                        message_end()
                       
                        for (i = 0; i < changedcount; i++)
                                setarg(changed[i], 0, LANG_PLAYER)
                }
        }
        // Send to specific target
        else
        {
                vformat(buffer, charsmax(buffer), message, 3)

                message_begin(MSG_ONE, gmsgSayText, _, target)
                write_byte(target)
                write_string(buffer)
                message_end()
        }
}

/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1030\\ f0\\ fs16 \n\\ par }
*/


tom1kIG 06-01-2021 13:13

Re: amx grab
 
I can't combine them, but i found this grab plugin and it works good.

Code:

#include <amxmodx>
#include <amxmisc>
#include <cromchat>
#include <fun>

#define DISTANCE_FROM_PLAYER 36

public plugin_init()
{
    register_plugin("amx_grab command", "1.0", "OciXCrom @ amxx-bg.info/forum")
    register_concmd("amx_grab", "Cmd_Grab", ADMIN_SLAY, "<nick|#userid>")
    CC_SetPrefix("&x04[AMXX]")
}

public Cmd_Grab(id, iLevel, iCid)
{
    if(!cmd_access(id, iLevel, iCid, 2))
        return PLUGIN_HANDLED
       
    new szPlayer[32]
    read_argv(1, szPlayer, charsmax(szPlayer))
   
    new iPlayer = cmd_target(id, szPlayer, CMDTARGET_ONLY_ALIVE)
   
    if(!iPlayer)
        return PLUGIN_HANDLED
   
    new iOrigin[3]
    get_user_origin(id, iOrigin)
    iOrigin[1] += DISTANCE_FROM_PLAYER
    set_user_origin(iPlayer, iOrigin)
   
    new szName[2][32]
    get_user_name(id, szName[0], charsmax(szName[]))
    get_user_name(iPlayer, szName[1], charsmax(szName[]))
   
    CC_LogMessage(0, _, "ADMIN &x03%s &x01grabbed &x03%s", szName[0], szName[1])
    return PLUGIN_HANDLED
}



All times are GMT -4. The time now is 12:18.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.