Raised This Month: $ Target: $400
 0% 

nVault plugin not working


Post New Thread Reply   
 
Thread Tools Display Modes
Old 06-14-2020, 21:46
Bugsy
This message has been deleted by Bugsy.
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-14-2020 , 21:47   Re: nVault plugin not working
Reply With Quote #2

Post your latest code
__________________
Bugsy is offline
Old 06-14-2020, 21:50
supertrio17
This message has been deleted by supertrio17.
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-14-2020 , 21:50   Re: nVault plugin not working
Reply With Quote #4

Quote:
Originally Posted by Bugsy View Post
Post your latest code
PHP Code:
#include <amxmodx> 
#include <amxmisc> 
#include <chatmanager>
#include <nvault>

#define FORMAT_SAY "format_admin"
#define FORMAT_TSAY "format_admin_team"

new g_iPrefix[33];
new 
g_Vault;
new 
g_szAuthID[33][35]; 

public 
plugin_init()
{
    
register_plugin("Proba Prefix""3.2""Mr. Boopsy");
    
register_clcmd("say /prefix",    "prefix_menu")
}

public 
plugin_cfg()
{
    
g_Vault nvault_open"PrefixVault2" );

    if ( 
g_Vault == INVALID_HANDLE )
        
set_fail_state"Error opening nVault" );
}

public 
plugin_end()
{
    
nvault_closeg_Vault );
}

public 
client_authorized(id)
{
    
get_user_authid(idg_szAuthID[id], charsmax(g_szAuthID[]));
    
LoadPrefix(id)


public 
prefix_menu(id)
{
    new 
menu menu_create("\r[\wChoose your Prefix\r]\r""menu_prefix")
    
    
menu_additem(menu"\wPLAYER""1"0)
    
menu_additem(menu"\wADMIN""2"0)
    
menu_additem(menu"\wOWNER""3"0)

    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
    
menu_display(idmenu0)
}

public 
menu_prefix(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    new 
data[6], iName[64]
    new 
accescallback
    menu_item_getinfo
(menuitemaccesdata,5iName63callback)
    
    new 
key str_to_num(data)

    switch(
key)
    { 
       case 
1
       {
            new 
szPrefix[30];
            new 
szKey[40];
            
cm_set_user_say_format(idFORMAT_SAYFORMAT_TSAY);
            
cm_set_user_prefix(id"[PLAYER]");
            
g_iPrefix[id] = 1;

            
formatex(szKeycharsmaxszKey ), "%sPREFIX"g_szAuthID[id]);
            
formatex(szPrefixcharsmaxszPrefix ), "%d"g_iPrefix[id]);
            
nvault_set(g_VaultszKeyszPrefix);
       }
       case 
2
       {
            new 
szPrefix[30];
            new 
szKey[40];
            
cm_set_user_say_format(idFORMAT_SAYFORMAT_TSAY);
            
cm_set_user_prefix(id"[ADMIN]");
            
g_iPrefix[id] = 2;

            
formatex(szKeycharsmaxszKey ), "%sPREFIX"g_szAuthID[id]);
            
formatex(szPrefixcharsmaxszPrefix ), "%d"g_iPrefix[id]);
            
nvault_set(g_VaultszKeyszPrefix);
       }
       case 
3:
       {
            new 
szPrefix[30];
            new 
szKey[40];
            
cm_set_user_say_format(idFORMAT_SAYFORMAT_TSAY);
            
cm_set_user_prefix(id"[OWNER]");
            
g_iPrefix[id] = 3;

            
formatex(szKeycharsmaxszKey ), "%sPREFIX"g_szAuthID[id]);
            
formatex(szPrefixcharsmaxszPrefix ), "%d"g_iPrefix[id]);
            
nvault_set(g_VaultszKeyszPrefix);
       }
    }
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED
}  

LoadPrefix(id)
{
    new 
szKey[40];
    
formatex(szKeycharsmaxszKey ), "%sPREFIX"g_szAuthID[id]);
    new 
iPrefix nvault_get(g_VaultszKey);

    switch(
iPrefix)
    { 
       case 
1
       {
            
cm_set_user_say_format(idFORMAT_SAYFORMAT_TSAY);
            
cm_set_user_prefix(id"[PLAYER]");
       }
       case 
2
       {
            
cm_set_user_say_format(idFORMAT_SAYFORMAT_TSAY);
            
cm_set_user_prefix(id"[ADMIN]");
       }
       case 
3:
       {
            
cm_set_user_say_format(idFORMAT_SAYFORMAT_TSAY);
            
cm_set_user_prefix(id"[OWNER]");
       }
    }   

__________________
Contact! || Discord:
Mr_Boopsy_#2066
supertrio17 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-14-2020 , 21:58   Re: nVault plugin not working
Reply With Quote #5

Do some debugging. In menu_prefix(), for each of your case values, do a log_amx() or server_print() to see if that code is getting reached.
__________________
Bugsy is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-14-2020 , 22:07   Re: nVault plugin not working
Reply With Quote #6

So I did this, and it appears that public client_authorized(id) is not sending a message, and nothing from LoadPrefix(id), here is my code, I set id to 0 so I could get that message on my cpanel.

PHP Code:
#include <amxmodx> 
#include <amxmisc> 
#include <chatmanager>
#include <CromChat>
#include <nvault>

#define FORMAT_SAY "format_admin"
#define FORMAT_TSAY "format_admin_team"

new g_iPrefix[33];
new 
g_Vault;
new 
g_szAuthID[33][35]; 

public 
plugin_init()
{
    
register_plugin("Proba Prefix""3.2""Mr. Boopsy");
    
register_clcmd("say /prefix",    "prefix_menu")
}

public 
plugin_cfg()
{
    
g_Vault nvault_open"PrefixVault2" );

    if ( 
g_Vault == INVALID_HANDLE )
        
set_fail_state"Error opening nVault" );
}

public 
plugin_end()
{
    
nvault_closeg_Vault );
}

public 
client_authorized(id)
{
    
get_user_authid(idg_szAuthID[id], charsmax(g_szAuthID[]));
    
LoadPrefix(id)
    
CC_SendMessage(0"&x01>> &x04client_authorized");


public 
prefix_menu(id)
{
    new 
menu menu_create("\r[\wChoose your Prefix\r]\r""menu_prefix")
    
    
menu_additem(menu"\wPLAYER""1"0)
    
menu_additem(menu"\wADMIN""2"0)
    
menu_additem(menu"\wOWNER""3"0)

    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
    
menu_display(idmenu0)
}

public 
menu_prefix(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    new 
data[6], iName[64]
    new 
accescallback
    menu_item_getinfo
(menuitemaccesdata,5iName63callback)
    
    new 
key str_to_num(data)

    switch(
key)
    { 
       case 
1
       {
            new 
szPrefix[30];
            new 
szKey[40];
            
cm_set_user_say_format(idFORMAT_SAYFORMAT_TSAY);
            
cm_set_user_prefix(id"[PLAYER]");
            
g_iPrefix[id] = 1;

            
formatex(szKeycharsmaxszKey ), "%sPREFIX"g_szAuthID[id]);
            
formatex(szPrefixcharsmaxszPrefix ), "%d"g_iPrefix[id]);
            
nvault_set(g_VaultszKeyszPrefix);
            
CC_SendMessage(0"&x01>> &x04menu case 1");
       }
       case 
2
       {
            new 
szPrefix[30];
            new 
szKey[40];
            
cm_set_user_say_format(idFORMAT_SAYFORMAT_TSAY);
            
cm_set_user_prefix(id"[ADMIN]");
            
g_iPrefix[id] = 2;

            
formatex(szKeycharsmaxszKey ), "%sPREFIX"g_szAuthID[id]);
            
formatex(szPrefixcharsmaxszPrefix ), "%d"g_iPrefix[id]);
            
nvault_set(g_VaultszKeyszPrefix);
            
CC_SendMessage(0"&x01>> &x04menu case 2");
       }
       case 
3:
       {
            new 
szPrefix[30];
            new 
szKey[40];
            
cm_set_user_say_format(idFORMAT_SAYFORMAT_TSAY);
            
cm_set_user_prefix(id"[OWNER]");
            
g_iPrefix[id] = 3;

            
formatex(szKeycharsmaxszKey ), "%sPREFIX"g_szAuthID[id]);
            
formatex(szPrefixcharsmaxszPrefix ), "%d"g_iPrefix[id]);
            
nvault_set(g_VaultszKeyszPrefix);
            
CC_SendMessage(0"&x01>> &x04menu case 3");
       }
    }
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED
}  

LoadPrefix(id)
{
    new 
szKey[40];
    
formatex(szKeycharsmaxszKey ), "%sPREFIX"g_szAuthID[id]);
    new 
iPrefix nvault_get(g_VaultszKey);
    
CC_SendMessage(0"&x01>> &x04Loading prefix");

    switch(
iPrefix)
    { 
       case 
1
       {
            
cm_set_user_say_format(idFORMAT_SAYFORMAT_TSAY);
            
cm_set_user_prefix(id"[PLAYER]");
            
CC_SendMessage(0"&x01>> &x04Loading prefix case 1");
       }
       case 
2
       {
            
cm_set_user_say_format(idFORMAT_SAYFORMAT_TSAY);
            
cm_set_user_prefix(id"[ADMIN]");
            
CC_SendMessage(0"&x01>> &x04Loading prefix case 2");
       }
       case 
3:
       {
            
cm_set_user_say_format(idFORMAT_SAYFORMAT_TSAY);
            
cm_set_user_prefix(id"[OWNER]");
            
CC_SendMessage(0"&x01>> &x04Loading prefix case 3");
       }
    }   

__________________
Contact! || Discord:
Mr_Boopsy_#2066
supertrio17 is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-14-2020 , 22:11   Re: nVault plugin not working
Reply With Quote #7

I did debug too, but no errors.
__________________
Contact! || Discord:
Mr_Boopsy_#2066
supertrio17 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-14-2020 , 22:16   Re: nVault plugin not working
Reply With Quote #8

You're not looking for errors by debugging. You add logging or server/console prints so you can see specifically what happens through the code. Once you learn how to do this, you can figure most things out on your own.

Example
Code:
LoadPrefix(id) {     new szKey[40];     formatex(szKey, charsmax( szKey ), "%sPREFIX", g_szAuthID[id]);     new iPrefix = nvault_get(g_Vault, szKey);     server_print( "prefix value for [%s] is %d" , szKey , iPrefix );     CC_SendMessage(0, "&x01>> &x04Loading prefix");     switch(iPrefix)     {        case 1:        {             server_print( "case 1 reached" );             cm_set_user_say_format(id, FORMAT_SAY, FORMAT_TSAY);             cm_set_user_prefix(id, "[PLAYER]");             CC_SendMessage(0, "&x01>> &x04Loading prefix case 1");        }
__________________

Last edited by Bugsy; 06-14-2020 at 22:17.
Bugsy is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-14-2020 , 22:27   Re: nVault plugin not working
Reply With Quote #9

@Bugsy hey, so I got this when I logged in
Code:
prefix value for [STEAM_0:0:hiddenPREFIX] is 1
case 1 reached
client_authorized reached
PHP Code:
#include <amxmodx> 
#include <amxmisc> 
#include <chatmanager>
#include <CromChat>
#include <nvault>

#define FORMAT_SAY "format_admin"
#define FORMAT_TSAY "format_admin_team"

new g_iPrefix[33];
new 
g_Vault;
new 
g_szAuthID[33][35]; 

public 
plugin_init()
{
    
register_plugin("Proba Prefix""3.2""Mr. Boopsy");
    
register_clcmd("say /prefix",    "prefix_menu")
}

public 
plugin_cfg()
{
    
g_Vault nvault_open"PrefixVault2" );
    
server_print("plugin_cfg reached");

    if ( 
g_Vault == INVALID_HANDLE )
        
set_fail_state"Error opening nVault" );
}

public 
plugin_end()
{
    
nvault_closeg_Vault );
    
server_print("plugin closed");
}

public 
client_authorized(id)
{
    
get_user_authid(idg_szAuthID[id], charsmax(g_szAuthID[]));
    
LoadPrefix(id)
    
CC_SendMessage(0"&x01>> &x04client_authorized");
    
server_print("client_authorized reached");


public 
prefix_menu(id)
{
    new 
menu menu_create("\r[\wChoose your Prefix\r]\r""menu_prefix")
    
    
menu_additem(menu"\wPLAYER""1"0)
    
menu_additem(menu"\wADMIN""2"0)
    
menu_additem(menu"\wOWNER""3"0)

    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
    
menu_display(idmenu0)
    
server_print("menu callback");
}

public 
menu_prefix(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    new 
data[6], iName[64]
    new 
accescallback
    menu_item_getinfo
(menuitemaccesdata,5iName63callback)
    
    new 
key str_to_num(data)

    switch(
key)
    { 
       case 
1
       {
            new 
szPrefix[30];
            new 
szKey[40];
            
cm_set_user_say_format(idFORMAT_SAYFORMAT_TSAY);
            
cm_set_user_prefix(id"[PLAYER]");
            
g_iPrefix[id] = 1;

            
formatex(szKeycharsmaxszKey ), "%sPREFIX"g_szAuthID[id]);
            
formatex(szPrefixcharsmaxszPrefix ), "%d"g_iPrefix[id]);
            
nvault_set(g_VaultszKeyszPrefix);
            
server_print("menu case 1 reached");
            
CC_SendMessage(0"&x01>> &x04menu case 1");
       }
       case 
2
       {
            new 
szPrefix[30];
            new 
szKey[40];
            
cm_set_user_say_format(idFORMAT_SAYFORMAT_TSAY);
            
cm_set_user_prefix(id"[ADMIN]");
            
g_iPrefix[id] = 2;

            
formatex(szKeycharsmaxszKey ), "%sPREFIX"g_szAuthID[id]);
            
formatex(szPrefixcharsmaxszPrefix ), "%d"g_iPrefix[id]);
            
nvault_set(g_VaultszKeyszPrefix);
            
server_print("menu case 2 reached");
            
CC_SendMessage(0"&x01>> &x04menu case 2");
       }
       case 
3:
       {
            new 
szPrefix[30];
            new 
szKey[40];
            
cm_set_user_say_format(idFORMAT_SAYFORMAT_TSAY);
            
cm_set_user_prefix(id"[OWNER]");
            
g_iPrefix[id] = 3;

            
formatex(szKeycharsmaxszKey ), "%sPREFIX"g_szAuthID[id]);
            
formatex(szPrefixcharsmaxszPrefix ), "%d"g_iPrefix[id]);
            
nvault_set(g_VaultszKeyszPrefix);
            
server_print("menu case 3 reached");
            
CC_SendMessage(0"&x01>> &x04menu case 3");
       }
    }
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED
}  

LoadPrefix(id)
{
    new 
szKey[40];
    
formatex(szKeycharsmaxszKey ), "%sPREFIX"g_szAuthID[id]);
    new 
iPrefix nvault_get(g_VaultszKey);
    
server_print("prefix value for [%s] is %d" szKey iPrefix );
    
CC_SendMessage(0"&x01>> &x04Loading prefix");

    switch(
iPrefix)
    { 
       case 
1
       {
            
cm_set_user_say_format(idFORMAT_SAYFORMAT_TSAY);
            
cm_set_user_prefix(id"[PLAYER]");
            
server_print("case 1 reached");
            
CC_SendMessage(0"&x01>> &x04Loading prefix case 1");
       }
       case 
2
       {
            
cm_set_user_say_format(idFORMAT_SAYFORMAT_TSAY);
            
cm_set_user_prefix(id"[ADMIN]");
            
server_print("case 2 reached");
            
CC_SendMessage(0"&x01>> &x04Loading prefix case 2");
       }
       case 
3:
       {
            
cm_set_user_say_format(idFORMAT_SAYFORMAT_TSAY);
            
cm_set_user_prefix(id"[OWNER]");
            
server_print("case 3 reached");
            
CC_SendMessage(0"&x01>> &x04Loading prefix case 3");
       }
    }   

Which means that code did work, so I have one idea, might work
__________________
Contact! || Discord:
Mr_Boopsy_#2066
supertrio17 is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-14-2020 , 22:33   Re: nVault plugin not working
Reply With Quote #10

I swear that you will kill me one day, all this because cm_set_user_prefix and cm_set_user_say_format won't load right away, so what I needed to do is simply change
Code:
public client_authorized(id)
to
Code:
public client_putinserver(id)
I remembered OciXCrom telling me that exact same thing about his plugin. Sorry for spending 2 hours of your life...
__________________
Contact! || Discord:
Mr_Boopsy_#2066
supertrio17 is offline
Reply



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 17:14.


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