Raised This Month: $ Target: $400
 0% 

Help with fvault


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xeloxded
Member
Join Date: Dec 2016
Old 07-05-2017 , 14:35   Help with fvault
Reply With Quote #1

PHP Code:
#include <amxmodx>
#include <engine>
#include <cstrike>
#include <fun>
#include <fvault>

new name[32]
new 
data[24]
new 
Gorros[20]

new const 
g_db[] = "Database"

enum {
    
ITEM_HAT 0,
    
MAX_ITEMS
}

enum {
    
SHOPPED 0,
    
HAS,
    
IDENDIFIER
}

enum 
{
    
HID_AFRO 0,
    
HID_ANGEL2,
    
MAX_HIDS
}
enum HATS_DATA {
    
H_NAME[25],
    
H_ID,
    
H_COST,
    
H_MODEL[50]
}

new const 
szHats[][HATS_DATA] = {
    { 
"Afro"HID_AFRO1"models/hats/afro.mdl" },
    { 
"Angel 2"HID_ANGEL22"models/hats/angel2.mdl" }
}

new 
g_menu[200]

new 
g_playername[33][32]
new 
g_playeritem[33][MAX_ITEMS]
new 
g_hashat[33][IDENDIFIER][MAX_HIDS]

new 
g_hat[33]

public 
plugin_init() {
    
    
register_clcmd("say /hats""ShowMenuMain")
}

public 
client_putinserver(id)
{
    
Load(id)
    for(new 
0sizeof szHatsi++)
    {
        
g_hashat[id][SHOPPED][szHats[i][H_ID]] = false
        g_hashat
[id][HAS][szHats[i][H_ID]] = false
    
}
    
    
g_playeritem[id][ITEM_HAT] = -1
    
//g_frags[id] = 0
    
    
get_user_name(idg_playername[id], charsmax(g_playername[]))
}

public 
client_disconnect(id)
{
    
Save(id)
    if(
g_playeritem[id][ITEM_HAT] >= 0)
        
SetPlayerHat(id1szHats[g_playeritem[id][ITEM_HAT]][H_MODEL])
}

public 
plugin_precache()
{
    new 
i
    
    
for(0sizeof szHatsi++)
        
precache_model(szHats[i][H_MODEL])
}

public 
ShowMenuMain(id)
{
    new 
menui
    menu 
menu_create("\rHats""ShowMenuMain")
    
    for(
0sizeof szHatsi++)
    {
        if(
g_hashat[id][SHOPPED][szHats[i][H_ID]])
        {
            if(
g_hashat[id][HAS][szHats[i][H_ID]])
            {
                
formatex(g_menucharsmax(g_menu), "%s \y[ACTIVE]"szHats[i][H_NAME])
                
menu_additem(menug_menu"")
            }
            else
                
menu_additem(menuszHats[i][H_NAME], "")
        }
        else
        {
            if(
cs_get_user_money(id) >= szHats[i][H_COST])
            {
                
formatex(g_menucharsmax(g_menu), "%s \y$%d"szHats[i][H_NAME], szHats[i][H_COST])
                
menu_additem(menug_menu"")
            }
            else
            {
                
formatex(g_menucharsmax(g_menu), "%s \r[YOU NEED $%d]"szHats[i][H_NAME],
                
szHats[i][H_COST] - cs_get_user_money(id))
                
menu_additem(menug_menu"")
            }
        }
    }
    
    
menu_display(idmenu)
}

public 
CmdMenuHats(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED;
    }
    
    if(
g_hashat[id][SHOPPED][szHats[item][H_ID]])
    {
        if(
g_hashat[id][HAS][szHats[item][H_ID]])
            
client_print(idprint_chat"Ya tienes el sombrero %s Activo"szHats[item][H_NAME])
        else
        {
            if(
g_playeritem[id][ITEM_HAT] != -1)
                
g_hashat[id][HAS][g_playeritem[id][ITEM_HAT]] = false
                
            g_hashat
[id][HAS][szHats[item][H_ID]] = true
            client_print
(idprint_chat"Has seleccionado el sombrero %s"szHats[item][H_NAME])
            
g_playeritem[id][ITEM_HAT] = item
            SetPlayerHat
(id_szHats[item][H_MODEL])
        }
    }
    else
    {
        if(
cs_get_user_money(id) >= szHats[item][H_COST])
        {
       new 
Money cs_get_user_money(id);
            
g_hashat[id][SHOPPED][szHats[item][H_ID]] = true
            Money 
-= szHats[item][H_COST]
            
client_print(0print_chat"%sYou just Bought %s"g_playername[id], szHats[item][H_NAME])
        }
        else
            
client_print(idprint_chat"You need %d money to buy %s",
            
szHats[item][H_COST] - cs_get_user_money(id), szHats[item][H_NAME])
    }
    
    return 
PLUGIN_HANDLED;
}

SetPlayerHat(idiRemove 0, const sModel[] = "")
{
    if(!
iRemove)
    {
        if (!
is_valid_ent(g_hat[id]))
        {
            
g_hat[id] = create_entity("info_target")
            
            if (!
is_valid_ent(g_hat[id]))
                return;
            
            
entity_set_int(g_hat[id], EV_INT_movetypeMOVETYPE_FOLLOW)
            
entity_set_edict(g_hat[id], EV_ENT_aimentid)
            
entity_set_int(g_hat[id], EV_INT_rendermodekRenderNormal)
        }
        
        
entity_set_model(g_hat[id], sModel)
    }
    else
    {
        if (
is_valid_ent(g_hat[id]))
        {
            
remove_entity(g_hat[id])
            
g_hat[id] = 0
        
}            
    }
}

Loadid )
{
    
get_user_nameidnamecharsmaxname ) )

    if( 
fvault_get_datag_dbnamedatacharsmaxdata ) ) )
    {
        
parsedataGorroscharsmaxGorros ) )

        
g_hat[id] = str_to_numGorros )
    }
}

Saveid )
{
    
get_user_nameidnamecharsmaxname ) )

    
formatexdatacharsmaxdata ), "%d"g_hat[id])

    
fvault_set_datag_dbnamedata )

It doesnt seem to save things properly, can someone check the plugin and help me? or if anything its wrong and fix it so ill learn
xeloxded is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-05-2017 , 17:06   Re: Help with fvault
Reply With Quote #2

Remove dproto and we'll talk.
__________________
Black Rose is offline
SpawnerF
Member
Join Date: Apr 2017
Location: Morocco
Old 07-09-2017 , 16:30   Re: Help with fvault
Reply With Quote #3

Quote:
Originally Posted by Black Rose View Post
Remove dproto and we'll talk.
Saving with name doesn't proof anything ...
__________________
XX was created just for giving evidence and not meant to damage public servers.
&We do not test on public servers.
Thank's.
SpawnerF is offline
xeloxded
Member
Join Date: Dec 2016
Old 07-05-2017 , 17:09   Re: Help with fvault
Reply With Quote #4

Dproto? xd
xeloxded is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 07-09-2017 , 13:52   Re: Help with fvault
Reply With Quote #5

replace
Code:
Load( id )
{
    new data[ 512 ], name[ 32 ];
    get_user_name( id, name, charsmax( name ) )

    if( fvault_get_data( g_db, name, data, charsmax( data ) ) )
    {
        parse( data, Gorros, charsmax( Gorros ) )

        g_hat[id] = str_to_num( Gorros )
    }
}
Code:
Save( id )
{
    new data[ 512 ], name[ 32 ];	
    get_user_name( id, name, charsmax( name ) )

    formatex( data, charsmax( data ), "%d", g_hat[id])

    fvault_set_data( g_db, name, data )
}
im not sure, you just forget to add data n name[ 32 ];

tell me if it work now?

Last edited by Fuck For Fun; 07-09-2017 at 13:54.
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
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 22:49.


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