AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with saving data. (https://forums.alliedmods.net/showthread.php?t=217587)

danonix 06-04-2013 14:29

Help with saving data.
 
Hello,

I have got plugin, but I'd like to add one thing here. After dying or leaving the server knife resets to default one, I don't want this. If someone choose knife it should be saved till he change this. I tried to use vault, but it doesnt work, could you help me? Help would be much appreciated.


Thanks!

PHP Code:

public cbMyMenu(idmenuitem){
    new 
prefix[10];
    static 
stats[8], body[8];
    if(!
is_user_alive(id)){
        
ColorChat(idGREEN"[%s]^x01 Nie mozesz zmienic noza bedac niezywym"prefix);
        return 
PLUGIN_HANDLED
    
}
    
get_user_stats(idstatsbody);
    
get_pcvar_string(g_cPrefixprefixcharsmax(prefix)); 
    
    switch(
item){
        case 
0:{
            
SetKnife(id0)
        }
        case 
1:{
            if(
stats[0] < 150){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |amator|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id1)
        }
        case 
2:{
            if(
stats[0] < 150){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |sredniozaawansowany|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id2)
        }
        case 
3:{
            if(
stats[0] < 150){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |sredniozaawansowany|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id3)
        }
        case 
4:{
            if(
stats[0] < 150){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |sredniozaawansowany|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id4)
        }
        case 
5:{
            if(
stats[0] < 300){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |zaawansowany|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id5)
        }
        case 
6:{
            if(
stats[0] < 500){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |nozownik|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id6)
        }
        case 
7:{
            if(
stats[0] < 500){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |nozownik|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id7)
        }
        case 
8:{
            if(
stats[0] < 700){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |zabojca|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id8)
        }
        case 
9:{
            if(
stats[0] < 700){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |zabojca|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id9)
        }
        case 
10:{
            if(
stats[0] < 900){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |morderca|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id10)
        }
        case 
11:{
            if(
stats[0] < 900){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |morderca|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id11)
        }
        case 
12:{
            if(
stats[0] < 1200){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |platny morderca|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id12)
        }
        case 
13:{
            if(
stats[0] < 1200){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |platny morderca|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id13)
        }
        case 
14:{
            if(
stats[0] < 1500){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |killer|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id14)
        }
        case 
15:{
            if(
stats[0] < 2000){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |mistrz Polski|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id15)
        }
        case 
16:{
            if(
stats[0] < 2000){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |mistrz Polski|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id16)
        }
        case 
17:{
            if(
stats[0] < 2400){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |mistrz Europy|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id17)
        }
        case 
18:{
            if(
stats[0] < 2400){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |mistrz Europy|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id18)
        }
        case 
19:{
            if(
stats[0] < 2500){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |mistrz Swiata|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id19)
        }
        case 
20:{
            if(
stats[0] < 2500){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |mistrz Swiata|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id20)
        }
        case 
21:{
            if(
stats[0] < 2700){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |samurai|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id21)
        }
        case 
22:{
            if(
stats[0] < 2700){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |samurai|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id22)
        }
        case 
23:{
            if(
stats[0] < 3000){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |ninja|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id23)
        }
        case 
24:{
            if(
stats[0] < 3300){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |terminator|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id24)
        }
        case 
25:{
            if(
stats[0] < 3700){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |rambo|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id25)
        }
        case 
26:{
            if(
stats[0] < 4000){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |obcy|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id26)
        }
        case 
27:{
            if(
stats[0] < 5000){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |predator|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id27)
        }
        case 
28:{
            if(
stats[0] < 6000){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |cziter|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id28)
        }
        case 
29:{
            if(
stats[0] < 7000){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |wynalazca noza|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id29)
        }
        case 
30:{
            if(
stats[0] < 10001){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |szatan wcielony|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id30)
        }
        case 
31:{
            if(
stats[0] < 10001){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |szatan wcielony|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id31)
        }
        case 
32:{
            if(
stats[0] < 10001){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |szatan wcielony|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id32)
        }
        case 
33:{
            if(
stats[0] < 10001){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |szatan wcielony|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id33)
        }
        case 
34:{
            if(
stats[0] < 10001){
                
ColorChat(idGREEN"[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |szatan wcielony|."prefix);
                return 
PLUGIN_HANDLED
            
}
            
SetKnife(id34)
        }
    }
    
SaveData(id)
    return 
PLUGIN_HANDLED
}

public 
SetKnife(id Knife) {
    
knife_model[id] = Knife
    
    
new ClipAmmoWeapon get_user_weapon(idClipAmmo
    if ( 
Weapon != CSW_KNIFE )
        return 
PLUGIN_HANDLED
    
    
new vModel[56],pModel[56]
    
    switch(
Knife)
    {
        case 
0: {
            
format(vModel,55,"models/v_knife.mdl")
            
format(pModel,55,"models/p_knife.mdl")
        }
        case 
1: {
            
format(vModel,55,"models/KnifeArena/Backnife/v_knife.mdl")
            
format(pModel,55,"models/KnifeArena/Backnife/p_knife.mdl")
        }
        case 
2: {
            
format(vModel,55,"models/KnifeArena/Translucent/v_knife.mdl")
        }
        case 
3: {
            
format(vModel,55,"models/KnifeArena/jedenpiecknife/v_knife.mdl")
        }
        case 
4: {
            
format(vModel,55,"models/KnifeArena/hoxknife/v_knife.mdl")
        }
        case 
5: {
            
format(vModel,55,"models/KnifeArena/Tattoknife/v_knife.mdl")
        }
        case 
6: {
            
format(vModel,55,"models/KnifeArena/CrysisHand/v_knife.mdl")
        }
        case 
7: {
            
format(vModel,55,"models/KnifeArena/se7en/v_knife.mdl")
        }
        case 
8: {
            
format(vModel,55,"models/KnifeArena/GoldKnife/v_knife.mdl")
        }
        case 
9: {
            
format(vModel,55,"models/KnifeArena/Machete/v_knife.mdl")
        }
        case 
10: {
            
format(vModel,55,"models/KnifeArena/HandKnife/v_knife.mdl")
        }
        case 
11: {
            
format(vModel,55,"models/KnifeArena/Komandos/v_knife.mdl")
        }
        case 
12: {
            
format(vModel,55,"models/KnifeArena/Plazma/v_knife.mdl")
        }
        case 
13: {
            
format(vModel,55,"models/KnifeArena/SpongeKnife/v_knife.mdl")
        }
        case 
14: {
            
format(vModel,55,"models/KnifeArena/Green/v_knife.mdl")
            
format(pModel,55,"models/KnifeArena/Green/p_knife.mdl")
        }
        case 
15: {
            
format(vModel,55,"models/KnifeArena/Yellow/v_knife.mdl")
            
format(pModel,55,"models/KnifeArena/Yellow/p_knife.mdl")
        }
        case 
16: {
            
format(vModel,55,"models/KnifeArena/Hak/v_knife.mdl")
        }
        case 
17: {
            
format(vModel,55,"models/KnifeArena/Kibol/v_knife.mdl")
        }
        case 
18: {
            
format(vModel,55,"models/KnifeArena/Kyhan/v_knife.mdl")
        }
        case 
19: {
            
format(vModel,55,"models/KnifeArena/Szabla/v_knife.mdl")
        }
        case 
20: {
            
format(vModel,55,"models/KnifeArena/Most/v_knife.mdl")
        }
        case 
21: {
            
format(vModel,55,"models/KnifeArena/Dragon/v_knife.mdl")
        }
        case 
22:{
            
format(vModel,55,"models/KnifeArena/BloodKnife/v_knife.mdl")
            
format(pModel,55,"models/KnifeArena/BloodKnife/p_knife.mdl")
        }
        case 
23: {
            
format(vModel,55,"models/KnifeArena/Ninja/v_knife.mdl")
        }
        case 
24:{
            
format(vModel,55,"models/KnifeArena/Darth/v_knife.mdl")
            
format(pModel,55,"models/KnifeArena/Darth/p_knife.mdl")
        }
        case 
25:{
            
format(vModel,55,"models/KnifeArena/Kombat/v_knife.mdl")
        }
        case 
26: {
            
format(vModel,55,"models/KnifeArena/Pila/v_knife.mdl")
        }
        case 
27:{
            
format(vModel,55,"models/KnifeArena/Predator/v_knife.mdl")
        }
        case 
28: {
            
format(vModel,55,"models/KnifeArena/Hax/v_knife.mdl")
        }
        case 
29:{
            
format(vModel,55,"models/KnifeArena/Sablya/v_knife.mdl")
        }
        case 
30: {
            
format(vModel,55,"models/KnifeArena/Meat/v_knife.mdl")
        }
        case 
31:{
            
format(vModel,55,"models/KnifeArena/Simple/v_knife.mdl")
        }
        case 
32: {
            
format(vModel,55,"models/KnifeArena/Hitman/v_knife.mdl")
        }
        case 
33:{
            
format(vModel,55,"models/KnifeArena/Shoe/v_knife.mdl")
        }
        case 
34: {
            
format(vModel,55,"models/KnifeArena/Snajper/v_knife.mdl")
        }
        
    } 
    
    
entity_set_string(idEV_SZ_viewmodelvModel)
    
entity_set_string(idEV_SZ_weaponmodelpModel)
    
    return 
PLUGIN_HANDLED;  
}

public 
client_authorized(id)
{
    
LoadData(id)
}

SaveData(id){ 
    new 
authid[32]
    
get_user_authid(idauthid31)
    
    new 
vaultkey[64]
    new 
vaultdata[64]
    
    
format(vaultkey63"KMOD_%s"authid)
    
format(vaultdata63"%d"knife_model[id])
    
set_vaultdata(vaultkeyvaultdata)
}
LoadData(id){ 
    new 
authid[32
    
get_user_authid(id,authid,31)
    
    new 
vaultkey[64], vaultdata[64]
    
    
format(vaultkey63"KMOD_%s"authid)
    
get_vaultdata(vaultkeyvaultdata63)
    
knife_model[id] = str_to_num(vaultdata)



TheDS1337 06-04-2013 15:12

Re: Help with saving data.
 
Done :D
Code:
public cbMyMenu(id, menu, item){     new prefix[10];     static stats[8], body[8];     if(!is_user_alive(id)){         ColorChat(id, GREEN, "[%s]^x01 Nie mozesz zmienic noza bedac niezywym", prefix);         return PLUGIN_HANDLED     }     get_user_stats(id, stats, body);     get_pcvar_string(g_cPrefix, prefix, charsmax(prefix));         switch(item){         case 0:{             SetKnife(id, 0)         }         case 1:{             if(stats[0] < 150){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |amator|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 1)         }         case 2:{             if(stats[0] < 150){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |sredniozaawansowany|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 2)         }         case 3:{             if(stats[0] < 150){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |sredniozaawansowany|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 3)         }         case 4:{             if(stats[0] < 150){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |sredniozaawansowany|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 4)         }         case 5:{             if(stats[0] < 300){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |zaawansowany|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 5)         }         case 6:{             if(stats[0] < 500){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |nozownik|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 6)         }         case 7:{             if(stats[0] < 500){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |nozownik|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 7)         }         case 8:{             if(stats[0] < 700){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |zabojca|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 8)         }         case 9:{             if(stats[0] < 700){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |zabojca|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 9)         }         case 10:{             if(stats[0] < 900){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |morderca|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 10)         }         case 11:{             if(stats[0] < 900){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |morderca|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 11)         }         case 12:{             if(stats[0] < 1200){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |platny morderca|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 12)         }         case 13:{             if(stats[0] < 1200){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |platny morderca|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 13)         }         case 14:{             if(stats[0] < 1500){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |killer|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 14)         }         case 15:{             if(stats[0] < 2000){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |mistrz Polski|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 15)         }         case 16:{             if(stats[0] < 2000){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |mistrz Polski|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 16)         }         case 17:{             if(stats[0] < 2400){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |mistrz Europy|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 17)         }         case 18:{             if(stats[0] < 2400){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |mistrz Europy|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 18)         }         case 19:{             if(stats[0] < 2500){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |mistrz Swiata|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 19)         }         case 20:{             if(stats[0] < 2500){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |mistrz Swiata|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 20)         }         case 21:{             if(stats[0] < 2700){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |samurai|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 21)         }         case 22:{             if(stats[0] < 2700){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |samurai|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 22)         }         case 23:{             if(stats[0] < 3000){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |ninja|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 23)         }         case 24:{             if(stats[0] < 3300){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |terminator|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 24)         }         case 25:{             if(stats[0] < 3700){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |rambo|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 25)         }         case 26:{             if(stats[0] < 4000){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |obcy|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 26)         }         case 27:{             if(stats[0] < 5000){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |predator|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 27)         }         case 28:{             if(stats[0] < 6000){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |cziter|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 28)         }         case 29:{             if(stats[0] < 7000){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |wynalazca noza|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 29)         }         case 30:{             if(stats[0] < 10001){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |szatan wcielony|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 30)         }         case 31:{             if(stats[0] < 10001){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |szatan wcielony|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 31)         }         case 32:{             if(stats[0] < 10001){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |szatan wcielony|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 32)         }         case 33:{             if(stats[0] < 10001){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |szatan wcielony|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 33)         }         case 34:{             if(stats[0] < 10001){                 ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |szatan wcielony|.", prefix);                 return PLUGIN_HANDLED             }             SetKnife(id, 34)         }     }         return PLUGIN_HANDLED } public SetKnife(id , Knife) {     knife_model[id] = Knife         new Clip, Ammo, Weapon = get_user_weapon(id, Clip, Ammo)     if ( Weapon != CSW_KNIFE )         return PLUGIN_HANDLED         new vModel[56],pModel[56]         switch(Knife)     {         case 0: {             format(vModel,55,"models/v_knife.mdl")             format(pModel,55,"models/p_knife.mdl")         }         case 1: {             format(vModel,55,"models/KnifeArena/Backnife/v_knife.mdl")             format(pModel,55,"models/KnifeArena/Backnife/p_knife.mdl")         }         case 2: {             format(vModel,55,"models/KnifeArena/Translucent/v_knife.mdl")         }         case 3: {             format(vModel,55,"models/KnifeArena/jedenpiecknife/v_knife.mdl")         }         case 4: {             format(vModel,55,"models/KnifeArena/hoxknife/v_knife.mdl")         }         case 5: {             format(vModel,55,"models/KnifeArena/Tattoknife/v_knife.mdl")         }         case 6: {             format(vModel,55,"models/KnifeArena/CrysisHand/v_knife.mdl")         }         case 7: {             format(vModel,55,"models/KnifeArena/se7en/v_knife.mdl")         }         case 8: {             format(vModel,55,"models/KnifeArena/GoldKnife/v_knife.mdl")         }         case 9: {             format(vModel,55,"models/KnifeArena/Machete/v_knife.mdl")         }         case 10: {             format(vModel,55,"models/KnifeArena/HandKnife/v_knife.mdl")         }         case 11: {             format(vModel,55,"models/KnifeArena/Komandos/v_knife.mdl")         }         case 12: {             format(vModel,55,"models/KnifeArena/Plazma/v_knife.mdl")         }         case 13: {             format(vModel,55,"models/KnifeArena/SpongeKnife/v_knife.mdl")         }         case 14: {             format(vModel,55,"models/KnifeArena/Green/v_knife.mdl")             format(pModel,55,"models/KnifeArena/Green/p_knife.mdl")         }         case 15: {             format(vModel,55,"models/KnifeArena/Yellow/v_knife.mdl")             format(pModel,55,"models/KnifeArena/Yellow/p_knife.mdl")         }         case 16: {             format(vModel,55,"models/KnifeArena/Hak/v_knife.mdl")         }         case 17: {             format(vModel,55,"models/KnifeArena/Kibol/v_knife.mdl")         }         case 18: {             format(vModel,55,"models/KnifeArena/Kyhan/v_knife.mdl")         }         case 19: {             format(vModel,55,"models/KnifeArena/Szabla/v_knife.mdl")         }         case 20: {             format(vModel,55,"models/KnifeArena/Most/v_knife.mdl")         }         case 21: {             format(vModel,55,"models/KnifeArena/Dragon/v_knife.mdl")         }         case 22:{             format(vModel,55,"models/KnifeArena/BloodKnife/v_knife.mdl")             format(pModel,55,"models/KnifeArena/BloodKnife/p_knife.mdl")         }         case 23: {             format(vModel,55,"models/KnifeArena/Ninja/v_knife.mdl")         }         case 24:{             format(vModel,55,"models/KnifeArena/Darth/v_knife.mdl")             format(pModel,55,"models/KnifeArena/Darth/p_knife.mdl")         }         case 25:{             format(vModel,55,"models/KnifeArena/Kombat/v_knife.mdl")         }         case 26: {             format(vModel,55,"models/KnifeArena/Pila/v_knife.mdl")         }         case 27:{             format(vModel,55,"models/KnifeArena/Predator/v_knife.mdl")         }         case 28: {             format(vModel,55,"models/KnifeArena/Hax/v_knife.mdl")         }         case 29:{             format(vModel,55,"models/KnifeArena/Sablya/v_knife.mdl")         }         case 30: {             format(vModel,55,"models/KnifeArena/Meat/v_knife.mdl")         }         case 31:{             format(vModel,55,"models/KnifeArena/Simple/v_knife.mdl")         }         case 32: {             format(vModel,55,"models/KnifeArena/Hitman/v_knife.mdl")         }         case 33:{             format(vModel,55,"models/KnifeArena/Shoe/v_knife.mdl")         }         case 34: {             format(vModel,55,"models/KnifeArena/Snajper/v_knife.mdl")         }             }         entity_set_string(id, EV_SZ_viewmodel, vModel)     entity_set_string(id, EV_SZ_weaponmodel, pModel)         return PLUGIN_HANDLED;   } public client_authorized(id) {     LoadData(id) } public client_disconnect(id) {     SaveData(id) } SaveData(id){     new authid[32]     get_user_authid(id, authid, 31)         new vaultkey[64]     new vaultdata[64]         format(vaultkey, 63, "KMOD_%s", authid)     format(vaultdata, 63, "%d", knife_model[id])     set_vaultdata(vaultkey, vaultdata) } LoadData(id){     new authid[32]     get_user_authid(id,authid,31)         new vaultkey[64], vaultdata[64]         format(vaultkey, 63, "KMOD_%s", authid)     get_vaultdata(vaultkey, vaultdata, 63)     knife_model[id] = str_to_num(vaultdata) }

danonix 06-04-2013 15:34

Re: Help with saving data.
 
But it doesn't save after choosing a model, does it? And this code was writing a file in data folder, but it wasnt reading the model when someone was connecting to server. It was always default one

TheDS1337 06-04-2013 15:37

Re: Help with saving data.
 
umm, try change client_authorized to client_putinserver :)
and you don't need to save models in knife menu, only when client disconnect :)
EDIT: here, i changed some thing ;) try it :D
Code:

public cbMyMenu(id, menu, item){
    new prefix[10];
    static stats[8], body[8];
    if(!is_user_alive(id)){
        ColorChat(id, GREEN, "[%s]^x01 Nie mozesz zmienic noza bedac niezywym", prefix);
        return PLUGIN_HANDLED
    }
    get_user_stats(id, stats, body);
    get_pcvar_string(g_cPrefix, prefix, charsmax(prefix));
   
    switch(item){
        case 0:{
            SetKnife(id, 0)
        }
        case 1:{
            if(stats[0] < 150){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |amator|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 1)
        }
        case 2:{
            if(stats[0] < 150){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |sredniozaawansowany|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 2)
        }
        case 3:{
            if(stats[0] < 150){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |sredniozaawansowany|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 3)
        }
        case 4:{
            if(stats[0] < 150){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |sredniozaawansowany|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 4)
        }
        case 5:{
            if(stats[0] < 300){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |zaawansowany|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 5)
        }
        case 6:{
            if(stats[0] < 500){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |nozownik|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 6)
        }
        case 7:{
            if(stats[0] < 500){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |nozownik|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 7)
        }
        case 8:{
            if(stats[0] < 700){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |zabojca|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 8)
        }
        case 9:{
            if(stats[0] < 700){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |zabojca|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 9)
        }
        case 10:{
            if(stats[0] < 900){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |morderca|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 10)
        }
        case 11:{
            if(stats[0] < 900){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |morderca|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 11)
        }
        case 12:{
            if(stats[0] < 1200){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |platny morderca|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 12)
        }
        case 13:{
            if(stats[0] < 1200){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |platny morderca|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 13)
        }
        case 14:{
            if(stats[0] < 1500){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |killer|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 14)
        }
        case 15:{
            if(stats[0] < 2000){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |mistrz Polski|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 15)
        }
        case 16:{
            if(stats[0] < 2000){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |mistrz Polski|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 16)
        }
        case 17:{
            if(stats[0] < 2400){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |mistrz Europy|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 17)
        }
        case 18:{
            if(stats[0] < 2400){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |mistrz Europy|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 18)
        }
        case 19:{
            if(stats[0] < 2500){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |mistrz Swiata|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 19)
        }
        case 20:{
            if(stats[0] < 2500){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |mistrz Swiata|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 20)
        }
        case 21:{
            if(stats[0] < 2700){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |samurai|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 21)
        }
        case 22:{
            if(stats[0] < 2700){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |samurai|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 22)
        }
        case 23:{
            if(stats[0] < 3000){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |ninja|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 23)
        }
        case 24:{
            if(stats[0] < 3300){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |terminator|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 24)
        }
        case 25:{
            if(stats[0] < 3700){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |rambo|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 25)
        }
        case 26:{
            if(stats[0] < 4000){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |obcy|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 26)
        }
        case 27:{
            if(stats[0] < 5000){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |predator|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 27)
        }
        case 28:{
            if(stats[0] < 6000){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |cziter|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 28)
        }
        case 29:{
            if(stats[0] < 7000){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |wynalazca noza|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 29)
        }
        case 30:{
            if(stats[0] < 10001){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |szatan wcielony|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 30)
        }
        case 31:{
            if(stats[0] < 10001){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |szatan wcielony|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 31)
        }
        case 32:{
            if(stats[0] < 10001){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |szatan wcielony|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 32)
        }
        case 33:{
            if(stats[0] < 10001){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |szatan wcielony|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 33)
        }
        case 34:{
            if(stats[0] < 10001){
                ColorChat(id, GREEN, "[%s]^x01 By uzywac tego noza wymagana jest ranga^x03 |szatan wcielony|.", prefix);
                return PLUGIN_HANDLED
            }
            SetKnife(id, 34)
        }
    }   
    return PLUGIN_HANDLED
}

public SetKnife(id , Knife) {
    knife_model[id] = Knife
   
    new Clip, Ammo, Weapon = get_user_weapon(id, Clip, Ammo)
    if ( Weapon != CSW_KNIFE )
        return PLUGIN_HANDLED
   
    new vModel[56],pModel[56]
   
    switch(Knife)
    {
        case 0: {
            format(vModel,55,"models/v_knife.mdl")
            format(pModel,55,"models/p_knife.mdl")
        }
        case 1: {
            format(vModel,55,"models/KnifeArena/Backnife/v_knife.mdl")
            format(pModel,55,"models/KnifeArena/Backnife/p_knife.mdl")
        }
        case 2: {
            format(vModel,55,"models/KnifeArena/Translucent/v_knife.mdl")
        }
        case 3: {
            format(vModel,55,"models/KnifeArena/jedenpiecknife/v_knife.mdl")
        }
        case 4: {
            format(vModel,55,"models/KnifeArena/hoxknife/v_knife.mdl")
        }
        case 5: {
            format(vModel,55,"models/KnifeArena/Tattoknife/v_knife.mdl")
        }
        case 6: {
            format(vModel,55,"models/KnifeArena/CrysisHand/v_knife.mdl")
        }
        case 7: {
            format(vModel,55,"models/KnifeArena/se7en/v_knife.mdl")
        }
        case 8: {
            format(vModel,55,"models/KnifeArena/GoldKnife/v_knife.mdl")
        }
        case 9: {
            format(vModel,55,"models/KnifeArena/Machete/v_knife.mdl")
        }
        case 10: {
            format(vModel,55,"models/KnifeArena/HandKnife/v_knife.mdl")
        }
        case 11: {
            format(vModel,55,"models/KnifeArena/Komandos/v_knife.mdl")
        }
        case 12: {
            format(vModel,55,"models/KnifeArena/Plazma/v_knife.mdl")
        }
        case 13: {
            format(vModel,55,"models/KnifeArena/SpongeKnife/v_knife.mdl")
        }
        case 14: {
            format(vModel,55,"models/KnifeArena/Green/v_knife.mdl")
            format(pModel,55,"models/KnifeArena/Green/p_knife.mdl")
        }
        case 15: {
            format(vModel,55,"models/KnifeArena/Yellow/v_knife.mdl")
            format(pModel,55,"models/KnifeArena/Yellow/p_knife.mdl")
        }
        case 16: {
            format(vModel,55,"models/KnifeArena/Hak/v_knife.mdl")
        }
        case 17: {
            format(vModel,55,"models/KnifeArena/Kibol/v_knife.mdl")
        }
        case 18: {
            format(vModel,55,"models/KnifeArena/Kyhan/v_knife.mdl")
        }
        case 19: {
            format(vModel,55,"models/KnifeArena/Szabla/v_knife.mdl")
        }
        case 20: {
            format(vModel,55,"models/KnifeArena/Most/v_knife.mdl")
        }
        case 21: {
            format(vModel,55,"models/KnifeArena/Dragon/v_knife.mdl")
        }
        case 22:{
            format(vModel,55,"models/KnifeArena/BloodKnife/v_knife.mdl")
            format(pModel,55,"models/KnifeArena/BloodKnife/p_knife.mdl")
        }
        case 23: {
            format(vModel,55,"models/KnifeArena/Ninja/v_knife.mdl")
        }
        case 24:{
            format(vModel,55,"models/KnifeArena/Darth/v_knife.mdl")
            format(pModel,55,"models/KnifeArena/Darth/p_knife.mdl")
        }
        case 25:{
            format(vModel,55,"models/KnifeArena/Kombat/v_knife.mdl")
        }
        case 26: {
            format(vModel,55,"models/KnifeArena/Pila/v_knife.mdl")
        }
        case 27:{
            format(vModel,55,"models/KnifeArena/Predator/v_knife.mdl")
        }
        case 28: {
            format(vModel,55,"models/KnifeArena/Hax/v_knife.mdl")
        }
        case 29:{
            format(vModel,55,"models/KnifeArena/Sablya/v_knife.mdl")
        }
        case 30: {
            format(vModel,55,"models/KnifeArena/Meat/v_knife.mdl")
        }
        case 31:{
            format(vModel,55,"models/KnifeArena/Simple/v_knife.mdl")
        }
        case 32: {
            format(vModel,55,"models/KnifeArena/Hitman/v_knife.mdl")
        }
        case 33:{
            format(vModel,55,"models/KnifeArena/Shoe/v_knife.mdl")
        }
        case 34: {
            format(vModel,55,"models/KnifeArena/Snajper/v_knife.mdl")
        }
       
    }
   
    entity_set_string(id, EV_SZ_viewmodel, vModel)
    entity_set_string(id, EV_SZ_weaponmodel, pModel)
   
    return PLUGIN_HANDLED; 
}

public client_putinserver(id)
{
    LoadData(id)
}

public client_disconnect(id)
{
    SaveData(id)
}

SaveData(id){
    new authid[32]
    get_user_authid(id, authid, 31)
   
    new vaultkey[64]
    new vaultdata[64]
   
    format(vaultkey, 63, "KMOD_%s", authid)
    format(vaultdata, 63, "%d", knife_model[id])
    set_vaultdata(vaultkey, vaultdata)
}
LoadData(id){
    new authid[32]
    get_user_authid(id,authid,31)
   
    new vaultkey[64], vaultdata[64], knife[64]
   
    format(vaultkey, 63, "KMOD_%s", authid)
        format(vaultdata, 63, "%d", knife_model[id])
        if(get_vaultdata(vaultkey, vaultdata, 63))
        {
                parse(vaultdata, knife, 63)
                knife_model[id] = str_to_num(vaultdata)
        }
}


Blizzard_87 06-04-2013 18:08

Re: Help with saving data.
 
do you have SetKnife function set in CurWeapon event. that way everytime you change weapons then back to knife it will auto check the knife model you have and load it again.... so it always loads.

danonix 06-05-2013 01:23

Re: Help with saving data.
 
@Deagle.Studio, ok, Ill test it today and tell you if it works or not, thanks for help at all
@Blizzard_87, no I don't have it in curweapon event.

TheDS1337 06-05-2013 03:21

Re: Help with saving data.
 
Quote:

Originally Posted by Blizzard_87 (Post 1964726)
do you have SetKnife function set in CurWeapon event. that way everytime you change weapons then back to knife it will auto check the knife model you have and load it again.... so it always loads.

He have no problem with models, the problem is the vault ...

danonix 06-05-2013 09:17

Re: Help with saving data.
 
Deagle, unfortunately still if someone choose knife and die/leave from the server it doesn't change the model to choosen one

Clauu 06-05-2013 09:30

Re: Help with saving data.
 
Save every time when player choose his knife and then with ham spawn give him what is in vault.

danonix 06-05-2013 09:44

Re: Help with saving data.
 
I can't do that, I don't know how to use vault, thats why I'm asking for help there, if I could do it by myself.... :p


All times are GMT -4. The time now is 16:14.

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