Raised This Month: $ Target: $400
 0% 

Solved help with register_clcmd


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
krudge137
Junior Member
Join Date: Jun 2022
Old 07-29-2022 , 15:11   help with register_clcmd
Reply With Quote #1

Hey I want to modify this Plugin , I want it to be used with the say command instead of typing in console, "say /fov 100" for example.

Last edited by krudge137; 07-30-2022 at 11:24.
krudge137 is offline
lexzor
Senior Member
Join Date: Nov 2020
Old 07-29-2022 , 16: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
krudge137
Junior Member
Join Date: Jun 2022
Old 07-29-2022 , 21:07   Re: help with register_clcmd
Reply With Quote #3

It's working like a charm, but is it possible to make it save each player's fov? cuz it's changes back to default after map change, Thank you in advance!
krudge137 is offline
lexzor
Senior Member
Join Date: Nov 2020
Old 07-29-2022 , 23: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 23:11.
lexzor is offline
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
Reply


Thread Tools
Display Modes

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 06:30.


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