AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Zombie Plague Mod (https://forums.alliedmods.net/forumdisplay.php?f=126)
-   -   nvault saving and loading string (https://forums.alliedmods.net/showthread.php?t=157524)

bartek93tbg 05-22-2011 16:14

nvault saving and loading string
 
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

makiza 05-22-2011 19:26

Re: nvault saving and loading string
 
Quote:

Originally Posted by bartek93tbg (Post 1473713)
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.

bartek93tbg 05-23-2011 10:47

Re: nvault saving and loading string
 
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).

jc980 05-23-2011 11:21

Re: nvault saving and loading string
 
have you added nvault_open("vault name")

in plugin_init() ???

bartek93tbg 05-23-2011 11:31

Re: nvault saving and loading string
 
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.

jc980 05-23-2011 11:47

Re: nvault saving and loading string
 
because topxplvl is a num not a string

bartek93tbg 05-23-2011 11:57

Re: nvault saving and loading string
 
???
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 ?


All times are GMT -4. The time now is 21:45.

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