View Single Post
gubka
Veteran Member
Join Date: Jan 2012
Location: Russia
Old 10-05-2015 , 17:09   Re: [CS:GO] Zombie Plague Mod 3 (4.10.2015)
Reply With Quote #25

Quote:
Originally Posted by Lannister View Post
Very excited about this, keep up the good work!
I am fineshed saving ammo pack, when i will fineshed lvl and buysystem , i will update link here, wait during week

Code:
//**********************************************
//* DataBase Staff.                 		   *
//**********************************************

void Create_DataBase()
{
	if (DataBase != INVALID_HANDLE)
		CloseHandle(DataBase);

	Format(DataBaseFile, PLATFORM_MAX_PATH, "addons/sourcemod/%s", KV_DATABASE_NAME);
	
	if(!FileExists(DataBaseFile))
	{
		char DataBasePath[PLATFORM_MAX_PATH];
		BuildPath(Path_SM, DataBasePath, sizeof(DataBasePath), KV_DATABASE_NAME);
	
		DataBase = CreateKeyValues(KV_DATABASE_KEY);
		KeyValuesToFile(DataBase, DataBasePath);
		
		PrintToServer("[ZBM3_DATABASE] Database was created!");
	}
	else 
	{
		DataBase = CreateKeyValues(KV_DATABASE_KEY);
		FileToKeyValues(DataBase, DataBaseFile);
		
		PrintToServer("[ZBM3_DATABASE] Database was upload from server folder!");
	}
}

public int Check_DataBase(int iPlayer)
{
	Format(DataBaseFile, PLATFORM_MAX_PATH, "addons/sourcemod/%s", KV_DATABASE_NAME);

	if(!FileExists(DataBaseFile))
	{
		PrintToServer("[ZBM3_DATABASE] ERROR: file not exist");
		return 0;
	}
    else if (KvJumpToKey(DataBase, pSteamID[iPlayer], false)) 
    { 
		int pAmmoCount; 
		pAmmoCount = KvGetNum(DataBase, KV_DATABASE_STRING); 

		KvDeleteThis(DataBase); 
		KvRewind(DataBase); 
		KeyValuesToFile(DataBase, DataBaseFile);
	   
		PrintToServer("[ZBM3_DATABASE] Ammo was loaded for: %s, Found: %i ammopacks", pSteamID[iPlayer], pAmmoCount);
	   
		return pAmmoCount;
    } 
    else 
	{
		PrintToServer("[ZBM3_DATABASE] Ammo for New Player will create after disconnect: %s", pSteamID[iPlayer]);
		
		return AMMOPACK_FOR_NEW_PLAYER;
	}
}

void Save_DataBase(int iPlayer, int iPlayer_Ammo)
{
	Format(DataBaseFile, PLATFORM_MAX_PATH, "addons/sourcemod/%s", KV_DATABASE_NAME);

	if(!FileExists(DataBaseFile))
	{
		PrintToServer("[ZBM3_DATABASE] ERROR: file not exist");
		return;
	}
	
	// And create new one
	KvJumpToKey(DataBase, pSteamID[iPlayer], true); 
	KvSetNum(DataBase, KV_DATABASE_STRING, iPlayer_Ammo); 
	KvRewind(DataBase); 
	KeyValuesToFile(DataBase, DataBaseFile); 
	
	PrintToServer("[ZBM3_DATABASE] Ammo was saved for: %s with: %i ammopacks", pSteamID[iPlayer], iPlayer_Ammo);
}
__________________
gubka is offline
Send a message via ICQ to gubka