Raised This Month: $ Target: $400
 0% 

Solved help with register_clcmd


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
lexzor
Veteran Member
Join Date: Nov 2020
Old 07-29-2022 , 22:09   Re: help with register_clcmd
Reply With Quote #4

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


Last edited by lexzor; 07-29-2022 at 22:11.
lexzor is offline
 



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 15:37.


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