Thread: [Solved] help with register_clcmd
View Single Post
lexzor
Veteran Member
Join Date: Nov 2020
Old 07-29-2022 , 15:07   Re: help with register_clcmd
Reply With Quote #2

try this one

PHP Code:
#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >
#include < amxmisc >

#pragma semicolon 1

#define PLUGIN "Default FOV"
#define VERSION "1.0"
#define AUTHOR "God Of Gaming"

#define CS_DEFAULT_FOV 90 
#define cm(%0)    ( sizeof(%0) - 1 )

const m_iFOV 363;

new 
customFOV[32];

public 
plugin_init() {
    
register_pluginPLUGINVERSIONAUTHOR );

    for( new 
i=0i<32i++)
        
customFOV] = CS_DEFAULT_FOV;

    
register_clcmd("say""sayHandle");
    
register_clcmd("say_team""sayHandle");
    
    
register_messageget_user_msgid"SetFOV" ), "Message_SetFOV" );
    
RegisterHamHam_Spawn"player""OnCBasePlayer_Spawn_P"true );
}

public 
sayHandle(id)
{
    static 
szArg[192];
    
read_args(szArgcharsmax(szArg));
    
remove_quotes(szArg);

    if(
containi(szArg"/fov") != -1)
    {
        
replace(szArgcharsmax(szArg), "/fov """);
        
userFOV(idstr_to_num(szArg));
    }
}

public 
userFOVidiFOV ) {
    
    if( ( 
iFOV 90 ) || ( iFOV 180 ) )
        return 
PLUGIN_HANDLED;

    
customFOVid ] = iFOV;

    
message_beginMSG_ONEget_user_msgid"SetFOV" ), {0,0,0}, id );
    
write_byteiFOV );
    
message_end();

    return 
PLUGIN_HANDLED;
}

public 
Message_SetFOVmsg_idmsg_destmsg_entity ) {
    if( !
is_user_alivemsg_entity ) || get_msg_arg_int) != CS_DEFAULT_FOV )
        return;

    
set_msg_arg_int1get_msg_argtype), customFOVmsg_entity ] );
}

public 
OnCBasePlayer_Spawn_Pid ) {
    if( 
is_user_aliveid ) ) {
        
set_pdata_intidm_iFOVcustomFOVid ] );
    }

lexzor is offline