Raised This Month: $ Target: $400
 0% 

Help with saving data.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
danonix
Senior Member
Join Date: Dec 2012
Old 06-04-2013 , 14:29   Help with saving data.
Reply With Quote #1

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)


Last edited by danonix; 06-04-2013 at 14:29.
danonix is offline
 



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 16:14.


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