Raised This Month: $12 Target: $400
 3% 

nvault saving and loading string


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bartek93tbg
Member
Join Date: Apr 2011
Location: Poland
Old 05-22-2011 , 16:14   nvault saving and loading string
Reply With Quote #1

Hi. I have problem, how add to this 3rd variable (string)?

Code:
[...]
new topexp;
new topexpname[35];
//new topexplvl[35]; //I want add this
[...]

public top_stats_save()
{
    new vaultkey[64],vaultdata[256];

        format(vaultkey,63,"zp_topexp");
        format(vaultdata,255,"%i#%s#",topexp,topexpname);

        nvault_set(zp_top,vaultkey,vaultdata);
}

public top_stats_load()
{
    new vaultkey[64],vaultdata[256];

        format(vaultkey,63,"zp_topexp");
        format(vaultdata,255,"%i#%s#",topexp,topexpname) ;

        nvault_get(zp_top,vaultkey,vaultdata,255);
    replace_all(vaultdata, 255, "#", " ");

    new jeden[100];
    new str_rank[32];
    parse(vaultdata, str_rank, charsmax(str_rank), topexpname, charsmax(topexpname));
    

     parse(vaultdata, jeden, 99);
    topexp = str_to_num(jeden);
}
I have tried (2 hours or more) but it doesn't work because I dont' know how to load int, string and string from nvault.
Can you modify this for me? I need this.

THANKS
bartek93tbg is offline
makiza
BANNED
Join Date: Mar 2009
Old 05-22-2011 , 19:26   Re: nvault saving and loading string
Reply With Quote #2

Quote:
Originally Posted by bartek93tbg View Post
Hi. I have problem, how add to this 3rd variable (string)?
PHP Code:
[...]
new 
topexp;
new 
topexpname[35];
//new topexplvl[35]; //I want add this
[...]

public 
top_stats_save()
{
    new 
vaultkey[64],vaultdata[256]; vaultxp[64//add

        
format(vaultkey,63,"zp_topexp");
        
format(vaultdata,255,"%i#%s#"/*i dunno what goes there, %s?*/,topexp,topexpname,topexplvl);//add
        
nvault_set(zp_top,vaultkey,vaultdata,vaultxp);//add

Add the same thing.
makiza is offline
bartek93tbg
Member
Join Date: Apr 2011
Location: Poland
Old 05-23-2011 , 10:47   Re: nvault saving and loading string
Reply With Quote #3

Please can you modify code from my 1st post?
I tried and now everything don't work.

I don't understand your tips ;/

When I add this:
Code:
nvault_set(zp_top,vaultkey,vaultdata,vaultxp);//add

I can't compile:
"Numer of arguments doesn't match to the definition" ;/;/

Even If i could add this I wouldn't know how to load this string ;/


I used "%s" because this is string and it worked XD for 2 variables (int and string from 1st post).

Last edited by bartek93tbg; 05-23-2011 at 10:51.
bartek93tbg is offline
jc980
Veteran Member
Join Date: Jan 2010
Location: God is with us...
Old 05-23-2011 , 11:21   Re: nvault saving and loading string
Reply With Quote #4

have you added nvault_open("vault name")

in plugin_init() ???
__________________
jc980 is offline
bartek93tbg
Member
Join Date: Apr 2011
Location: Poland
Old 05-23-2011 , 11:31   Re: nvault saving and loading string
Reply With Quote #5

Yes of course...
Code:
[...]
new zp_top;
[...]
new topexp;
new topexpname[35];
//new topexplvl[35]; I WANT ADD THIS (TITLE OF LVL)
[...]
public plugin_init()
{
    zp_top = nvault_open("best")
}
[...]
public plugin_end(){
    nvault_close(zp_top);
}
[...]
//this is how i save new best player
    if(player_xp[id] > topexp)
    {

    topexp = player_xp[id];
    get_user_name(id, topexpname ,34)
    //topexplvl = ranga[level[id]] // this is title which i want add

    top_stats_save();
    }
[...]

public top_stats_save()
{
    new vaultkey[64],vaultdata[256];

    format(vaultkey,63,"zp_topexp");
    format(vaultdata,255,"%i#%s#",topexp,topexpname);

    nvault_set(zp_top,vaultkey,vaultdata);
}

public top_stats_load()
{
    new vaultkey[64],vaultdata[256];

    format(vaultkey,63,"zp_topexp");
    format(vaultdata,255,"%i#%s#",topexp,topexpname) ;

    nvault_get(zp_top,vaultkey,vaultdata,255);
    replace_all(vaultdata, 255, "#", " ");

    new jeden[100];
    new str_rank[32];
    parse(vaultdata, str_rank, charsmax(str_rank), topexpname, charsmax(topexpname));
    

    parse(vaultdata, jeden, 99);
    topexp = str_to_num(jeden);
}

[...]
It's working ok, but if i add 3rd variable it doesn't work ;/
This is how i show top stats:
Code:
    formatex(tempstring,charsmax(tempstring),"<b><font color=#F21533></br>%s | exp: %i</b></font><br /><br />", topexpname, topexp);
Help, I know that here is someone who can do it, I don't have more ideas ;/

EDIT: BAD CODE, LOOK NOW

Also with this:
Code:
public top_stats_save()
{
    new vaultkey[64],vaultdata[256];

        format(vaultkey,63,"zp_topexp");
        format(vaultdata,255,"%i#%s#%s#",topexp,topexpname,topexplvl);

        nvault_set(top,vaultkey,vaultdata);
}

public top_stats_load()
{
    new vaultkey[64],vaultdata[256];

        format(vaultkey,63,"zp_topexp");
        format(vaultdata,255,"%i#%s#%s#",topexp,topexpname,topexplvl) ;

        nvault_get(top,vaultkey,vaultdata,255);
    replace_all(vaultdata, 255, "#", " ");

    new jeden[100], str_rank[35], str_lvl[35];
    parse(vaultdata, str_rank, charsmax(str_rank), topexpname, charsmax(topexpname));
    parse(vaultdata, str_lvl, charsmax(str_lvl), topexplvl, charsmax(topexplvl));
    

    parse(vaultdata, jeden, 99);
    topexp = str_to_num(jeden);
}
It shows stats properly only If the best player is online... After mapchange instead of title it shows name.. Like this:

%s %s %i (topexplvl, topexpname, topexp)

topexpname, topexpname, topexp
Topexp and topexpname are working good.

Last edited by bartek93tbg; 05-23-2011 at 11:42.
bartek93tbg is offline
jc980
Veteran Member
Join Date: Jan 2010
Location: God is with us...
Old 05-23-2011 , 11:47   Re: nvault saving and loading string
Reply With Quote #6

because topxplvl is a num not a string
__________________
jc980 is offline
bartek93tbg
Member
Join Date: Apr 2011
Location: Poland
Old 05-23-2011 , 11:57   Re: nvault saving and loading string
Reply With Quote #7

???
By topexplvl I mean title like "Destroyer" so I think this is string. Look:

Code:
new ranga[][35]=
{
       "Title 1",
       "Title 2",
       [...]
       "Title 40"
}

topexplvl = ranga[level[id]] // for example if player has 2 lvl it will show "Title 2"
If I am wrong can you change my code to make it working ?
bartek93tbg 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 02:41.


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