Raised This Month: $159 Target: $400
 39% 

nVault plugin not working


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-14-2020 , 21:37   nVault plugin not working
Reply With Quote #1

Hey, so I wanted to try and make a plugin with nVault, I followed this tutorial made by Bugsy, but I can't get it to work.

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

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

public 
plugin_end()
{
    
nvault_closeg_Vault );
}

public 
client_putinserver(id)
{
    
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)
    
    
get_user_authid(idg_szAuthID[id], charsmax(g_szAuthID[]));

    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:47   Re: nVault plugin not working
Reply With Quote #2

When the player first connects, LoadPrefix() is called which uses g_szAuthID[] to make the key to read from the vault. At that time, g_szAuthID[] is empty since you are not populating it until menu_prefix() is called.
__________________
Bugsy is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-14-2020 , 21:51   Re: nVault plugin not working
Reply With Quote #3

I tried it like this, I called the menu, choose the prefix I wanted, logout, logged back in, no prefix.
__________________
Contact! || Discord:
Mr_Boopsy_#2066
supertrio17 is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-14-2020 , 22:05   Re: nVault plugin not working
Reply With Quote #4

Quote:
Originally Posted by Bugsy View Post
When the player first connects, LoadPrefix() is called which uses g_szAuthID[] to make the key to read from the vault. At that time, g_szAuthID[] is empty since you are not populating it until menu_prefix() is called.
Oh okay, I just got what you said, so how do I fix that?
__________________
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:08   Re: nVault plugin not working
Reply With Quote #5

Make sure g_szAuthID[] holds a valid value before you try to use it.
__________________
Bugsy is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-14-2020 , 22:13   Re: nVault plugin not working
Reply With Quote #6

How do I do that, sorry, I'm pretty newbie.
__________________
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:18   Re: nVault plugin not working
Reply With Quote #7

Change
PHP Code:
public client_putinserver(id)
{
    
LoadPrefix(id)

to

PHP Code:
public client_authorizedid )
{
    
get_user_authid(idg_szAuthID[id], charsmax(g_szAuthID[]));
    
LoadPrefix(id)

And remove get_user_authid() in menu_prefix().
__________________
Bugsy is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-14-2020 , 22:23   Re: nVault plugin not working
Reply With Quote #8

Quote:
Originally Posted by Bugsy View Post
Change
PHP Code:
public client_putinserver(id)
{
    
LoadPrefix(id)

to

PHP Code:
public client_authorizedid )
{
    
get_user_authid(idg_szAuthID[id], charsmax(g_szAuthID[]));
    
LoadPrefix(id)

And remove get_user_authid() in menu_prefix().
I did, and it still doesn't work. Any other ideas?
__________________
Contact! || Discord:
Mr_Boopsy_#2066

Last edited by supertrio17; 06-14-2020 at 22:23.
supertrio17 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-14-2020 , 22:36   Re: nVault plugin not working
Reply With Quote #9

What is not working specifically
__________________
Bugsy is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-14-2020 , 22:41   Re: nVault plugin not working
Reply With Quote #10

Quote:
Originally Posted by Bugsy View Post
What is not working specifically
Well, I type /prefix in chat, it gives me my menu, I choose, and I get my prefix, but when I disconnect and join again, there is no prefix. I want to save my choice so when I get back I will have the prefix that I selected before.
__________________
Contact! || Discord:
Mr_Boopsy_#2066
supertrio17 is offline
Old 06-14-2020, 22:46
Bugsy
This message has been deleted by Bugsy.
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 14:32.


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