Raised This Month: $ Target: $400
 0% 

[Key Values] Overwriting the wrong ones?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Marcus101RR
Veteran Member
Join Date: Aug 2009
Location: Tampa, FL
Old 03-08-2015 , 17:23   [Key Values] Overwriting the wrong ones?
Reply With Quote #1

I am unable to determine how a string becomes an integer, as you can see "2147483647" and "0". When the last entry was done correctly, why are the others done incorrectly?

NOTE: I determined that when it saves a person's data, it overwrites all others. Even though their STEAMID, or BOT ID doesn't match. What is going on in this code that is causing this?

Code:
"SaveFile"
{
	"BOT_Francis"
	{
		"Upgrades"		"0"
		"Disabled"		"0"
		"PerkBonusSlots"		"0"
	}
	"BOT_Zoey"
	{
		"Upgrades"		"2147483647"
		"Disabled"		"0"
		"PerkBonusSlots"		"0"
	}
	"BOT_Louis"
	{
		"Upgrades"		"0"
		"Disabled"		"0"
		"PerkBonusSlots"		"0"
	}
	"BOT_(1)Francis"
	{
		"Upgrades"		"2147483647"
		"Disabled"		"0"
		"PerkBonusSlots"		"0"
	}
	"BOT_Bill"
	{
		"Upgrades"		"2147483647"
		"Disabled"		"0"
		"PerkBonusSlots"		"0"
	}
	"BOT_(1)Louis"
	{
		"Upgrades"		"0"
		"Disabled"		"0"
		"PerkBonusSlots"		"0"
	}
	"STEAM_1:0:26901013"
	{
		"Upgrades"		"00010000000001000000000100000010"
		"Disabled"		"00000000000000000000000000000000"
		"PerkBonusSlots"		"0"
	}
}
Source:
PHP Code:
/* Save To File */
ClientSaveToFileSave(targetid)
{
    
decl Handle:kv;
    
decl String:cName[MAX_NAME_LENGTH];
    
decl String:cUsername[MAX_TARGET_LENGTH];
    
kv CreateKeyValues("SurvivorUpgradesReloaded");
    
FileToKeyValues(kvSavePath);

    
GetClientAuthString(targetidcNamesizeof(cName));
    
GetClientName(targetidcUsernamesizeof(cUsername));    
    if(
IsFakeClient(targetid) && StrContains(cUsername"SurvivorBot"false) == -1)
    {
        
Format(cNamesizeof(cName), "%s_%s"cNamecUsername);
    }
    
KvJumpToKey(kvcNametrue);

    
decl String:buffer[256] = ""String:buffer2[256] = "";
    
    for(new 
0MAX_UPGRADESi++)
    {
        if(
== 0)
        {
            if(
iUpgrade[targetid][i] > 0)
                
Format(buffersizeof(buffer), "1");
            else
                
Format(buffersizeof(buffer), "0");

            if(
iUpgradeDisabled[targetid][i] > 0)
                
Format(buffer2sizeof(buffer2), "1");
            else
                
Format(buffer2sizeof(buffer2), "0");
        }
        else
        {
            if(
iUpgrade[targetid][i] > 0)
                
Format(buffersizeof(buffer), "%s1"buffer);
            else
                
Format(buffersizeof(buffer), "%s0"buffer);

            if(
iUpgradeDisabled[targetid][i] > 0)
                
Format(buffer2sizeof(buffer2), "%s1"buffer2);
            else
                
Format(buffer2sizeof(buffer2), "%s0"buffer2);
        }
    }
    
KvSetString(kv"Upgrades"buffer);
    
KvSetString(kv"Disabled"buffer2);
    
KvSetNum(kv"PerkBonusSlots"iPerkBonusSlots[targetid]);

    
KvRewind(kv);
    
KeyValuesToFile(kvSavePath);
    
CloseHandle(kv);
}

/* Load Save From File */
ClientSaveToFileLoad(targetid)
{
    
decl Handle:kv;
    
decl String:cName[MAX_NAME_LENGTH];
    
decl String:cUsername[MAX_TARGET_LENGTH];
    
kv CreateKeyValues("SurvivorUpgradesReloaded");
    
FileToKeyValues(kvSavePath);

    
GetClientAuthString(targetidcNamesizeof(cName));
    
GetClientName(targetidcUsernamesizeof(cUsername));
    
    if(
IsFakeClient(targetid) && StrContains(cUsername"SurvivorBot"false) == -1)
    {
        
Format(cNamesizeof(cName), "%s_%s"cNamecUsername);
    }
    if(!
KvJumpToKey(kvcName))
    {
        return;
    }
    
KvJumpToKey(kvcNametrue);
    
    
iBitsUpgrades[targetid] = 0;
    
    
decl String:buffer[256];
    
decl String:buffer2[256];
    
    
KvGetString(kv"Upgrades"buffersizeof(buffer));
    
KvGetString(kv"Disabled"buffer2sizeof(buffer2));
    
    new 
len strlen(buffer);
    for (new 
0<= leni++)
    {
        if(
buffer[i] == '1')
        {
            
iUpgrade[targetid][i] = UpgradeIndex[i];
        }
    }

    
len strlen(buffer2);
    for (new 
0<= leni++)
    {
        if(
buffer2[i] == '1')
        {
            
iUpgradeDisabled[targetid][i] = 1;
        }
    }
    
iPerkBonusSlots[targetid] = KvGetNum(kv"PerkBonusSlots"0);
    
CloseHandle(kv);

__________________

Last edited by Marcus101RR; 03-08-2015 at 17:34.
Marcus101RR is offline
Send a message via AIM to Marcus101RR Send a message via Skype™ to Marcus101RR
Reply



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 20:43.


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