Quote:
Originally Posted by Lannister
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);
}
__________________