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

Capsule 2.9 [Please Help]

Scripting help for english speaking users. While not very active, you still have a chance to get help here.
Правила форума
We cannot maintain english version version of our forum rules, but shortly (it's simple) - Don't be a dick. If you really want to know our rules you should check appropriate thread.

Capsule 2.9 [Please Help]

Сообщение Guilford » 07 ноя 2016, 06:54

Guys please help me with this plugins Capsule. There is problem in that plugin, when you picking up capsule, example: you killed guy with m4a1, then you picking up capsule and u taking his ak-47, and then you have 2 primary weapons, same with pistols. I want to make, if you have already primary weapon and pistol, then it will not pick up. Only ammo, armor, nades, etc... Please help!

Код: Выделить всё
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This plugin is based on original Half-Life game. When someone dies, release a capsule that contains the
weapons and items of dead player. When another player grabs capsule, receive items in the capsule.

There're three modes of playing with capsules:
* cp_teammode 0: Every player can pick capsules
* cp_teammode 1: Only players of the same team can pick capsules droped by someone
* cp_teammode 2: Only players of the other team can pick capsules droped by someone

You can enable/disable glowing:
* cp_glowmode 0: Glow disabled
* cp_glowmode 1: Glow enabled

Cvars: 
cp_teammode 1:
    0: Anyone can catch the capsule.
    1: Only the same team can catch the capsule.
    2: Only the opposing team can catch the capsule.

cp_glowmode 1:
    0: Glow disabled.
    1: Glow enabled.

cp_remove 0:
    0: Do not remove the capsules.
    1: Remove the capsules.

cp_bounce 1:
    0: Off the bounce in the capsule.
    1: On the bounce on the capsule. 

Credits:
Joropito
IneedHelp
meTaLiCroSS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <cstrike>
#include <engine>
#include <fun>

#define Plugin    "Capsule"
#define Version    "2.9"
#define Author    "Asd'"

#define    Clip 51
#define WeaponLinux 4

/*················[Models][Sprites][Sounds]···············*/
new CapsuleMdl[] = "models/w_weaponbox.mdl"

new ReceivedSd[] = "items/gunpickup3.wav"
new BounceSd[] = "weapons/g_bounce1.wav"

new SmokeSpr[] = "sprites/steam1.spr"
/*························································*/

/*·························[Weapons Consts][BPAmmo Consts]·························*/
new const 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) |
    (
1<<CSW_P228) | (1<<CSW_ELITE) | (1<<CSW_FIVESEVEN) | 
    (
1<<CSW_USP) | (1<<CSW_GLOCK18)    | (1<<CSW_DEAGLE) | 
    (
1<<CSW_FLASHBANG) | (1<<CSW_HEGRENADE) | (1<<CSW_SMOKEGRENADE)
)

new const 
MaxBPAmmo[] = {
    -
152, -1901321100901120100,
    
100909090100120,
    
30120200329012090,
    
2359090, -1100
}
/*·················································································*/

/*······[Glow Colors]·····*/
new Float:Colors[3][3] = {
    {
0.0200.00.0}, 
    {
200.00.00.0}, 
    {
0.00.0200.0
}
/*······················*/

/*·····[Variables]·····*/
new Bounce
new Remove
new GlowMode
new TeamMode
new Smoke
/*·····················*/

/*·····[Arrays]·····*/
new UserWeapons[33]
new 
Capsule[33]
new 
UserAmmo[33]
new 
UserClip[33]
/*···················*/

public plugin_init( )
{
    
/* Plugin */
    
register_pluginPluginVersionAuthor )
    
    
/* Cvars & Commands */
    
Bounce register_cvar"cp_bounce""0" )    
    
Remove register_cvar"cp_remove""0" )    
    
GlowMode register_cvar"cp_glowmode""1" )
    
TeamMode register_cvar"cp_teammode""1" )
    
    
/* Engine Fowards */
    
register_touch"Capsule""player""CapsuleTouch" )
    
register_touch"Capsule""worldspawn""CapsuleBounce" )
    
register_think"Capsule""CapsuleThink" )
    
    
/* Hamsandwich Forwards */
    
RegisterHamHam_Killed"player""CapsuleCreate")
    
RegisterHamHam_Spawn"player""CapsuleRemoved")
    
    
/* Others */
    
register_cvar"cp_author"AuthorFCVAR_SERVER|FCVAR_SPONLY /* Game monitor */
    
register_cvar"cp_version"VersionFCVAR_SERVER|FCVAR_SPONLY /* Game monitor */
}

public 
plugin_precache( )
{
    
/* Precache model */
    
precache_modelCapsuleMdl )
    
    
/* Precache sprite */
    
Smoke precache_modelSmokeSpr )
    
    
/* Precache sounds */
    
precache_soundReceivedSd )
    
precache_soundBounceSd )
}

public 
CapsuleCreateVictimAttackerShouldGib )
{
    new 
Float:Origin[3]
    new 
Float:Velocidad[3]
    
    
CapsuleRemoveVictim )
    
    new 
Entidad create_entity"info_target" )
    new 
Team get_user_teamVictim )
    
    
entity_get_vectorVictimEV_VEC_originOrigin )
    
entity_set_stringEntidadEV_SZ_classname"Capsule" )
    
entity_set_modelEntidadCapsuleMdl )
    
    if( 
get_pcvar_numGlowMode ) )
    {
        
entity_set_intEntidadEV_INT_rendermodekRenderNormal)
        
entity_set_intEntidadEV_INT_renderfxkRenderFxGlowShell )
        
        
entity_set_vectorEntidadEV_VEC_rendercolorget_pcvar_numTeamMode ) ? Colors[Team] : Colors[0] )
        
entity_set_floatEntidadEV_FL_renderamt10.0 )
    }
    
    
entity_set_edictEntidadEV_ENT_ownerVictim )
    
entity_set_intEntidadEV_INT_iuser1Team )
    
entity_set_intEntidadEV_INT_iuser2Victim )
    
    
entity_set_sizeEntidadFloat:{ -10.0, -10.0, -0.0 },  Float:{ 10.010.00.0 } )
    
entity_set_originEntidadOrigin )
    
    
entity_set_intEntidadEV_INT_solidSOLID_TRIGGER )
    
    if( 
get_pcvar_numBounce ) )
        
entity_set_intEntidadEV_INT_movetypeMOVETYPE_BOUNCE )
    else
        
entity_set_intEntidadEV_INT_movetypeMOVETYPE_TOSS )
    
    
entity_get_vectorVictimEV_VEC_velocityVelocidad )
    
entity_set_vectorEntidadEV_VEC_velocityVelocidad )
    
    
Capsule[Victim] = Entidad
    
    CapsuleItems
VictimEntidad )
    
entity_set_floatEntidadEV_FL_nextthinkget_gametime( ) + 1.0 )
    
    return 
HAM_HANDLED
}

public 
CapsuleRemovedid )
{
    if( 
get_pcvar_numRemove ) )
        
CapsuleRemoveid )
    
    return 
HAM_IGNORED
}

public 
CapsuleThinkEntidad )
{
    new 
Float:Origin[3]
    
pevEntidadpev_originOrigin )
    
    new 
OriginEnd[3]
    
OriginEnd[0] = floatroundOrigin[0] )
    
OriginEnd[1] = floatroundOrigin[1] )
    
OriginEnd[2] = floatroundOrigin[2] )
    
    
message_beginMSG_BROADCASTSVC_TEMPENTITY )
    
write_byteTE_SMOKE )
    
write_coordOriginEnd[0] )
    
write_coordOriginEnd[1] )
    
write_coordOriginEnd[2] )
    
write_shortSmoke )
    
write_byterandom_num510 ) )
    
write_byte10 )
    
message_end( )
    
    
entity_set_floatEntidadEV_FL_nextthinkget_gametime( ) + 1.0 )
}

public 
CapsuleBounceEntidadWorld )
{
    if( !
is_valid_entEntidad ) )
        return 
PLUGIN_HANDLED
    
    
if( entity_get_edictEntidadEV_ENT_owner ) )
        
entity_set_edictEntidadEV_ENT_owner)
    
    if( 
get_pcvar_numBounce ) )
    {    
        new 
Float:Velocidad[3]
        
entity_get_vectorEntidadEV_VEC_velocityVelocidad )
        
        
Velocidad[0] -= Velocidad[0] / 10.0
        Velocidad
[1] -= Velocidad[1] / 5.0
        Velocidad
[2] -= Velocidad[2] / 0.0
        
        entity_set_vector
EntidadEV_VEC_velocityVelocidad )
        
emit_soundEntidadCHAN_ITEMBounceSd1.0ATTN_NORM0PITCH_NORM )
    }
    return 
PLUGIN_HANDLED
}


public 
CapsuleTouchEntidadIndex )
{
    if( !
is_user_aliveIndex ) )
        return 
PLUGIN_HANDLED
    
    
if( !is_valid_entEntidad ) )
        return 
PLUGIN_HANDLED
    
    
if( entity_get_edictEntidadEV_ENT_owner ) )
        return 
PLUGIN_HANDLED
    
    
new WeaponsDT[32]
    new 
OldEntidad entity_get_intEntidadEV_INT_iuser2 )
    new 
NewAmmo
    
new OldAmmo
    
new NewClip
    
new WPEntidad
    
    entity_get_string
EntidadEV_SZ_noise1UserWeaponscharsmaxUserWeapons ) )
    
entity_get_stringEntidadEV_SZ_noise2UserAmmocharsmaxUserAmmo) )
    
entity_get_stringEntidadEV_SZ_noise3UserClipcharsmaxUserClip) )
    
    for(new 
0charsmaxUserWeapons ); i++)
    {
        if( 
UserWeapons[i] == )
            break
        
        if( 
MaxBPAmmo[UserWeapons[i]] > )
        {
            if( !
user_has_weaponIndexUserWeapons[i] ) )
            {
                
get_weaponnameUserWeapons[i], WeaponsDTcharsmaxWeaponsDT ) )
                
give_itemIndexWeaponsDT )
                
                
WPEntidad WeaponEntidadIndexUserWeapons[i]) 
                
NewAmmo UserAmmo[i]
                
NewClip UserClip[i]
            }
            else
            {
                
OldAmmo cs_get_user_bpammoIndexUserWeapons[i] )
                
NewAmmo = ( MaxBPAmmo[UserWeapons[i]] + OldAmmo ) < UserAmmo[i] ? MaxBPAmmo[UserWeapons[i]] : UserAmmo[i]
                
WPEntidad WeaponEntidadIndexUserWeapons[i] )
                
NewClip get_pdata_intWPEntidadClipWeaponLinux )
            }
            
cs_set_user_bpammoIndexUserWeapons[i], NewAmmo )
            
set_pdata_intWPEntidadClipNewClipWeaponLinux )
        }
    }
    
emit_soundEntidadCHAN_ITEMReceivedSd1.0ATTN_NORM0PITCH_NORM )
    
CapsuleRemoveOldEntidad )
    
    return 
PLUGIN_HANDLED
}

public 
CapsuleItemsIndexEntidad )
{
    new 
CarriedWeapons[32]
    new 
NumWeapons
    
new WeaponID
    
new i
    
    get_user_weapons
IndexCarriedWeaponsNumWeapons )
    
    for(
0NumWeaponsi++)
    {
        
UserWeapons[i] = CarriedWeapons[i]
        
WeaponID WeaponEntidadIndexUserWeapons[i] )
        
        if( 
Weapons & ( << CarriedWeapons[i] ) )
            
get_user_ammoIndexCarriedWeapons[i], UserClip[i], UserAmmo[i] )
        else
            
UserAmmo[i] = UserClip[i] = -1
        
        ExecuteHamB
Ham_Weapon_RetireWeaponWeaponID )
        
ExecuteHamBHam_RemovePlayerItemIndexWeaponID )
        
ExecuteHamBHam_Item_KillWeaponID )
    }
    
UserWeapons[i] = UserAmmo[i] = UserClip[i] = 0
    
    entity_set_string
EntidadEV_SZ_noise1UserWeapons )
    
entity_set_stringEntidadEV_SZ_noise2UserAmmo )
    
entity_set_stringEntidadEV_SZ_noise3UserClip )
}

/*·························[Stocks]·························*/
stock CapsuleRemoveIndex )
{
    if( ( 
Capsule[Index] != ) && is_valid_entCapsule[Index] ) )
    {
        
remove_entityCapsule[Index] )
        
Capsule[Index] = 0
    
}
}

stock WeaponEntidadIndexWeaponID )
{
    static 
szWeaponName[32]
    
get_weaponnameWeaponIDszWeaponNamecharsmaxszWeaponName ) )
    
    return 
find_ent_by_owner(-1szWeaponNameIndex )
}
/*·························································*/
 
Аватара пользователя
Guilford
 
Сообщения: 1
Зарегистрирован: 07 ноя 2016, 06:35
Благодарил (а): 0 раз.
Поблагодарили: 0 раз.
Языки программирования: Pawn
SourcePawn
C++
Php
Ruby
Python
C#

Re: Capsule 2.9 [Please Help]

Сообщение Bos93 » 07 ноя 2016, 08:50

Need to drop a weapon that you have, when you pick up someone else's?

Example: You have m4a1, you killed player, he drop ak47, you touch weapon, get it and drop m4a1?
Всем добра, любви и осознанности.

Nosce animum tuum.

А осознание и есть, что понял и осмыслил..
А коль не думал ты о том, то кто о том замыслил..?
Аватара пользователя
Bos93
 
Сообщения: 1416
Зарегистрирован: 03 апр 2010, 13:44
Благодарил (а): 149 раз.
Поблагодарили: 508 раз.

Re: Capsule 2.9 [Please Help]

Сообщение Fedcomp » 07 ноя 2016, 10:14

Hello, please make better topic name and we will reopen topic for you.
Не помогаю в ЛС - есть форум.
Плагины тоже не пишу, на форуме достаточно хороших скриптеров.
Аватара пользователя
Fedcomp
Администратор
 
Сообщения: 4330
Зарегистрирован: 28 авг 2009, 20:47
Благодарил (а): 699 раз.
Поблагодарили: 1181 раз.
Языки программирования: Counter-Strike 1.6


Вернуться в Scripting

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

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