Thread: [Solved] help with register_clcmd
View Single Post
krudge137
Junior Member
Join Date: Jun 2022
Old 07-30-2022 , 11:21   Re: help with register_clcmd
Reply With Quote #5

Quote:
Originally Posted by lexzor View Post
oke
PHP Code:
#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >
#include < amxmisc >
#include < nvault >

#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 )

#if !defined MAX_AUTHID_LENGTH
    #define MAX_AUTHID_LENGTH 64
#endif

const m_iFOV 363;

new 
customFOV[32];

new 
g_nVault;
new const 
g_sznVaultName[] = "fov";

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 );

    
g_nVault nvault_open(g_sznVaultName);

    if(
g_nVault == INVALID_HANDLE)
        
set_fail_state("Couldn t open ^"%s^" nvault file"g_sznVaultName);
}

public 
plugin_end()
{
    
nvault_close(g_nVault);
}

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();

    
save_user_fov(idiFOV);

    return 
PLUGIN_HANDLED;
}

save_user_fov(const id, const fov)
{
    new 
szAuthID[MAX_AUTHID_LENGTH];
    
get_user_authid(idszAuthIDcharsmax(szAuthID));

    new 
szData[5];
    
num_to_str(fovszDatacharsmax(szData));
    
nvault_set(g_nVaultszAuthIDszData);
}

public 
client_authorized(id)
{
    new 
iTsszData[5], szAuthID[MAX_AUTHID_LENGTH];
    
get_user_authid(idszAuthIDcharsmax(szAuthID));
    if(
nvault_lookup(g_nVaultszAuthIDszDatacharsmax(szData), iTs))
        
customFOV[id] = str_to_num(szData);
}

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 ] );
    }

Thank you so much man!
krudge137 is offline