AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Zoom (https://forums.alliedmods.net/showthread.php?t=221692)

AwesomeMan 07-25-2013 06:57

Zoom
 
Hello, I want a player to unzoom when they change a weapon. As I made ak47 zoomable, works great but when player changes weapon it doesnt unzoom, it keeps the zoom. Heres the code i tried for unzooming while weapon change;

Code:

public event_curweapon(id)
{
        new gun = read_data(2)
       
        if((gun != CSW_AK47 && g_hasZoom[id])) {
                g_hasZoom[ id ] = false
                cs_set_user_zoom(id,CS_RESET_ZOOM,0)
        }
}

also, it does set g_hasZoom[id] to false but it doesnt unzoom.

In plugin_init
register_event("CurWeapon", "event_curweapon", "be", "1=1")
and this to set zoom on ATTACK2:
cs_set_user_zoom( id, CS_SET_AUGSG552_ZOOM, 0 )

Bos93 07-25-2013 10:54

Re: Zoom
 
PHP Code:

#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >
#tryinclude < cstrike_pdatas > 

#if !defined _cbaseentity_included 
        #assert Cstrike Pdatas and Offsets library required! Read the below instructions:   \ 
                
1. Download it at forums.alliedmods.net/showpost.php?p=1712101#post1712101   \ 
                
2. Put it into amxmodx/scripting/include/ folder   
                
3. Compile this plugin locallydetailswiki.amxmodx.org/index.php/Compiling_Plugins_%28AMX_Mod_X%29   
                
4. Install compiled plugindetailswiki.amxmodx.org/index.php/Configuring_AMX_Mod_X#Installing 
#endif 

#define PLUGIN_NAME "New-Plugin"
#define PLUGIN_VERSION "0.0.0.1"
#define PLUGIN_AUTHOR "Andrei"

public plugin_init( ) 
{
    
register_plugin
    

        
PLUGIN_NAME
        
PLUGIN_VERSION
        
PLUGIN_AUTHOR 
    
);
    
    
register_forwardFM_CmdStart"Forward__CmdStart_Post", ._post true );
    
    
RegisterHamHam_Item_Holster"weapon_ak47""CBasePlayerItem__Holster_Pre", .Post false );
}

public 
Forward__CmdStart_PostpPlayerUcCmdiRandomSeed )
{
    if( !
is_user_alivepPlayer ) || get_user_weaponpPlayer ) != CSW_AK47 )
        return 
FMRES_IGNORED;
    if( ~
get_pdata_intpPlayerm_afButtonPressedXO_CBASEPLAYER ) & IN_ATTACK2 )
        return 
FMRES_IGNORED;
    
    new 
pEntity get_pdata_cbasepPlayerm_pActiveItemXO_CBASEPLAYER );
    
    if( 
get_pdata_floatpEntitym_flNextSecondaryAttackXO_CBASEPLAYERITEM ) > 0.0 )
        return 
FMRES_IGNORED;
    if( 
get_pdata_floatpPlayerm_flNextAttackXO_CBASEMONSTER ) > 0.0 )
        return 
FMRES_IGNORED;
        
    
set_pdata_floatpEntitym_flNextSecondaryAttack0.3XO_CBASEPLAYERITEM );
    
    
CBasePlayerItem__Holster_PrepEntity )
    
    return 
FMRES_IGNORED;
}

public 
CBasePlayerItem__Holster_PrepEntity )
{
    new 
pPlayer get_pdata_cbasepEntitym_pPlayerXO_CBASEPLAYERITEM );
    new 
iFOV get_pdata_intpPlayerm_iFOVXO_CBASEPLAYER ) == 90 55 90;
    
    
set_pdata_intpPlayerm_iFOViFOV );



AwesomeMan 07-25-2013 12:03

Re: Zoom
 
Quote:

Originally Posted by Bos93 (Post 1998477)
PHP Code:

#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >
#tryinclude < cstrike_pdatas > 

#if !defined _cbaseentity_included 
        #assert Cstrike Pdatas and Offsets library required! Read the below instructions:   \ 
                
1. Download it at forums.alliedmods.net/showpost.php?p=1712101#post1712101   \ 
                
2. Put it into amxmodx/scripting/include/ folder   
                
3. Compile this plugin locallydetailswiki.amxmodx.org/index.php/Compiling_Plugins_%28AMX_Mod_X%29   
                
4. Install compiled plugindetailswiki.amxmodx.org/index.php/Configuring_AMX_Mod_X#Installing 
#endif 

#define PLUGIN_NAME "New-Plugin"
#define PLUGIN_VERSION "0.0.0.1"
#define PLUGIN_AUTHOR "Andrei"

public plugin_init( ) 
{
    
register_plugin
    

        
PLUGIN_NAME
        
PLUGIN_VERSION
        
PLUGIN_AUTHOR 
    
);
    
    
register_forwardFM_CmdStart"Forward__CmdStart_Post", ._post true );
    
    
RegisterHamHam_Item_Holster"weapon_ak47""CBasePlayerItem__Holster_Pre", .Post false );
}

public 
Forward__CmdStart_PostpPlayerUcCmdiRandomSeed )
{
    if( !
is_user_alivepPlayer ) || get_user_weaponpPlayer ) != CSW_AK47 )
        return 
FMRES_IGNORED;
    if( ~
get_pdata_intpPlayerm_afButtonPressedXO_CBASEPLAYER ) & IN_ATTACK2 )
        return 
FMRES_IGNORED;
    
    new 
pEntity get_pdata_cbasepPlayerm_pActiveItemXO_CBASEPLAYER );
    
    if( 
get_pdata_floatpEntitym_flNextSecondaryAttackXO_CBASEPLAYERITEM ) > 0.0 )
        return 
FMRES_IGNORED;
    if( 
get_pdata_floatpPlayerm_flNextAttackXO_CBASEMONSTER ) > 0.0 )
        return 
FMRES_IGNORED;
        
    
set_pdata_floatpEntitym_flNextSecondaryAttack0.3XO_CBASEPLAYERITEM );
    
    
CBasePlayerItem__Holster_PrepEntity )
    
    return 
FMRES_IGNORED;
}

public 
CBasePlayerItem__Holster_PrepEntity )
{
    new 
pPlayer get_pdata_cbasepEntitym_pPlayerXO_CBASEPLAYERITEM );
    new 
iFOV get_pdata_intpPlayerm_iFOVXO_CBASEPLAYER ) == 90 55 90;
    
    
set_pdata_intpPlayerm_iFOViFOV );



Cheers :fox:
Works great, thank you =D

Smatify 07-26-2013 13:47

Re: Zoom
 
Quote:

Originally Posted by LordOfNothing (Post 1999275)
:nono: #tryinclude < cstrike_pdatas > wtf ???

Quote:

Originally Posted by ConnorMcLeod (Post 1712101)
If you use those includes, you can include them like this :
PHP Code:

#tryinclude <cstrike_pdatas>

#if !defined _cbaseentity_included
        #assert Cstrike Pdatas and Offsets library required! Read the below instructions:   \
                
1. Download it at forums.alliedmods.net/showpost.php?p=1712101#post1712101   \
                
2. Put it into amxmodx/scripting/include/ folder   \
                
3. Compile this plugin locallydetailswiki.amxmodx.org/index.php/Compiling_Plugins_%28AMX_Mod_X%29   \
                
4. Install compiled plugindetailswiki.amxmodx.org/index.php/Configuring_AMX_Mod_X#Installing
#endif 




All times are GMT -4. The time now is 06:20.

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