Русское сообщество по скриптингу

BackWeapons & Human Race

Все вопросы по скриптингу для AMXX, помощь в редактировании плагинов.

Модераторы: Subb98, liFe iS GoOD

Правила форума
1. Запрещено материться и оскорблять других участников форума.
2. Запрещен флуд, оффтоп, дабл постинг во всех разделах форума, кроме раздела "Болтовня".
3. Запрещено взламывать сайт/форум или наносить любой вред проекту.
4. Запрещено рекламировать другие ресурсы.
5. Запрещено создавать темы без информативного названия. Название темы должно отображать ее смысл.

В данном разделе форума разрешено создавать темы, касающие только скриптинга для AMX Mod X.

Правила при создании новой темы:
1. При вставке кода плагина необходимо использовать тег [code=php].
2. Любые изображения должны быть загружены, как вложения к вашему сообщению.
3. При описании проблемы или запросе на помощь в редактировании плагина обязательно выкладывайте исходник sma плагина.

BackWeapons & Human Race

Сообщение MayroN » 27 июл 2019, 20:05

Облазил кругом на Оленях - нашел только пример.
Пробовал и в Мод и в сам плагин "пихать" - не заработало.

Суть простая:

При выборе Расы Человека - модель игрока из любым оружием становиться невидимой
Но как только оружие появляеться за спиной - оно приобретает полностью видимый вид.

Код: Выделить всё
===================================================================================
If this were in FakeMeta I could tell you.

But I don't know what the constant for alpha is in Engine.

Ask how to change/get Alpha in Engine in scripting help.

Then replace:
Code:
            set_entity_visibility(g_bwEnt[id], 1)
            entity_set_model(g_bwEnt[id], modelName)
(Near the end of Event_CurWeapon)

With:
Code:
            set_entity_visibility(g_bwEnt[id], 1)
            entity_set_model(g_bwEnt[id], modelName)
            entity_set_int(g_bwEnt[id],EV_INT_Alpha,entity_get_int(entity_set_int(id,EV_INT_Alpha))

===================================================================================

#include < amxmodx > 
#include < engine > 
#include < fakemeta > 

#pragma semicolon 1 

#define PLUGIN "Attachments Visibility" 
#define VERSION "0.0.1" 

new g_iMaxPlayers; 
#define IsPlayer(%0)    ( 1 <= (%0) <= g_iMaxPlayers ) 

public plugin_init() 

    register_plugin( PLUGIN, VERSION, "ConnorMcLeod" ); 
    register_forward(FM_AddToFullPack, "OnAddToFullPack_Post", true); 
    g_iMaxPlayers = get_maxplayers(); 


public OnAddToFullPack_Post(es, e, ent, host, hostflags, player, pSet) 

    if( !player && get_orig_retval() && get_es(es, ES_MoveType) == MOVETYPE_FOLLOW ) 
    { 
        static aiment, Float:rendercolor[3], RenderColor[3]; 
        aiment = entity_get_edict(ent, EV_ENT_aiment); 
        if( IsPlayer(aiment) && aiment != host ) 
        { 
            set_es(es, ES_RenderMode, entity_get_int(aiment, EV_INT_rendermode)); 
            set_es(es, ES_RenderAmt, clamp( floatround(entity_get_float(aiment, EV_FL_renderamt)), 0, 255 )); 
            entity_get_vector(aiment, EV_VEC_rendercolor, rendercolor); 
            FVecIVec(rendercolor, RenderColor); 
            set_es(es, ES_RenderColor, RenderColor); 
            set_es(es, ES_RenderFx, entity_get_int(aiment, EV_INT_renderfx)); 
        } 
    } 


=================================================================================

set_user_rendering( id, kRenderFxNone, 0, 0, 0, kRenderTransTexture, invlevel );  

=================================================================================


Код: Выделить всё
/*ԯ`׮ظ.ԯ`׮ظ.ԯ`׮ظ.ԯ`׮ظ.ԯ`׮ظ.ԯ`׮ظ.ԯ`׮ظ.ԯ`׮ظ.ԯ`׮ظ.ԯ`׮ظ.ԯ`׮ظ.
*    Race: Human Alliance Functions
ԯ`׮ظ.ԯ`׮ظ.ԯ`׮ظ.ԯ`׮ظ.ԯ`׮ظ.ԯ`׮ظ.ԯ`׮ظ.ԯ`׮ظ.ԯ`׮ظ.ԯ`׮ظ.ԯ`׮ظ.*/

#include <colorchat>

#define BLINK_COOLDOWN                2.0
#define BASH_GLOW_INTENSITY            200
#define BASH_HOLD_TIME                0.7


HU_ULT_Blink( id )
{
    
    
// User can't Blink when he/she's stunned
    if ( p_data_b[id][PB_STUNNED] )
    {
        WC3_StatusText( id, 0, "%L", id, "CLIENT_PRINT_HU_ULT_BLINK_1" );

        return;
    }
    
    new vOldLocation
[3], vNewLocation[3]
    
    
// Get the player's current location
    get_user_origin( id, vOldLocation );
    
    
// Get where the player is looking (where the player will teleport)
    get_user_origin( id, vNewLocation, 3 );
    
    
// Play the blink sound!
    emit_sound( id, CHAN_STATIC, g_szSounds[SOUND_BLINK], 1.0, ATTN_NORM, 0, PITCH_NORM );

    // Make sure a nearby enemy doesn't have immunity
    if ( WC3_IsImmunePlayerNear( id, vOldLocation ) || WC3_IsImmunePlayerNear( id, vNewLocation ) )
    {
        //set_hudmessage( 255, 255, 10, -1.0, -0.4, 1, 0.5, BLINK_COOLDOWN, 0.2, 0.2 ,-1 );
        WC3_StatusText( id, 0, "%L", id, "TELEPORT_FAILED_ENEMY_IMMUNITY" );
        
        
// Reset the user's ultimate
        ULT_ResetCooldown( id, get_pcvar_num( CVAR_wc3_ult_cooldown ) );

        return;
    }

    // Check to see if the user is teleporting where they shouldn't
    if ( SHARED_NearObjective( vNewLocation ) == OBJENT_VIP_ESCAPE )
    {
        WC3_StatusText( id, 0, "%L", id, "CLIENT_PRINT_HU_ULT_BLINK_2" );
        
        
// Reset the user's ultimate
        ULT_ResetCooldown( id, get_pcvar_num( CVAR_wc3_ult_cooldown ) );

        return;
    }

    // If we teleport them back, make sure they don't get teleported into the ground
    vOldLocation[ZPOS] += 15;

    // Change coordinates to make sure player won't get stuck in the ground/wall
    vNewLocation[XPOS] += ( ( vNewLocation[XPOS] - vOldLocation[XPOS] > 0 ) ? -50 : 50 );
    vNewLocation[YPOS] += ( ( vNewLocation[YPOS] - vOldLocation[YPOS] > 0 ) ? -50 : 50 );
    vNewLocation[ZPOS] += 40;            

    
    
// Set up some origins for some special effects!!!
    new vCenterOrigin[3], vAxisOrigin[3];
    vCenterOrigin[0]    = vOldLocation[0];
    vCenterOrigin[1]    = vOldLocation[1];
    vCenterOrigin[2]    = vOldLocation[2] + 10;
    vAxisOrigin[0]        = vOldLocation[0];
    vAxisOrigin[1]        = vOldLocation[1];
    vAxisOrigin[2]        = vOldLocation[2] + 10 + TELEPORT_RADIUS;

    // Lets create some beam cylinders!
    Create_TE_BEAMCYLINDER( vOldLocation, vCenterOrigin, vAxisOrigin, g_iSprites[SPR_SHOCKWAVE], 0, 0, 3, 60, 0, 0, 255, 0, 255, 0 );
    
    
// Modify our effects a bit for another cylinder
    vCenterOrigin[2]    += 80;
    vAxisOrigin[2]        += 80;
    
    
// And draw another cylinder!!!
    Create_TE_BEAMCYLINDER( vOldLocation, vCenterOrigin, vAxisOrigin, g_iSprites[SPR_SHOCKWAVE], 0, 0, 3, 60, 0, 0, 255, 0, 255, 0 );

    // Planting the bomb then teleporting = bad, lets stop this...
    client_cmd( id, "-use" );

    // Then lets try to slay some bitches...
    if ( get_pcvar_num( CVAR_wc3_blink_protection ) )
    {

        // Lets go ahead and make this check before they teleport...
        if ( HU_ULT_BlinkProtection( id, vNewLocation ) )
        {

            ULT_ResetCooldown( id, get_pcvar_num( CVAR_wc3_ult_cooldown ) );

            return;
        }
    }

    // Teleport the player!!!
    set_user_origin( id, vNewLocation );

    // Check if Blink landed you in a wall, if so, abort
    new parm[5];
    parm[0] = id;
    parm[1] = vOldLocation[0];
    parm[2] = vOldLocation[1];
    parm[3] = vOldLocation[2];
    parm[4] = vNewLocation[2];
    
    set_task
( 0.1, "_HU_ULT_BlinkStuck", TASK_BLINKSTUCK + id, parm, 5 );
    
    ULT_ResetCooldown
( id, get_pcvar_num( CVAR_wc3_ult_cooldown ) );

    ULT_Icon( id, ICON_HIDE );

    emit_sound( id, CHAN_STATIC, g_szSounds[SOUND_BLINK], 1.0, ATTN_NORM, 0, PITCH_NORM );

    return;
}

// Function will check to see if a user is stuck in a wall
public _HU_ULT_BlinkStuck( parm[] )
{

    new id = parm[0]     

    if 
( !p_data_b[id][PB_ISCONNECTED] )
    {
        return;
    }

    new vOldLocation[3], vOrigin[3];

    vOldLocation[0] = parm[1];
    vOldLocation[1] = parm[2];
    vOldLocation[2] = parm[3];

    get_user_origin( id, vOrigin );
    
    
// Then the user is stuck :/
    if ( parm[4] == vOrigin[2] )
    {

        //set_hudmessage( 255, 255, 10, -1.0, -0.4, 1, 0.5, BLINK_COOLDOWN, 0.2, 0.2, 5 );
        WC3_StatusText( id, 0, "%L", id, "TELEPORT_FAILED_BAD_DESTINATION" );

        set_user_origin( id, vOldLocation )    ;

        ULT_ResetCooldown( id, floatround(BLINK_COOLDOWN) );
    }

    // Otherwise they teleported correctly!
    else
    
{

        // Sprays white bubbles everywhere
        new vStartOrigin[3];
        vStartOrigin[0] = vOrigin[0];
        vStartOrigin[1] = vOrigin[1];
        vStartOrigin[2] = vOrigin[2] + 40;
        
        Create_TE_SPRITETRAIL
( vStartOrigin, vOrigin, g_iSprites[SPR_FLARE], 30, 10, 1, 50, 10 );

    }    
    
    return
;
}


// Function will make sure the user isn't in an invalid location in a map
HU_ULT_BlinkProtection( id, vOrigin[3] )
{

    new bool:bSlay = false;
    new Float:fOrigin[3];
    
    
// Convert origin to float
    IVecFVec( vOrigin, fOrigin );
    
    
// User shouldn't be teleporting into the sky!
    if ( point_contents( fOrigin ) == CONTENTS_SKY )
    {
        bSlay = true;
    }

    // Get the current map name
    new szMapName[32];
    get_mapname( szMapName, 32 );

    
    
// Only do these checks if we're in CS/CZ
    if ( g_MOD == GAME_CSTRIKE || g_MOD == GAME_CZERO )
    {

        if ( !bSlay )
        {
            new x = vOrigin[0];
            new y = vOrigin[1];
            new z = vOrigin[2];
            
            
// Don't teleport too high
            if ( equali( szMapName, "de_dust" ) )
            {
                if ( z > 220 )
                {
                    bSlay = true;
                }
            }

            else if ( equali( szMapName, "awp_assault" ) )
            {
                if( z > 520 && y > 2400 && y < 2600 )
                {
                    bSlay = true;
                }
            }

            else if ( equali( szMapName, "de_dust_cz" ) )
            {
                if ( z > 220 )
                {
                    bSlay = true;
                }
            }

            else if ( equali( szMapName, "de_aztec_cz" ) )
            {
                if ( z > 300 )
                {
                    bSlay = true;
                }
            }

            else if ( equali( szMapName, "cs_assault_upc" ) )
            {
                if( z > 650 )
                {
                    bSlay = true;
                }
            }

            else if ( equali( szMapName, "de_aztec" ) )
            {
                if( z > 300 )
                {
                    bSlay = true;
                }
            }

            else if ( equali( szMapName, "de_cbble" ) || equali( szMapName, "de_cbble_cz" ) )
            {
                if ( z > 315 )
                {
                    if ( ! ( ( x > -1320 && x < -1150 ) && ( y > 2600 && y < 2900 ) ) )
                    {
                        bSlay = true;
                    }
                }           
            
}

            else if ( equali( szMapName, "cs_assault" ) )
            {
                if ( z > 700 )
                {
                    bSlay = true;
                }
            }

            else if ( equali( szMapName, "cs_militia" ) || equali( szMapName, "cs_militia_cz" ) )
            {
                if ( z > 500 )
                {
                    bSlay = true;
                }
            }

            else if ( equali( szMapName, "cs_italy" ) )
            {
                if ( z > -220 && y < -2128 )
                {
                        bSlay = true;
                }
                else if( z > 250 )
                {
                    if ( ( x < -1000 && x > -1648 ) && ( y > 1900 && y < 2050 ) )
                    {
                        bSlay = true;
                    }
                    else if ( ( x < -1552 && x > -1648 ) && ( y > 1520 && y < 2050 ) )
                    {
                        bSlay = true;
                    }
                }
            }

            else if ( equali( szMapName, "cs_italy_cz" ) )
            {
                if ( y > 2608 )
                {
                    bSlay = true;
                }
            }

            else if ( equali( szMapName, "de_dust2" ) )
            {
                if ( z > 270 )
                {
                    bSlay = true;
                }
            }

            else if ( equali( szMapName, "de_dust2_cz" ) )
            {
                if ( z > 270 )
                {
                    bSlay = true;
                }
            }

            else if ( equali( szMapName, "fy_dustworld" ) )
            {
                if ( z > 82 )
                {
                    bSlay = true;
                }
            }

            else if ( equali( szMapName, "fy_pool_day" ) )
            {
                if ( z > 190 )
                {
                    bSlay = true;
                }
            }

            else if ( equali( szMapName, "as_oilrig" ) )
            {
                if ( x > 1700 )
                {
                    bSlay = true;
                }
            }
        }
    }

    
    
// For some reason bSlay is always true on this map, but you should be able to teleport anywhere
    if ( equali( szMapName, "cs_mice_final" ) )
    {
        bSlay = false;
    }


    // Slay the user!!!
    if ( bSlay )
    {
#if AMXX_VERSION_NUM < 183
ColorChat(id, RED, "%L", LANG_PLAYER, "SLAIN_FOR_TELEPORTING" );
#else
client_print_color(id, print_team_red, "%L", LANG_PLAYER, "SLAIN_FOR_TELEPORTING" );
#endif 
        //client_print( id, print_chat, "%s %L", id, "SLAIN_FOR_TELEPORTING" );
        user_kill( id );
    }

    return bSlay;
}

HU_DevotionAura( id )
{

    if ( !is_user_alive( id ) )
    {
        return;
    }

    static iSkillLevel;
    iSkillLevel = SM_GetSkillLevel( id, SKILL_DEVOTION );
    
    
// Then the user has devotion aura + hasn't lost some skill levels!
    if ( iSkillLevel > 0 )
    {

        // Increase the user's health
        set_user_health( id, get_user_health( id ) + ( p_devotion * iSkillLevel ) );
    }
}

HU_SkillsOffensive( iAttacker, iVictim )
{
    static iSkillLevel;

    // Bash
    iSkillLevel = SM_GetSkillLevel( iAttacker, SKILL_BASH );
    if ( iSkillLevel > 0 )
    {

        // Cannot bash if already bashed or user is slowed
        if ( random_float( 0.0, 1.0 ) <= p_bash[iSkillLevel-1] && !SHARED_IsPlayerSlowed( iVictim ) )
        {        

            p_data_b
[iVictim][PB_STUNNED] = true;
            SHARED_SetSpeed( iVictim );
            
            set_task
( BASH_HOLD_TIME, "SHARED_ResetMaxSpeed", TASK_RESETSPEED + iVictim );

            // Make the user glow!
            SHARED_Glow( iVictim, 0, 0, 0, BASH_GLOW_INTENSITY );

            // Create a screen fade
            Create_ScreenFade( iVictim, (1<<10), (1<<10), (1<<12), 255, 255, 255, g_GlowLevel[iVictim][3] )
        }
    }
}


Код: Выделить всё
public SHARED_INVIS_Set( id )
{
    // Do not want to set them as invisible if the player is currently rendering
    if ( !p_data_b[id][PB_CAN_RENDER] || !p_data_b[id][PB_ISCONNECTED] )
    {
        return;
    }

    new iInvisLevel = 0;

    static iSkillLevel;
    iSkillLevel = SM_GetSkillLevel( id, SKILL_INVISIBILITY );

    // If they are Human Alliance with Invisibility lets set the level
    if ( iSkillLevel > 0 )
    {
        iInvisLevel = p_invisibility[iSkillLevel-1];
    }

    // User has a Cloak of Invisibility
    if ( ITEM_Has( id, ITEM_CLOAK ) > ITEM_NONE )
    {
        // Then we are already a little invis, lets give them a little bonus for purchasing the item
        if ( iInvisLevel > 0 )
        {
            iInvisLevel = floatround( float( iInvisLevel ) / INVIS_CLOAK_DIVISOR );
        }
        else
        
{
            iInvisLevel = get_pcvar_num( CVAR_wc3_cloak );
        }
    }
    
    
// If the player is holding a knife they should be more invisible
    if ( SHARED_IsHoldingKnife( id ) )
    {
        iInvisLevel /= 2;
    }

    if ( iInvisLevel )
    {
        set_user_rendering( id, kRenderFxNone, 0, 0, 0, kRenderTransTexture, iInvisLevel );
        
        p_data_b
[id][PB_INVIS] = true;
    }

    // User should not be invisible
    else
    
{
        set_user_rendering( id );

        p_data_b[id][PB_INVIS] = false;
    }

    return;
}

// Function will return true if their active weapon is a knife
public SHARED_IsHoldingKnife( id )
{
    new iClip, iAmmo, iWeapon;
    iWeapon = get_user_weapon( id, iClip, iAmmo );

    // Check for Counter-Strike or Condition Zero
    if ( g_MOD == GAME_CSTRIKE || g_MOD == GAME_CZERO )
    {
        if ( iWeapon == CSW_KNIFE )
        {
            return true;
        }
    }

    // Check for Day of Defeat
    else if ( g_MOD == GAME_DOD )
    {
        if ( iWeapon == DODW_AMERKNIFE || iWeapon == DODW_GERKNIFE || iWeapon == DODW_SPADE )
        {
            return true;
        }
    }

    return false;
}


Код: Выделить всё
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define MAX_PLAYERS         32
#define OFFSET_PRIMARYWEAPON     116
#define OFFSET_WEAPONTYPE     43
#define EXTRAOFFSET_WEAPONS     4
#define OFFSET_AUTOSWITCH     509
#define OFFSET_SHIELD         510
#define HAS_SHIELD         (1<<24)

#define PRIMARY_WEAPONS (1<<CSW_SCOUT | 1<<CSW_XM1014 | 1<<CSW_MAC10 | 1<<CSW_AUG | 1<<CSW_UMP45 | 1<<CSW_SG550 | 1<<CSW_GALIL | 1<<CSW_FAMAS | 1<<CSW_AWP | 1<<CSW_MP5NAVY | 1<<CSW_M249 | 1<<CSW_M3 | 1<<CSW_M4A1 | 1<<CSW_TMP | 1<<CSW_G3SG1 | 1<<CSW_SG552 | 1<<CSW_AK47 | 1<<CSW_P90)

#define is_weapon_primary(%1)      (PRIMARY_WEAPONS & (1<<%1))
#define cs_get_weapon_type(%1)     get_pdata_int(%1, OFFSET_WEAPONTYPE, EXTRAOFFSET_WEAPONS)
#define cs_get_user_hasprim(%1)    get_pdata_int(%1, OFFSET_PRIMARYWEAPON)
#define cs_get_user_autoswitch(%1) get_pdata_int(%1, OFFSET_AUTOSWITCH)
#define cs_get_user_shield(%1)       (get_pdata_int(%1, OFFSET_SHIELD) & HAS_SHIELD) ? 1 : 0

enum
{
    MODEL_NULL    = 0,
    MODEL_AUG     = 1,
    MODEL_AK47    = 2,
    MODEL_AWP     = 3,
    MODEL_MP5NAVY = 4,
    MODEL_P90     = 5,
    MODEL_GALIL   = 6,
    MODEL_M4A1    = 7,
    MODEL_SG550   = 8,
    MODEL_SG552   = 9,
    MODEL_SCOUT   = 10,
    MODEL_XM1014  = 11,
    MODEL_G3SG1   = 13,
    MODEL_M249    = 14,
    MODEL_FAMAS   = 15,
    MODEL_UMP45   = 16,
    MODEL_TMP     = 17,
    MODEL_MAC10   = 18
}

new g_weapons[][] =
{
    "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"
}

new g_weaponclass[] = "backweapon"
new g_weaponmodel[] = "models/backweapons_wc/backweapons_wc.mdl"
new g_weaponent[MAX_PLAYERS+1]
new bot_limit,bool:bot_ham

public plugin_init
()
{
    register_plugin("Back Weapons", "1.87", "hoboman313; cheap_suit")

    RegisterHam(Ham_Killed,           "player", "bacon_killed")
    RegisterHam(Ham_Spawn,            "player", "bacon_spawn_post", 1)
    RegisterHam(Ham_AddPlayerItem,    "player", "bacon_addplayeritem")
    RegisterHam(Ham_RemovePlayerItem, "player", "bacon_removeplayeritem")
    bot_limit=get_cvar_pointer("bot_quota")
    for(new i = 0; i < sizeof g_weapons; i++)
    {
        RegisterHam(Ham_Item_AttachToPlayer, g_weapons[i], "bacon_item_attachtoplayer_post", 1)
        RegisterHam(Ham_Item_Deploy,         g_weapons[i], "bacon_item_deploy_post",         1)
    }
}

public plugin_precache()
    precache_model(g_weaponmodel)

public client_putinserver(id)
{
    static infotarget
    if
(!infotarget) infotarget = engfunc(EngFunc_AllocString, "info_target")

    g_weaponent[id] = engfunc(EngFunc_CreateNamedEntity, infotarget)
    if(pev_valid(g_weaponent[id]))
    {
        engfunc(EngFunc_SetModel, g_weaponent[id], g_weaponmodel)
        set_pev(g_weaponent[id], pev_classname, g_weaponclass)
        set_pev(g_weaponent[id], pev_movetype, MOVETYPE_FOLLOW)
        set_pev(g_weaponent[id], pev_effects, EF_NODRAW)
        set_pev(g_weaponent[id], pev_aiment, id)
    }
    if(is_user_bot(id)&&!bot_ham&&bot_limit)set_task(0.1,"reg_ham_bot",id)
}

public client_disconnect(id)
{
    if(g_weaponent[id] > 0 && pev_valid(g_weaponent[id]))
        engfunc(EngFunc_RemoveEntity, g_weaponent[id])

    g_weaponent[id] = 0
}

public reg_ham_bot(id)
{
    if(bot_ham||!is_user_connected(id)||!get_pcvar_num(bot_limit))return
    RegisterHamFromEntity(Ham_Killed,id,"bacon_killed")
    RegisterHamFromEntity(Ham_Spawn,id,"bacon_spawn_post",1)
    RegisterHamFromEntity(Ham_AddPlayerItem,id,"bacon_addplayeritem")
    RegisterHamFromEntity(Ham_RemovePlayerItem,id,"bacon_removeplayeritem")
    bot_ham=true;if(is_user_alive(id))bacon_spawn_post(id)
}

public bacon_killed(id, idattacker, shouldgib)
    fm_set_entity_visibility(g_weaponent[id], 0)

public bacon_addplayeritem(id, ent)
{
    static weaponid; weaponid = cs_get_weapon_type(ent)
    if(is_weapon_primary(weaponid) && pev_valid(g_weaponent[id]))
    {
        fm_set_entity_visibility(g_weaponent[id], 0)
        set_pev(g_weaponent[id], pev_body, get_weapon_model(weaponid))
    }
}

public bacon_removeplayeritem(id, ent)
{
    if(is_weapon_primary(cs_get_weapon_type(ent)) && pev_valid(g_weaponent[id]))
        fm_set_entity_visibility(g_weaponent[id], 0)
}

public bacon_spawn_post(id) if(is_user_alive(id))
{
    if(!cs_get_user_hasprim(id))
        fm_set_entity_visibility(g_weaponent[id], 0)
}

public bacon_item_attachtoplayer_post(ent, id) if(is_user_alive(id) && !cs_get_user_autoswitch(id))
{
    if(is_weapon_primary(cs_get_weapon_type(ent)) && pev_valid(g_weaponent[id]))
        fm_set_entity_visibility(g_weaponent[id], 1)
}

public bacon_item_deploy_post(ent)
{
    static id; id = pev(ent, pev_owner)
    if(is_user_alive(id))
    {
        static weapon; weapon = cs_get_weapon_type(ent)
        if(is_weapon_primary(weapon) || cs_get_user_shield(id))
            fm_set_entity_visibility(g_weaponent[id], 0)

        else if(cs_get_user_hasprim(id))
            fm_set_entity_visibility(g_weaponent[id], 1)
    }
}

stock get_weapon_model(weapon)
{
    switch(weapon)
    {
        case CSW_SCOUT:   return MODEL_SCOUT
        case CSW_XM1014
:  return MODEL_XM1014
        case CSW_AUG
:      return MODEL_AUG
        case CSW_UMP45
:   return MODEL_UMP45
        case CSW_SG550
:   return MODEL_SG550
        case CSW_GALIL
:   return MODEL_GALIL
        case CSW_FAMAS
:   return MODEL_FAMAS
        case CSW_AWP
:     return MODEL_AWP
        case CSW_MP5NAVY
: return MODEL_MP5NAVY
        case CSW_M249
:    return MODEL_M249
        case CSW_M4A1
:    return MODEL_M4A1
        case CSW_G3SG1
:   return MODEL_G3SG1
        case CSW_SG552
:   return MODEL_SG552
        case CSW_AK47
:    return MODEL_AK47
        case CSW_P90
:     return MODEL_P90
        case CSW_MAC10
:   return MODEL_MAC10    
        case CSW_TMP
:     return MODEL_TMP
    
}
    return 0
}

stock fm_set_entity_visibility(index, visible = 1)
    set_pev(index, pev_effects, visible == 1 ? pev(index, pev_effects) & ~EF_NODRAW : pev(index, pev_effects) | EF_NODRAW)
МультиМод CS
Аватара пользователя
MayroN
 
Сообщения: 673
Зарегистрирован: 10 окт 2010, 18:23
Откуда: Украина, г. Белая Церковь
Благодарил (а): 149 раз.
Поблагодарили: 86 раз.
Опыт программирования: Около года
Языки программирования: На которых говорю...

Re: BackWeapons & Human Race

Сообщение артист666 » 11 авг 2019, 18:45

Много кода, лень смотреть...
Так всё просто, отлов выхватывания оружия, если в руках вторичное оружие - установить невидимость, если нет - сбросить.
Если вы хотите чему-то научиться, пробуйте, задавайте вопросы.
Иначе компенсируйте потраченное время на ваши "проблемы".
Аватара пользователя
артист666
 
Сообщения: 2706
Зарегистрирован: 09 апр 2013, 17:46
Благодарил (а): 284 раз.
Поблагодарили: 639 раз.
Опыт программирования: Больше трех лет
Языки программирования: С, C++
Delphi
HTML, CSS, Java Script
Pawn

Re: BackWeapons & Human Race

Сообщение MayroN » 11 авг 2019, 23:49

артист666 писал(а):Много кода, лень смотреть...
Так всё просто, отлов выхватывания оружия, если в руках вторичное оружие - установить невидимость, если нет - сбросить.


А что эсли зделать проще:

Вот у меня эсть ещё плагин Рун, и там есть также Навык Невидимости и получаеться,что етот плагин вместе из етим нюансом ещё дополнительно неработает.Тоесть,невидимость пропадает ( тоесть юзаеться там Курвеапон, и эсли чет нажать - всё...)

Что я думаю - может попросту вырезать эту невидимость для Людей только из ВарКрафта и тогда всё в Ажуре? Как вариант...
Или опять не то ?)
МультиМод CS
Аватара пользователя
MayroN
 
Сообщения: 673
Зарегистрирован: 10 окт 2010, 18:23
Откуда: Украина, г. Белая Церковь
Благодарил (а): 149 раз.
Поблагодарили: 86 раз.
Опыт программирования: Около года
Языки программирования: На которых говорю...

Re: BackWeapons & Human Race

Сообщение MayroN » 08 апр 2020, 22:28

Всё ещё Актуально...
МультиМод CS
Аватара пользователя
MayroN
 
Сообщения: 673
Зарегистрирован: 10 окт 2010, 18:23
Откуда: Украина, г. Белая Церковь
Благодарил (а): 149 раз.
Поблагодарили: 86 раз.
Опыт программирования: Около года
Языки программирования: На которых говорю...

Re: BackWeapons & Human Race

Сообщение MayroN » 11 апр 2020, 13:40

Вот нашол здравый Вы должны зарегистрироваться, чтобы видеть ссылки. от OciXCrom - только вот не получаеться правильно подстроить там,где эта невидимость есть

У Беквеапон в конец
Код: Выделить всё
public plugin_natives()
    register_native("backweapons_set_transparency", "_backweapons_set_transparency")

public _backweapons_set_transparency(iPlugin, iParams)
{
    new id = get_param(1)
    
    if
(g_weaponent[id] > 0 && pev_valid(g_weaponent[id]))
        set_pev(g_weaponent[id], pev_renderamt, get_param_f(2))

Код: Выделить всё
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define MAX_PLAYERS         32
#define OFFSET_PRIMARYWEAPON     116
#define OFFSET_WEAPONTYPE     43
#define EXTRAOFFSET_WEAPONS     4
#define OFFSET_AUTOSWITCH     509
#define OFFSET_SHIELD         510
#define HAS_SHIELD         (1<<24)

#define PRIMARY_WEAPONS (1<<CSW_SCOUT | 1<<CSW_XM1014 | 1<<CSW_MAC10 | 1<<CSW_AUG | 1<<CSW_UMP45 | 1<<CSW_SG550 | 1<<CSW_GALIL | 1<<CSW_FAMAS | 1<<CSW_AWP | 1<<CSW_MP5NAVY | 1<<CSW_M249 | 1<<CSW_M3 | 1<<CSW_M4A1 | 1<<CSW_TMP | 1<<CSW_G3SG1 | 1<<CSW_SG552 | 1<<CSW_AK47 | 1<<CSW_P90)

#define is_weapon_primary(%1)      (PRIMARY_WEAPONS & (1<<%1))
#define cs_get_weapon_type(%1)     get_pdata_int(%1, OFFSET_WEAPONTYPE, EXTRAOFFSET_WEAPONS)
#define cs_get_user_hasprim(%1)    get_pdata_int(%1, OFFSET_PRIMARYWEAPON)
#define cs_get_user_autoswitch(%1) get_pdata_int(%1, OFFSET_AUTOSWITCH)
#define cs_get_user_shield(%1)       (get_pdata_int(%1, OFFSET_SHIELD) & HAS_SHIELD) ? 1 : 0

enum
{
    MODEL_NULL    = 0,
    MODEL_AUG     = 1,
    MODEL_AK47    = 2,
    MODEL_AWP     = 3,
    MODEL_MP5NAVY = 4,
    MODEL_P90     = 5,
    MODEL_GALIL   = 6,
    MODEL_M4A1    = 7,
    MODEL_SG550   = 8,
    MODEL_SG552   = 9,
    MODEL_SCOUT   = 10,
    MODEL_XM1014  = 11,
        MODEL_M3       = 12,
    MODEL_G3SG1   = 13,
    MODEL_M249    = 14,
    MODEL_FAMAS   = 15,
    MODEL_UMP45   = 16,
    MODEL_TMP     = 17,
    MODEL_MAC10   = 18
}

new g_weapons[][] =
{
    "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"
}

new g_weaponclass[] = "backweapon"
new g_weaponmodel[] = "models/backweapons_wc/backweapons_wc.mdl"
new g_weaponent[MAX_PLAYERS+1]
new bot_limit,bool:bot_ham

public plugin_init
()
{
    register_plugin("Back Weapons", "1.87", "hoboman313; cheap_suit")

    RegisterHam(Ham_Killed,           "player", "bacon_killed")
    RegisterHam(Ham_Spawn,            "player", "bacon_spawn_post", 1)
    RegisterHam(Ham_AddPlayerItem,    "player", "bacon_addplayeritem")
    RegisterHam(Ham_RemovePlayerItem, "player", "bacon_removeplayeritem")
    bot_limit=get_cvar_pointer("bot_quota")
    for(new i = 0; i < sizeof g_weapons; i++)
    {
        RegisterHam(Ham_Item_AttachToPlayer, g_weapons[i], "bacon_item_attachtoplayer_post", 1)
        RegisterHam(Ham_Item_Deploy,         g_weapons[i], "bacon_item_deploy_post",         1)
    }
}

public plugin_precache()
    precache_model(g_weaponmodel)

public client_putinserver(id)
{
    static infotarget
    if
(!infotarget) infotarget = engfunc(EngFunc_AllocString, "info_target")

    g_weaponent[id] = engfunc(EngFunc_CreateNamedEntity, infotarget)
    if(pev_valid(g_weaponent[id]))
    {
        engfunc(EngFunc_SetModel, g_weaponent[id], g_weaponmodel)
        set_pev(g_weaponent[id], pev_classname, g_weaponclass)
        set_pev(g_weaponent[id], pev_movetype, MOVETYPE_FOLLOW)
        set_pev(g_weaponent[id], pev_effects, EF_NODRAW)
        set_pev(g_weaponent[id], pev_aiment, id)
    }
    if(is_user_bot(id)&&!bot_ham&&bot_limit)set_task(0.1,"reg_ham_bot",id)
}

public client_disconnect(id)
{
    if(g_weaponent[id] > 0 && pev_valid(g_weaponent[id]))
        engfunc(EngFunc_RemoveEntity, g_weaponent[id])

    g_weaponent[id] = 0
}

public reg_ham_bot(id)
{
    if(bot_ham||!is_user_connected(id)||!get_pcvar_num(bot_limit))return
    RegisterHamFromEntity(Ham_Killed,id,"bacon_killed")
    RegisterHamFromEntity(Ham_Spawn,id,"bacon_spawn_post",1)
    RegisterHamFromEntity(Ham_AddPlayerItem,id,"bacon_addplayeritem")
    RegisterHamFromEntity(Ham_RemovePlayerItem,id,"bacon_removeplayeritem")
    bot_ham=true;if(is_user_alive(id))bacon_spawn_post(id)
}

public bacon_killed(id, idattacker, shouldgib)
    fm_set_entity_visibility(g_weaponent[id], 0)

public bacon_addplayeritem(id, ent)
{
    static weaponid; weaponid = cs_get_weapon_type(ent)
    if(is_weapon_primary(weaponid) && pev_valid(g_weaponent[id]))
    {
        fm_set_entity_visibility(g_weaponent[id], 0)
        set_pev(g_weaponent[id], pev_body, get_weapon_model(weaponid))
    }
}

public bacon_removeplayeritem(id, ent)
{
    if(is_weapon_primary(cs_get_weapon_type(ent)) && pev_valid(g_weaponent[id]))
        fm_set_entity_visibility(g_weaponent[id], 0)
}

public bacon_spawn_post(id) if(is_user_alive(id))
{
    if(!cs_get_user_hasprim(id))
        fm_set_entity_visibility(g_weaponent[id], 0)
}

public bacon_item_attachtoplayer_post(ent, id) if(is_user_alive(id) && !cs_get_user_autoswitch(id))
{
    if(is_weapon_primary(cs_get_weapon_type(ent)) && pev_valid(g_weaponent[id]))
        fm_set_entity_visibility(g_weaponent[id], 1)
}

public bacon_item_deploy_post(ent)
{
    static id; id = pev(ent, pev_owner)
    if(is_user_alive(id))
    {
        static weapon; weapon = cs_get_weapon_type(ent)
        if(is_weapon_primary(weapon) || cs_get_user_shield(id))
            fm_set_entity_visibility(g_weaponent[id], 0)

        else if(cs_get_user_hasprim(id))
            fm_set_entity_visibility(g_weaponent[id], 1)
    }
}

stock get_weapon_model(weapon)
{
    switch(weapon)
    {
        case CSW_SCOUT:   return MODEL_SCOUT
        case CSW_XM1014
:  return MODEL_XM1014
        case CSW_AUG
:      return MODEL_AUG
        case CSW_UMP45
:   return MODEL_UMP45
        case CSW_SG550
:   return MODEL_SG550
        case CSW_GALIL
:   return MODEL_GALIL
        case CSW_FAMAS
:   return MODEL_FAMAS
        case CSW_AWP
:     return MODEL_AWP
        case CSW_M3
:     return MODEL_M3
        case CSW_MP5NAVY
: return MODEL_MP5NAVY
        case CSW_M249
:    return MODEL_M249
        case CSW_M4A1
:    return MODEL_M4A1
        case CSW_G3SG1
:   return MODEL_G3SG1
        case CSW_SG552
:   return MODEL_SG552
        case CSW_AK47
:    return MODEL_AK47
        case CSW_P90
:     return MODEL_P90
        case CSW_MAC10
:   return MODEL_MAC10    
        case CSW_TMP
:     return MODEL_TMP
    
}
    return 0
}

public plugin_natives()
    register_native("backweapons_set_transparency", "_backweapons_set_transparency")

public _backweapons_set_transparency(iPlugin, iParams)
{
    new id = get_param(1)
    
    if
(g_weaponent[id] > 0 && pev_valid(g_weaponent[id]))
        set_pev(g_weaponent[id], pev_renderamt, get_param_f(2))
}

stock fm_set_entity_visibility(index, visible = 1)
    set_pev(index, pev_effects, visible == 1 ? pev(index, pev_effects) & ~EF_NODRAW : pev(index, pev_effects) | EF_NODRAW


Далее В файле shared.txt там в начале...
Я так понял сюда нужно

Код: Выделить всё
if ( iInvisLevel )
{
set_user_rendering( id, kRenderFxNone, 0, 0, 0, kRenderTransTexture, iInvisLevel );

p_data_b[id][PB_INVIS] = true;
}


И это тоже впихнул remove_user_glow(id) там где возвращать нужно

Код: Выделить всё
#include <colorchat>

native backweapons_set_transparency(id, Float:fTransparency)

public set_user_glow(id, iRed = 0, iGreen = 0, iBlue = 0, iAlpha)
{
    set_user_rendering(id, kRenderFxGlowShell, iRed, iGreen, iBlue, kRenderTransAlpha, iAlpha)
    backweapons_set_transparency(id, float(iAlpha))
}
    
public remove_user_glow
(id)
{
    set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderNormal, 0)
    backweapons_set_transparency(id, 255.0)
}

// This should be called on weapon change, on new round, when the user selects a new skill, and after an item is purchased
public SHARED_INVIS_Set( id )
{
    // Do not want to set them as invisible if the player is currently rendering
    if ( !p_data_b[id][PB_CAN_RENDER] || !p_data_b[id][PB_ISCONNECTED] )
    {
        return;
    }

    new iInvisLevel = 0;

    static iSkillLevel;
    iSkillLevel = SM_GetSkillLevel( id, SKILL_INVISIBILITY );

    // If they are Human Alliance with Invisibility lets set the level
    if ( iSkillLevel > 0 )
    {
        iInvisLevel = p_invisibility[iSkillLevel-1];
    }

    // User has a Cloak of Invisibility
    if ( ITEM_Has( id, ITEM_CLOAK ) > ITEM_NONE )
    {
        // Then we are already a little invis, lets give them a little bonus for purchasing the item
        if ( iInvisLevel > 0 )
        {
            iInvisLevel = floatround( float( iInvisLevel ) / INVIS_CLOAK_DIVISOR );
        }
        else
        
{
            iInvisLevel = get_pcvar_num( CVAR_wc3_cloak );
        }
    }
    
    
// If the player is holding a knife they should be more invisible
    if ( SHARED_IsHoldingKnife( id ) )
    {
        iInvisLevel /= 2;
    }

    if ( iInvisLevel )
    {
                set_user_glow(id, iRed = 0, iGreen = 0, iBlue = 0, iAlpha)

        set_user_rendering( id, kRenderFxNone, 0, 0, 0, kRenderTransTexture, iInvisLevel );
        
        p_data_b
[id][PB_INVIS] = true;
    }

    // User should not be invisible
    else
    
{
        set_user_rendering( id );

        p_data_b[id][PB_INVIS] = false;
    }

    return;
}

// Function will return true if their active weapon is a knife
public SHARED_IsHoldingKnife( id )
{
    new iClip, iAmmo, iWeapon;
    iWeapon = get_user_weapon( id, iClip, iAmmo );

    // Check for Counter-Strike or Condition Zero
    if ( g_MOD == GAME_CSTRIKE || g_MOD == GAME_CZERO )
    {
        if ( iWeapon == CSW_KNIFE )
        {
            return true;
        }
    }

    // Check for Day of Defeat
    else if ( g_MOD == GAME_DOD )
    {
        if ( iWeapon == DODW_AMERKNIFE || iWeapon == DODW_GERKNIFE || iWeapon == DODW_SPADE )
        {
            return true;
        }
    }

    return false;
}

// Function returns true if the user has a grenade in his inventory
SHARED_HasGrenade( id )
{
    new i, bool:bNadeFound = false;
    
    
// Loop through all weapons and search for a grenade
    while ( g_PlayerWeapons[id][i] && !bNadeFound )
    {
        if ( SHARED_IsGrenade( g_PlayerWeapons[id][i] ) )
        {
            bNadeFound = true;
            break;
        }

        i++;
    }

    return bNadeFound;
}

bool:SHARED_IsGrenade( iWeapon )
{
    if ( g_MOD == GAME_CSTRIKE || g_MOD == GAME_CZERO )
    {
        if ( iWeapon == CSW_HEGRENADE )
        {
            return true;
        }
    }
    else if ( g_MOD == GAME_DOD )
    {
        if ( iWeapon == DODW_HANDGRENADE || iWeapon == DODW_STICKGRENADE )
        {
            return true;
        }
    }

    return false;
}

// Function checks to see if the weapon id is a primary weapon (used with Night Elf's Entangle)
SHARED_IsPrimaryWeapon( iWeaponID )
{
    // Check for Counter-Strike or Condition Zero
    if ( g_MOD == GAME_CSTRIKE || g_MOD == GAME_CZERO )
    {
        if ( iWeaponID == CSW_GALIL || iWeaponID == CSW_FAMAS || iWeaponID == CSW_M3 || iWeaponID == CSW_XM1014 || iWeaponID == CSW_MP5NAVY || iWeaponID == CSW_TMP || iWeaponID == CSW_P90 || iWeaponID == CSW_MAC10 || iWeaponID == CSW_UMP45 || iWeaponID == CSW_AK47 || iWeaponID == CSW_SG552 || iWeaponID == CSW_M4A1 || iWeaponID == CSW_AUG || iWeaponID == CSW_SCOUT || iWeaponID == CSW_AWP || iWeaponID == CSW_G3SG1 || iWeaponID == CSW_SG550 || iWeaponID == CSW_M249 )
        {
            return true;
        }
    }

    // Check for Day of Defeat
    else if ( g_MOD == GAME_DOD )
    {
        return false;
    }

    return false;
}

// Function will return the user's money
SHARED_GetUserMoney( id )
{
    // If user isn't connected - then he shouldn't have any money
    if ( !p_data_b[id][PB_ISCONNECTED] )
    {
        return 0;
    }

    // Check for Counter-Strike or Condition Zero
    if ( g_MOD == GAME_CSTRIKE || g_MOD == GAME_CZERO )
    {
        return cs_get_user_money( id );
    }

    // Check for Day of Defeat
    else if ( g_MOD == GAME_DOD )
    {
        return p_data[id][P_MONEY];
    }

    return 0;
}

// Function will set a user's money, if show is 1 then the difference will be displayed on screen
SHARED_SetUserMoney( id, money, show = 1 )
{
    if ( !p_data_b[id][PB_ISCONNECTED] )
    {
        return;
    }

    // Check for Counter-Strike or Condition Zero
    if ( g_MOD == GAME_CSTRIKE || g_MOD == GAME_CZERO )
    {
        // Don't allow the user to have more than 16000
        if ( money > 16000 )
        {
            money = 16000;
        }

        cs_set_user_money( id, money, show );
    }

    // Check for Day of Defeat
    else if ( g_MOD == GAME_DOD )
    {

        if ( !XP_MinPlayers() )
        {
            return;
        }

        new parm[3];
        parm[0] = id;
        parm[1] = 1;
        parm[2] = money - SHARED_GetUserMoney( id );

        p_data[id][P_MONEY] = money;
        _DOD_showMoney( parm );
    }

    return;
}

// Function will return an ammo name given a weapon ID
public SHARED_GetAmmoName( iWeapID, szAmmoName[], len )
{
    switch( iWeapID )
    {
        case CSW_USP, CSW_MAC10, CSW_UMP45:
        { 
            copy
( szAmmoName, len, "ammo_45acp" );
        }
        case CSW_ELITE, CSW_GLOCK18, CSW_MP5NAVY, CSW_TMP:
        {
            copy( szAmmoName, len, "ammo_9mm" );
        }
        case CSW_FIVESEVEN, CSW_P90:
        {
            copy( szAmmoName, len, "ammo_57mm" );
        }
        case CSW_DEAGLE:
        {
            copy( szAmmoName, len, "ammo_50ae" );
        }
        case CSW_P228:
        {
            copy( szAmmoName, len, "ammo_357sig" );
        }
        case CSW_SCOUT, CSW_G3SG1, CSW_AK47:
        {
            copy( szAmmoName, len, "ammo_762nato" );
        }
        case CSW_XM1014, CSW_M3:
        {
            copy( szAmmoName, len, "ammo_buckshot" );
        }
        case CSW_AUG, CSW_SG550, CSW_GALIL, CSW_FAMAS, CSW_M4A1:
        {
            copy( szAmmoName, len, "ammo_556nato" );
        }
        case CSW_AWP:
        {
            copy( szAmmoName, len, "ammo_338magnum" );
        }
        case CSW_M249:
        {
            copy( szAmmoName, len, "ammo_556natobox" );
        }
        case CSW_SG552:
        {
            copy( szAmmoName, len, "ammo_556nato" );
        }
        default:
        {
            copy( szAmmoName, len, "" );
        }
    }
}

// Function used to spawn a player
public _SHARED_Spawn( id )
{

    id -= TASK_SPAWN;
    
    
// Spawning doesn't work in DOD
    if ( g_MOD == GAME_DOD )
    {
        return;
    }

    // User is no longer connected or is not on a team
    if ( !p_data_b[id][PB_ISCONNECTED] || !SHARED_IsOnTeam( id ) )
    {
        return;
    }


    
    if 
( is_user_alive( id ) )
    {
        return;
    }

    // Save their previous weapons!
    SHARED_CopySavedWeapons( id );

    // Ignore the armor settaging...
    bIgnoreArmorSet[id] = true;

    // We don't want to call a crap-ton of WC3 functions when we're spawning them 3 times do we ?
    bIgnorePlayerSpawning[id] = true;

    // Spawn the player
    spawn( id );
    spawn( id );

    p_data_b[id][PB_SLOWED]        = false;
    p_data_b[id][PB_STUNNED]    = false;
    p_data_b[id][PB_GIVEITEMS]    = true;
    
    
// Give the user godmode for a little
    set_user_godmode( id, 1 );

    // Reset the user's skin to normal
    SHARED_ChangeSkin( id, SKIN_RESET );

    // The user should no longer be a mole!
    p_data_b[id][PB_MOLE] = false;

    set_task( 0.2, "_SHARED_Spawn_Final", TASK_SPAWNPLAYER + id );
    set_task( 0.4, "_SHARED_CS_GiveWeapons", TASK_GIVEITEMS + id );
    set_task( 1.0, "_SHARED_SpawnRemoveGod", TASK_SPAWNREMOVEGOD + id );

    return;
}

public _SHARED_SpawnRemoveGod( id )
{
    id -= TASK_SPAWNREMOVEGOD;

    // Only do this if the user is connected
    if ( p_data_b[id][PB_ISCONNECTED] )
    {
        set_user_godmode( id, 0 );
    }
}

// Function will just spawn a player again
public _SHARED_Spawn_Final( id )
{
    id -= TASK_SPAWNPLAYER;

    if ( !p_data_b[id][PB_ISCONNECTED] )
    {
        return;
    }

    // OK lets do something on this spawn!
    bIgnorePlayerSpawning[id] = false;

    spawn( id );
    
    bIgnoreArmorSet
[id] = false;

    // If we don't give them a suit then they won't have a HUD
    give_item( id, "item_suit" );
    
    
// Vengeance Check
    if ( p_data[id][P_RESPAWNBY] == RESPAWN_VENGEANCE )
    {
        set_user_health( id, VENGEANCE_HEALTH );
    }
    
    return
;
}

// Reincarnation for Day of Defeat
public SHARED_DOD_Reincarnation( id )
{

    if ( !WC3_Check() )
    {
        return;
    }
    
    new bReincarnate 
= 0;


    // Reincarnate from a skill?
    if ( SM_GetSkillLevel( id, SKILL_REINCARNATION ) > 0 )
    {
        new iSkillLevel = SM_GetSkillLevel( id, SKILL_REINCARNATION );

        // Then the user shouldn't reincarnate
        if ( iSkillLevel > 0 && random_float( 0.0, 1.0 ) <= p_ankh[iSkillLevel-1] )
        {
            bReincarnate = 2;
        }
    }

    // Only use item if we didn't reincarnate from a skill!
    if ( bReincarnate == 0 && g_bPlayerBoughtAnkh[id] )
    {
        bReincarnate = 1;
    }


    // Then we can't reincarnate
    if ( !bReincarnate )
    {
        return;
    }


    // User just joined - we don't actually have a place to respawn them!
    if ( g_DOD_ReincarnationStatus[id] == DOD_REINC_JUSTJOINED )
    {
        return;
    }

    // User died last time we tried this :/
    if ( g_DOD_ReincarnationStatus[id] == DOD_REINC_DIEDLAST )
    {
        client_print( id, print_chat, "%s %L", g_MODclient, id, "SKILL_REINCARNATION_SKIPPING" );

        g_DOD_ReincarnationStatus[id] = DOD_REINC_READY;
    }
    else
    
{
        // Remove the ankh here
        if ( bReincarnate == 1 )
        {
            g_bPlayerBoughtAnkh[id] = false;
        }

        client_cmd( id, "speak %s", g_szSounds[SOUND_REINCARNATION] );

        // Make the user glow!
        SHARED_Glow( id, 0, 100, 0, 0 );

        // Screen fade green
        Create_ScreenFade( id, (1<<10), (1<<10), (1<<12), 0, 255, 0, g_GlowLevel[id][1] );

        // Make sure the user doesn't get stuck in the ground!
        iReincarnation[id][ZPOS] += 30;

        set_user_origin( id, iReincarnation[id] );

        set_task( 0.1, "_SHARED_DOD_Reincarnation_Check", TASK_REINCARNATION + id );
        set_task( 2.5, "_SHARED_DOD_Reincarnation_Loc", TASK_REINCCHECK + id );
    }

    return;
}

public _SHARED_DOD_Reincarnation_Check( id )
{

    id -= TASK_REINCARNATION;

    if ( !p_data_b[id][PB_ISCONNECTED] )
    {
        return;
    }

    new origin[3];
    get_user_origin( id, origin );

    // Failure, stuck somewhere, put them back
    if ( origin[2] == iReincarnation[id][2] )
    {

        new ent = SHARED_FindFreeSpawn( id, false );
        
        
// Valid spawn found
        if ( ent > 0 )
        {
            new Float:fSpawnOrigin[3], vOrigin[3];
            
            
// Get the origin of the spawn point
            entity_get_vector( ent, EV_VEC_origin, fSpawnOrigin );

            // Convert float vector to int vector
            FVecIVec( fSpawnOrigin, vOrigin );
            
            
// Move the user
            set_user_origin( id, vOrigin );

            client_print( id, print_chat, "%s %L", g_MODclient, id, "SKILL_REINCARNATION_FAILED" )
        }

        // No Spawn found
        else
        
{
            set_task( 0.1, "_SHARED_DOD_Reincarnation", TASK_REINCARNATION + id );
        }
    }

    return;
}

public _SHARED_DOD_Reincarnation_Loc( id )
{
    id -= TASK_REINCCHECK;

    if ( !p_data_b[id][PB_ISCONNECTED] )
    {
        return;
    }
    
    g_DOD_ReincarnationStatus
[id] = ( is_user_alive( id ) ) ? DOD_REINC_READY : DOD_REINC_DIEDLAST;

    return;
}

// Reincarnation for Counter-Strike and Condition Zero
public SHARED_CS_Reincarnation( id )
{

    if ( !p_data_b[id][PB_ISCONNECTED] )
    {
        return;
    }

    // Giving weapons will only screw things up w/CSDM - so lets not do that!


    new bool:bGiveWeapons = false;
    
    
// If the give items flag is true
    if ( p_data_b[id][PB_GIVEITEMS] )
    {
        bGiveWeapons = true;
        p_data_b[id][PB_GIVEITEMS] = false;
    }
    
    
// Check based on skill or if the user has an item
    if ( p_data_b[id][PB_DIEDLASTROUND] )
    {
        static iSkillLevel;
        iSkillLevel = SM_GetSkillLevel( id, SKILL_REINCARNATION );

        // Orc's Reincarnation
        if ( iSkillLevel > 0 )
        {

            if ( random_float( 0.0, 1.0 ) <= p_ankh[iSkillLevel-1] )
            {
                bGiveWeapons = true;        
            
}
        }
        
        
// Ankh
        if ( g_bPlayerBoughtAnkh[id] )
        {
            bGiveWeapons = true;

            g_bPlayerBoughtAnkh[id] = false;
        }    
    
}

    if ( bGiveWeapons )
    {
        client_cmd( id, "speak %s", g_szSounds[SOUND_REINCARNATION] );
        
        
// Make the user glow!
        SHARED_Glow( id, 0, 100, 0, 0 );

        // Screen fade green
        Create_ScreenFade( id, (1<<10), (1<<10), (1<<12), 0, 255, 0, 255 );
        
        
// Give the user their weapons from last round
        set_task( 0.3, "_SHARED_CS_GiveWeapons", TASK_GIVEITEMS + id );
    }
    else
    
{
        if ( !cs_get_user_nvg( id ) )
        {
            p_data_b[id][PB_NIGHTVISION] = false;
        }
    }

    return;    
}    

public _SHARED_CS_GiveWeapons
(id)
{

    if ( id > TASK_GIVEITEMS )
    {
        id -= TASK_GIVEITEMS;
    }

    if ( !p_data_b[id][PB_ISCONNECTED] )
    {
        return;
    }

    // Check to see if the user should have the bomb
    new bool:bGiveBomb = false;
    if ( cs_get_user_plant( id ) )
    {
        bGiveBomb = true;
    }

    // Remove all weapons
    strip_user_weapons( id );

    // Give armor
    if ( p_data[id][P_LASTARMOR] )
    {
        // g_ArmorType
        cs_set_user_armor( id, p_data[id][P_LASTARMOR], g_ArmorType[id] );
    }
    
    
// Give a defuse kit
    if ( p_data_b[id][PB_DEFUSE] )
    {
        give_item(id, "item_thighpack");
    }

    if ( p_data_b[id][PB_NIGHTVISION] )
    {
        cs_set_user_nvg(id, 1);
    }

    // Give the user a bomb
    if ( bGiveBomb )
    {
        give_item( id, "weapon_c4" );

        cs_set_user_plant( id, 1, 1 );
    }
    
    new iWeapID 
= 0, i = 0, bool:bPrimaryFound = false;
    for ( i = 0; i < 32; i++ )
    {
        iWeapID = g_PlayerLastWeapons[id][i];

        if ( iWeapID )
        {
            if ( iWeapID != CSW_C4 && iWeapID != CSW_FLASHBANG )
            {
                new szWeaponName[32], szAmmoName[32];
                get_weaponname( iWeapID, szWeaponName, 31 );
                SHARED_GetAmmoName( iWeapID, szAmmoName, 31 );
                
                if 
( contain( szWeaponName, "weapon_" ) == 0 )
                {
                    give_item( id, szWeaponName );

                    if ( strlen( szAmmoName ) > 0 )
                    {
                        give_item( id, szAmmoName );
                        give_item( id, szAmmoName );
                        give_item( id, szAmmoName );
                        give_item( id, szAmmoName );
                        give_item( id, szAmmoName );
                    }
                }
            }
        }

        if ( SHARED_IsPrimaryWeapon( iWeapID ) )
        {
            new szWeaponName[32];
            get_weaponname( iWeapID, szWeaponName, 31 );

            bPrimaryFound = true;
        }
    }

    // Only give it if the user doesn't have a primary weapon
    if ( p_data_b[id][PB_SHIELD] )
    {
        if ( !bPrimaryFound )
        {
            give_item( id, "weapon_shield" );
        }
    }

    // Give them their flash bangs back
    while ( p_data[id][P_FLASHCOUNT] > 0 )
    {
        give_item( id, "weapon_flashbang" );

        p_data[id][P_FLASHCOUNT]--;
    }

    return;
}

public SHARED_SaveWeapons( id )
{
    if ( !is_user_alive( id ) )
    {
        return;
    }

    // Clear Array
    for( new i = 0; i < 32; i++ )
    {
        g_PlayerWeapons[id][i] = 0;
    }

    new num = 0;
    get_user_weapons( id, g_PlayerWeapons[id], num );
    
    return
;
}

// Copy the weapons over right before reset hud is called, that way we don't lose our last round weapons when the round restarts
public SHARED_CopySavedWeapons( id )
{
    for ( new i = 0; i < 33; i++ )
    {
        for ( new j = 0; j < 32; j++ )
        {
            g_PlayerLastWeapons[i][j] = g_PlayerWeapons[i][j];
        }
    }
}

// Sets the user's speed, should be called after freezetime, on weapon change and after a speed modifying skill has been called
public SHARED_SetSpeed( id )
{

    if ( id >= TASK_UNHOLYSPEED )
    {
        id -= TASK_UNHOLYSPEED;
    }

    if ( !p_data_b[id][PB_ISCONNECTED] )
    {
        return;
    }
    
    
// We should NOT change the user's speed during freezetime
    if ( g_freezeTime && ( g_MOD == GAME_CSTRIKE || g_MOD == GAME_CZERO ) )
    {
        return;
    }

    // User is stunned, we shouldn't change their speed
    else if ( p_data_b[id][PB_STUNNED] )
    {
        set_user_maxspeed( id, 1.0 );
                set_user_gravity(id, 10000.0)
        return;
    }

    // User is hexed, they should be slowed
    else if ( p_data_b[id][PB_HEXED] )
    {
        set_user_maxspeed( id, SH_HEX_SPEED );

        return;
    }

    // User is slowed
    else if ( p_data_b[id][PB_SLOWED] )
    {
        set_user_maxspeed( id, get_pcvar_float( CVAR_wc3_frost ) );
        
        return
;
    }
    
    
// Day of Defeat specific checks
    else if ( g_MOD == GAME_DOD )
    {
        
        
// User is in the prone position so we shouldn't change their speed
        if ( entity_get_int( id, EV_INT_iuser3 ) )
        {
            // When prone the maxspeed should be 50, never let it be different than this
            if ( get_user_maxspeed( id ) > 500.0 )
            {
                set_user_maxspeed( id, 50.0 );
            }

            return;
        }

        // User has a rocket launcher "mounted", we let users w/unholy aura + boots of speed run faster with it
        else if ( get_user_maxspeed( id ) == 50.0 && ( ITEM_Has( id, ITEM_BOOTS ) > ITEM_NONE || SM_GetSkillLevel( id, SKILL_UNHOLYAURA ) > 0 ) )
        {
            set_user_maxspeed( id, 600.0 );

            return;
        }
    }

    // Counter-Strike and Condition Zero specific checks
    else if ( g_MOD == GAME_CSTRIKE || g_MOD == GAME_CZERO )
    {
        new Float:fNewSpeed = 0.0;
        static iSkillLevel;
        iSkillLevel = SM_GetSkillLevel( id, SKILL_UNHOLYAURA );
        
        
// Unholy Aura bonus
        if ( iSkillLevel > 0.0 )
        {
            fNewSpeed = p_unholy[iSkillLevel-1];
        }

        // Boots of Speed bonus
        if ( ITEM_Has( id, ITEM_BOOTS ) > ITEM_NONE )
        {
            new iClip, iAmmo;
            new iWeapon = get_user_weapon( id, iClip, iAmmo );
            
            
// Then just apply the bonus!
            if ( fNewSpeed > 0.0 )
            {
                fNewSpeed *= ITEM_BOOT_INCREASE;
            }
            
            
// User only has boots
            else
            
{
                // Give them the bonus
                if ( g_iPlayerRole[id] == PLR_VIP )
                {
                    fNewSpeed = CS_SPEED_VIP * ITEM_BOOT_INCREASE;
                }
                // Player zoomed in
                else if ( g_bPlayerZoomed[id] )
                {
                    fNewSpeed = CS_WEAPON_SPEED_ZOOM[iWeapon] * ITEM_BOOT_INCREASE;
                }
                // Regular
                else
                
{
                    fNewSpeed = CS_WEAPON_SPEED[iWeapon] * ITEM_BOOT_INCREASE;
                }
            }
        }

        // Change the user's speed!
        if ( fNewSpeed > 0.0 )
        {
            set_user_maxspeed( id, fNewSpeed );

            return;
        }
    }

    // We would never get here unless we didn't hit any if statement from above
    if ( g_MOD == GAME_CSTRIKE || g_MOD == GAME_CZERO )
    {
        // Here we want to reset the user's speed
        new iClip, iAmmo;
        new iWeapon = get_user_weapon( id, iClip, iAmmo );
        
        if 
( g_iPlayerRole[id] == PLR_VIP )
        {
            set_user_maxspeed( id, CS_SPEED_VIP );
        }
        else if ( g_bPlayerZoomed[id] )
        {
            set_user_maxspeed( id, CS_WEAPON_SPEED_ZOOM[iWeapon] );
        }
        else
        
{
            set_user_maxspeed( id, CS_WEAPON_SPEED[iWeapon] );
        }
    }
    else if ( g_MOD == GAME_DOD )
    {
        set_user_maxspeed( id, 600.0 );
    }

    return;
}

public SHARED_ResetMaxSpeed( id )
{

    if ( id >= TASK_RESETSPEED )
    {
        id -= TASK_RESETSPEED;
    }


    if ( !p_data_b[id][PB_ISCONNECTED] )
    {
        return;
    }
    
    
// User should no longer be stunned
    p_data_b[id][PB_STUNNED]    = false;

    // User should no longer be slowed
    p_data_b[id][PB_SLOWED]        = false;

    SHARED_SetSpeed( id );
        set_user_gravity(id, 1.0)
    return;
}

// Returns true if the user is hexed/stunned/slowed
SHARED_IsPlayerSlowed( id )
{

    if ( p_data_b[id][PB_STUNNED] || p_data_b[id][PB_SLOWED] )
    {
        return true;
    }

    return false;
}

// Function changes your skin for ITEM_MOLE and Chameleon
public SHARED_ChangeSkin( id, iFlag )
{
    
    
// Don't change a bots model - it just confuses the bots!
    if ( is_user_bot( id ) )
    {
        return;
    }

    new szSkin[32];
    
    
// Reset the user's model
    if ( iFlag == SKIN_RESET && p_data_b[id][PB_SKINSWITCHED] )
    {

        if ( g_MOD == GAME_CSTRIKE || g_MOD == GAME_CZERO )
        {
            cs_reset_user_model( id );
        }
        else if ( g_MOD == GAME_DOD )
        {
            dod_clear_model( id );
        }

        p_data_b[id][PB_SKINSWITCHED] = false;
    }
    
    
// Switch the user's skin to the opposing team
    else if ( iFlag == SKIN_SWITCH )
    {
        new iTeam = get_user_team( id );
        
        
// For Counter-Strike or Condition Zero
        if ( g_MOD == GAME_CSTRIKE || g_MOD == GAME_CZERO )
        {
            new iModelNum = random_num( 0, 3 );
            
            
// Condition Zero has one more model!
            if ( g_MOD == GAME_CZERO )
            {
                iModelNum = random_num( 0, 4 );
            }
            
            
// Save which skin we're going to use
            if ( iTeam == TEAM_CT )
            {
                add( szSkin, 31, SKIN_T[iModelNum] );
            }
            else
            
{
                add( szSkin, 31, SKIN_CT[iModelNum] );
            }

            cs_set_user_model( id, szSkin );

        }

        // For Day of Defeat
        else if ( g_MOD == GAME_DOD )
        {
            new iModelNum = random_num( 0, 1 );

            if ( iTeam == ALLIES )
            {
                add( szSkin, 31, SKIN_AXIS[iModelNum] );
            }
            else
            
{
                
                
// Then we should use a British model
                if ( dod_get_map_info( MI_ALLIES_TEAM ) == 1 )
                {
                    add( szSkin, 31, SKIN_BRIT[0] );
                }
                
                
// Otherwise use American model
                else
                
{
                    add( szSkin, 31, SKIN_ALLIES[iModelNum] );
                }
            }
            
            dod_set_model
( id, szSkin );
        }

        p_data_b[id][PB_SKINSWITCHED] = true;
    }

    return;
}

public SHARED_SetGravity( id )
{

    // Can't set gravity if user isn't connected!
    if ( !p_data_b[id][PB_ISCONNECTED] )
    {
        return;
    }
    
    
// This user doesn't want their gravity to be changed! - Make sure it's 1.0!
    if ( !g_bLevitation[id] )
    {
        set_user_gravity( id, 1.0 );

        return;
    }

    // If gravity is less than this, lets not change per-user b/c it BLOWS ASS in game
    if ( CVAR_sv_gravity == 0 || get_pcvar_num( CVAR_sv_gravity ) > 650 )
    {
        static iSkillLevel;
        iSkillLevel = SM_GetSkillLevel( id, SKILL_LEVITATION );

        new Float:fGravityLevel = 1.0;

        // Our gravity level bonus because of undead's levitation
        if ( iSkillLevel > 0 )
        {
            fGravityLevel = p_levitation[iSkillLevel-1];
        }

        // Set the user's gravity based on the item
        if ( ITEM_Has( id, ITEM_SOCK ) > ITEM_NONE )
        {
            
            
// User has levitation + sock, give them an extra bonus
            if ( fGravityLevel > 0.0 )
            {
                fGravityLevel /= 2.0;

            }

            // User just has sock
            else
            
{
                fGravityLevel = get_pcvar_float( CVAR_wc3_sock );
            }
        }

        // Set the user's gravity!
        set_user_gravity( id, fGravityLevel );
    }

    return;
}

public SHARED_IsOnTeam( id )
{
    new iTeam = get_user_team( id );

    // Counter-Strike or Condition Zero Check
    if ( g_MOD == GAME_CSTRIKE || g_MOD == GAME_CZERO )
    {
        if ( iTeam == CTS || iTeam == TS )
        {
            return true;
        }
    }

    // Day of Defeat Check
    else if ( g_MOD == GAME_DOD )
    {
        if ( iTeam == ALLIES || iTeam == AXIS )
        {
            return true;
        }
    }

    return false;
}

// Reset our reserved spawn points
public _SHARED_SpawnReset()
{
    new i;

    for ( i = 0; i < TOTAL_SPAWNS; i++ )
    {
        g_iSpawnReserved[i] = 0;
    }
}

// Determine if this entity is reserved for another player
bool:SHARED_SpawnReserved( ent )
{
    new i;

    for ( i = 0; i < g_iSpawnInc; i++ )
    {
        if ( g_iSpawnReserved[i] == ent )
        {
            return true;
        }
    }

    return false;
}

// Find a free spawn!
SHARED_FindFreeSpawn( id, bImmunityCheck = false, bReverseTeam = false )
{

    new iPlayersInVicinity, iSpawnID, iEntList[1], vOrigin[3];
    new ent = -1;
    new Float:fSpawnOrigin[3];
    new Float:fVicinity = 96.0;
    new bool:bFound = false;
    new bool:bImmunityNear = false;
    
    new iTeam 
= get_user_team( id );

    // Reverse the team IDs (i.e. Mole would want this)
    if ( bReverseTeam )
    {
        if ( g_MOD == GAME_CSTRIKE || g_MOD == GAME_CZERO )
        {
            iTeam = ( ( iTeam == TEAM_CT ) ? TEAM_T : TEAM_CT );
        }
        else if ( g_MOD == GAME_DOD )
        {
            iTeam = ( ( iTeam == AXIS ) ? ALLIES : AXIS );
        }
    }

    // Need to determine which spawn point to look for based on the user's team
    if ( g_MOD == GAME_CSTRIKE || g_MOD == GAME_CZERO )
    {
        iSpawnID = ( ( iTeam == TEAM_CT ) ? 0 : 1 );
    }
    else if ( g_MOD == GAME_DOD )
    {
        iSpawnID = ( ( iTeam == AXIS ) ? 0 : 1 );
    }

    // Loop through each ent until we find a spawn entity that we want
    do {
        ent = find_ent_by_class( ent, szSpawnEnt[iSpawnID] );
        
        
// Valid ent found
        if ( ent != 0 )
        {
            entity_get_vector( ent, EV_VEC_origin, fSpawnOrigin );
            
            
// Convert float vector to int vector
            FVecIVec( fSpawnOrigin, vOrigin );

            // Check to see if there are players in this spawn
            iPlayersInVicinity = find_sphere_class( 0, "player", fVicinity, iEntList, 1, fSpawnOrigin );
            
            
// We have a free spawn!!
            if ( iPlayersInVicinity == 0 )
            {

                // Make sure it isn't reserved
                if ( !SHARED_SpawnReserved( ent ) )
                {


                    // We need to make sure there isn't anyone nearby that is immune
                    if ( bImmunityCheck )
                    {
                        // Immune found
                        if ( WC3_IsImmunePlayerNear( id, vOrigin ) )
                        {
                            bImmunityNear = true;
                        }

                        // We're clear!
                        else
                        
{
                            bImmunityNear = false;
                            bFound = true;
                        }
                    }
                    
                    
// We have a free spawn we can quit!
                    else
                    
{
                        bFound = true;
                    }
                }
            }
        }
    }
    while ( ent && !bFound && !bImmunityNear )
    
    
// Reset the spawn points...
    if ( !task_exists( TASK_RESETSPAWNS ) )
    {
        set_task( 0.3, "_SHARED_SpawnReset", TASK_RESETSPAWNS );
    }

    // Failed, nothing found
    if ( !bFound )
    {
        // Return a different value so they know the reason for failing
        if ( bImmunityCheck && bImmunityNear )
        {
            return -2;
        }

        return -1;
    }
    
    
// Otherwise we found something!
    return ent;
}

SHARED_MoleCheck( id, bItemOnly = false )
{
    new parm[2];
    parm[1] = 0;

    // Only do a skill check if bItemOnly is false
    if ( !bItemOnly )
    {
        static iSkillLevel;
        iSkillLevel = SM_GetSkillLevel( id, SKILL_FANOFKNIVES );

        // Mole from Fan of Knives?
        if ( iSkillLevel > 0 && random_float( 0.0, 1.0 ) <= p_fan[iSkillLevel-1] )
        {
            parm[1] = 1;
        }
    }
    
    
// Mole from an item?
    if ( parm[1] == 0 )
    {
        if ( g_bPlayerBoughtMole[id] )
        {
            parm[1] = 2;

            g_bPlayerBoughtMole[id] = false;
        }
    }

    // OK then lets mole!!
    if ( parm[1] > 0 )
    {
        parm[0] = id;
        
        set_task
( 0.1, "_SHARED_Mole", TASK_MOLE + id, parm, 2 );
    }
}

public _SHARED_Mole( parm[2] )
{
    
    new id 
= parm[0];

    if ( !p_data_b[id][PB_ISCONNECTED] )
    {
        return;
    }

    // Lets search for a new spawn (ignore immunity, reverse team ids)    
    new ent = SHARED_FindFreeSpawn( id, false, true );
    
    
// Free spawn found!!
    if ( ent > 0 )
    {
        new vOrigin[3], Float:fSpawnOrigin[3];
        
        
// Get the origin of the spawn
        entity_get_vector( ent, EV_VEC_origin, fSpawnOrigin );
        
        
// Convert float vector to int vector
        FVecIVec( fSpawnOrigin, vOrigin );
        
        
// Change the user's skin
        SHARED_ChangeSkin( id, SKIN_SWITCH );
        
        
// Move the user
        set_user_origin( id, vOrigin );

        // Shake the user's screen
        Create_ScreenShake( id, (255<< 14), (10 << 14), (255<< 14) );
        
        
// User is a mole
        p_data_b[id][PB_MOLE] = true;
        
        if 
( g_MOD == GAME_CSTRIKE || g_MOD == GAME_CZERO )
        {
            if ( !g_bMoleBuyZoneDisabled )
            {
                // Give the user a buyzone!
                SHARED_CreateBuyZone( id );

                // Display to target they can buy
#if AMXX_VERSION_NUM < 183
ColorChat(id, RED, "%L", LANG_PLAYER, "YOU_BASE_ENEMY");
#else
client_print_color(id, print_team_red, "%L", LANG_PLAYER, "YOU_BASE_ENEMY");
#endif
            }
        }
    }

    // No spawn found
    else
    
{
        // Moving b/c of item - if no spot then give the user his/her money back!
        if ( parm[1] == 2 )
        {
            SHARED_SetUserMoney( id, SHARED_GetUserMoney( id ) + ITEM_Cost( id, ITEM_MOLE ), 1 );

            client_print( id, print_chat, "%s %L", g_MODclient, id, "NO_SPOT_MOLE_MONEY" );
        }

        // Moving b/c of skill
        else
        
{
            client_print( id, print_chat, "%s %L", g_MODclient, id, "NO_SPOT_TO_MOLE" )
        }
    }

    return; 
} 

bool
:SHARED_ValidPlayer( id )
{
    if ( id < 1 || id > MAXPLAYERS )
    {
        return false;
    }

    return true;
}

#define MAXGLOW                    150

SHARED_Glow( id, iRed, iGreen, iBlue, iAll )
{
    
    
// Not allowed to glow right now...
    if ( !p_data_b[id][PB_CAN_RENDER] )
    {
        return;
    }
        
    
// Don't glow if invisible
    else if ( SM_GetSkillLevel( id, SKILL_INVISIBILITY ) > 0 || ITEM_Has( id, ITEM_CLOAK ) > ITEM_NONE )
    {
        return;
    }

    // Only glow if the task doesn't exist!
    else if ( task_exists( TASK_GLOW + id ) )
    {
        return;
    }
    
    if 
( iAll )
    {
        g_GlowLevel[id][0]    = 0;
        g_GlowLevel[id][1]    = 0;
        g_GlowLevel[id][2]    = 0;
        g_GlowLevel[id][3]    += iAll;
    }
    else if ( iRed )
    {
        g_GlowLevel[id][0]    += iRed;
        g_GlowLevel[id][1]    = 0;
        g_GlowLevel[id][2]    = 0;
        g_GlowLevel[id][3]    = 0;
    }
    else if ( iGreen )
    {
        g_GlowLevel[id][0]    = 0;
        g_GlowLevel[id][1]    += iGreen;
        g_GlowLevel[id][2]    = 0;
        g_GlowLevel[id][3]    = 0;
    }
    else if ( iBlue )
    {
        g_GlowLevel[id][0]    = 0;
        g_GlowLevel[id][1]    = 0;
        g_GlowLevel[id][2]    += iBlue;
        g_GlowLevel[id][3]    = 0;
    }

    // Lets make sure its not over the max!
    g_GlowLevel[id][0] = ( ( g_GlowLevel[id][0] > MAXGLOW ) ? MAXGLOW : g_GlowLevel[id][0] );
    g_GlowLevel[id][1] = ( ( g_GlowLevel[id][1] > MAXGLOW ) ? MAXGLOW : g_GlowLevel[id][1] );
    g_GlowLevel[id][2] = ( ( g_GlowLevel[id][2] > MAXGLOW ) ? MAXGLOW : g_GlowLevel[id][2] );
    g_GlowLevel[id][3] = ( ( g_GlowLevel[id][3] > MAXGLOW ) ? MAXGLOW : g_GlowLevel[id][3] );
    

    _SHARED_Glow
( id );
}

public _SHARED_Glow( id )
{
    
    if 
( id >= TASK_GLOW )
    {
        id -= TASK_GLOW;
    }

    // User is no longer connected, so lets not continue this!
    if ( !p_data_b[id][PB_ISCONNECTED] )
    {
        return;
    }
    
    new iRed    
= g_GlowLevel[id][0];
    new iGreen    = g_GlowLevel[id][1];
    new iBlue    = g_GlowLevel[id][2];
    new iAll    = g_GlowLevel[id][3];

    // Then we want to glow
    if ( iRed || iGreen || iBlue )
    {

        g_GlowLevel[id][0] = ( ( iRed > 5 )        ? iRed - 5        : 0 );
        g_GlowLevel[id][1] = ( ( iGreen > 5 )    ? iGreen - 5    : 0 );
        g_GlowLevel[id][2] = ( ( iBlue > 5 )    ? iBlue - 5        : 0 );

        set_user_rendering( id, kRenderFxGlowShell, iRed, iGreen, iBlue, kRenderNormal, 16 );

                remove_user_glow(id)
    }

    else if ( iAll )
    {
        g_GlowLevel[id][3] = ( ( iAll > 5 )        ? iAll - 5        : 0 );
        
        set_user_rendering
( id, kRenderFxGlowShell, iAll, iAll, iAll, kRenderNormal, 16 );

                remove_user_glow(id)
    }

    // No more glowing!
    else
    
{
        set_user_rendering( id );

        return;
    }

    set_task( 0.2, "_SHARED_Glow", TASK_GLOW + id );

    return;
}

SHARED_GetMaxArmor( id )
{
    id--;    // Need this or a dumb compiler warning :/

    return 100;
}

// Returns if an origin is near an objective (returns which objective)
SHARED_NearObjective( vOrigin[3] )
{

    new i, Float:fOrigin[3];
    
    
// Convert vector to float
    IVecFVec( vOrigin, fOrigin );

    // Check the distances
    for ( i = 0; i < g_iTotalObjectiveEnts; i++ )
    {
        new Float:fDistance = vector_distance( fOrigin, g_fObjectiveOrigin[i] );

        if ( fDistance < 250.0 )
        {
            return g_iObjectiveEntType[i];
        }
    }

    return -1;
}

// This will create a buyzone on a target and remove it when buytime is complete
SHARED_CreateBuyZone( id )  
{       
    new iEnt 
= create_entity( "func_buyzone" );  

    new Float
:vPlayerOrigin[3];  
    entity_get_vector
( id, EV_VEC_origin, vPlayerOrigin );  
    entity_set_vector
( iEnt, EV_VEC_origin, vPlayerOrigin );  

    DispatchSpawn
( iEnt );  

    new Float
:fDuration = ( get_pcvar_float( CVAR_mp_buytime ) * 60.0 );

    set_task( fDuration, "_SHARED_RemoveBuyZone", TASK_REMOVEBUYZONE + iEnt );  

    return
;       
}  

// This will remove the buyzone if it exists
public _SHARED_RemoveBuyZone( iEnt )  
{
    if ( iEnt >= TASK_REMOVEBUYZONE )
    {      
        iEnt 
-= TASK_REMOVEBUYZONE;      
    
}

    // Make sure we're removing a valid entity!
    if ( is_valid_ent( iEnt ) )
    {
        remove_entity( iEnt );  
    
}

    return;  
}

stock SHARED_ForceWeaponChange( id )
{
    new iAmmo, iClip, szWeaponName[32], i;
    new num = 0, iWeapons[32];

    new iCurWeapon = get_user_weapon( id, iAmmo, iClip );

    // We need a valid current weapon to do this!
    if ( iCurWeapon != 0 )
    {
        // Get all weapons the user is holding
        get_user_weapons( id, iWeapons, num );

        // Loop through all weapons
        for ( i = 0; i < num; i++ )
        {
            
            
// Find a weapon the player isn't currently holding
            if ( iWeapons[i] != iCurWeapon && iWeapons[i] > 0 )
            {
                get_weaponname( iWeapons[i], szWeaponName, 31 );

                client_cmd( id, szWeaponName );

                break;
            }
        }

        // Switch back to the user's current weapon
        get_weaponname( iCurWeapon, szWeaponName, 31 );
        client_cmd( id, szWeaponName );
    }

    return;
}
МультиМод CS
Аватара пользователя
MayroN
 
Сообщения: 673
Зарегистрирован: 10 окт 2010, 18:23
Откуда: Украина, г. Белая Церковь
Благодарил (а): 149 раз.
Поблагодарили: 86 раз.
Опыт программирования: Около года
Языки программирования: На которых говорю...


Вернуться в Скриптинг

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 9