Raised This Month: $51 Target: $400
 12% 

help to fix this plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
cahervar
Member
Join Date: Mar 2021
Old 08-07-2021 , 17:08   help to fix this plugin
Reply With Quote #1

the capsule plugin when you die leaves a capsule where you can grab the weapons that player had, the problem is that the grenades you grab from that box won't let you throw them. You can use the weapon, but not grenades. can someone correct it?
Thank you

PHP Code:
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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/caja.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""1" )    
    
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 )
}
/*·························································*/ 
cahervar is offline
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 08-08-2021 , 22:01   Re: help to fix this plugin
Reply With Quote #2

Ok, I tested a bit with it, leaving some "helpful" info for someone else who can actually help him:
TESTING ENVIRONMENT: I die with 1 of each grenades
RESULTS:
A) You pick up a capsule, it gives u 1 HE, 1 FLASH, and 0 SMOKEgrenades with 1 CLIP ammo (aka like this: https://i.imgur.com/XKu2z7W.png )
B) You pick up a capsule, it gives u 0 HE, 0 FLASH, and 0 SMOKEGRENADES with 1 CLIP ammo.
C) Sometimes ALL OF THE ABOVE depends on the INSTANCE, if I change map/restart server it alternates between variant A and B.

Adding a switch case in CapsuleItems function and doing nothing depending on case CSW_HEGRENADE CSW_FLASHBANG CSW_SMOKEGRENADE will add the correct amount, but will not increment whatever the user already has. And is not consistent (for some reason, variant C still applies,hence why I didn't post code).

https://www.amxmodx.org/api/cstrike/cs_set_user_bpammo ->> Did it ever have an identifier for grenades? Maybe? I'm not sure since I wasn't scripting in 2013 or whenever this plugin was ported from AMX.
__________________

Last edited by deprale; 08-08-2021 at 22:02.
deprale is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:04.


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