rxki
Пользователь
- Регистрация
- 5 Янв 2019
- Сообщения
- 208
- Симпатии
- 5
- Пол
- Мужской
Добрый день. Не могу сообразить, как правильно прописать загрузку суммы денег игрока из ваулт файла. Сохранение данных получилось сделать, а вот как загружать это значение и присваивать его игроку - до сих пор копаюсь...Ниже паблики с загрузкой и сохранением данных игрока в ваулт (паблик сохранения переделывал сам с сейва золота на доллары. Вроде работает, но гляньте, правильно ли прописал). В файле с загрузкой данных тоже сам ковырнул, но что то не то... в общем, памагити, люди добрые)
на всякий случай, вот оригинал пабликов
PHP:
public LoadUserConfig(id)
{
new iFile
if((iFile = nvault_open(NVAULT_FILE_NAME)) == INVALID_HANDLE)
return;
new szKey[48];
new szData[128];
switch(g_ConfigValues[CFG_DATA_SAVE_MODE])
{
case 1: get_user_name(id, szKey, 32);
case 2: get_user_ip(id, szKey, 32, 1);
case 3: get_user_authid(id, szKey, 32)
}
formatex(szKey, charsmax(szKey), "%s-engine#", szKey);
if(nvault_get(iFile, szKey, szData, charsmax(szData)))
{
new szTempInfo[13][8];
explode(szData, '|', szTempInfo, 13, 7);
new tmpMoney[32]
tmpMoney[id] = cs_get_user_money(id)
tmpMoney[id] = str_to_num( szTempInfo[0] );
g_PlayerInfo[id][PLAYER_FRAGS] = str_to_num( szTempInfo[1] );
g_PlayerHealthbar[id] = str_to_num( szTempInfo[2] )
g_PlayerHudSize[id] = str_to_num( szTempInfo[3] );
g_PlayerHudColor[id][0] = str_to_num( szTempInfo[4] );
g_PlayerHudColor[id][1] = str_to_num( szTempInfo[5] );
g_PlayerHudColor[id][2] = str_to_num( szTempInfo[6] );
g_PlayerSwapMoneyAutobuy[id] = str_to_num( szTempInfo[7] );
g_PlayerHealthbarScale[id] = str_to_float( szTempInfo[8] );
g_PlayerHudPosition[id][0] = str_to_float( szTempInfo[9] );
g_PlayerHudPosition[id][1] = str_to_float( szTempInfo[10] );
g_PlayerGamePlayedNumber[id] = str_to_num( szTempInfo[11] );
g_PlayerShowHitCrosshair[id] = str_to_num( szTempInfo[12] );
new iMax;
new iFrags = g_PlayerInfo[id][PLAYER_FRAGS];
for(new i = 1; i <= MAX_LEVEL; i++)
if(iFrags >= g_LevelFrags[i])
iMax = i + 1;
g_PlayerInfo[id][PLAYER_LEVEL] = iMax;
if(g_PlayerInfo[id][PLAYER_LEVEL] > 1)
{
for(new i = 2; i <= iMax ; i++)
GiveUserSkillsByLevel(id, i);
}
}
nvault_close(iFile);
}
public GiveUserSkillsByLevel(iPlayer, iLevel)
{
switch(iLevel)
{
case 2: g_PlayerInfo[iPlayer][PLAYER_EXTRA_DAMAGE] += 6;
case 3: g_PlayerInfo[iPlayer][PLAYER_EXTRA_SPEED] += 25;
case 4: g_PlayerInfo[iPlayer][PLAYER_EXTRA_GOLD] += 1
case 5: g_PlayerInfo[iPlayer][PLAYER_EXTRA_MONEY] += 150
case 6: set_task(120.0, "GiveUserNapalmTask", iPlayer + TASK_GIVE_NAPALM, _, _, "b");
case 7: g_PlayerInfo[iPlayer][PLAYER_EXTRA_SPEED] += 50
case 8: g_PlayerInfo[iPlayer][PLAYER_EXTRA_DAMAGE] += 16;
case 9: set_task(120.0, "GiveUserFrozenTask", iPlayer + TASK_GIVE_FROZEN, _, _, "b");
}
}
stock explode(const string[],const character,output[][],const maxs,const maxlen)
{
new iDo = 0,
len = strlen(string),
oLen = 0;
do{
oLen += (1+copyc(output[iDo++],maxlen,string[oLen],character))
}while(oLen < len && iDo < maxs)
}
public SaveUserConfig(id, iFile)
{
new szKey[48];
new szData[128];
switch(g_ConfigValues[CFG_DATA_SAVE_MODE])
{
case 1: get_user_name(id, szKey, 32);
case 2: get_user_ip(id, szKey, 32, 1);
case 3: get_user_authid(id, szKey, 32)
}
new tmpGold = g_PlayerInfo[id][PLAYER_GOLD];
new tmpMoney[32]
if(g_IsPlayerVip[id])
{
if(g_ConfigValues[CFG_BANK_LIMIT_VIP])
{
if(tmpGold > g_ConfigValues[CFG_BANK_LIMIT_VIP])
{
client_print_color(id, print_team_default, "%s^x01 Лимит переноса^x04 золота^x01 на следующую катру для ^x04VIP^x01 = ^x04%d^x01", CHAT_PREFIX, g_ConfigValues[CFG_BANK_LIMIT_VIP]);
tmpGold = g_ConfigValues[CFG_BANK_LIMIT_VIP];
}
}
}
else
{
if(g_ConfigValues[CFG_BANK_LIMIT])
{
if(tmpGold > g_ConfigValues[CFG_BANK_LIMIT])
{
client_print_color(id, print_team_default, "%s^x01 Лимит переноса^x04 золота^x01 на следующую карту = ^x04%d^x01", CHAT_PREFIX, g_ConfigValues[CFG_BANK_LIMIT]);
if(g_ConfigValues[CFG_VIP] && g_ConfigValues[CFG_BANK_LIMIT_VIP])
client_print_color(id, print_team_default, "%s^x01 Игроки с пакетом ^x04VIP^x01 могут сохранять ^x04%d^x01 золота", CHAT_PREFIX, g_ConfigValues[CFG_BANK_LIMIT_VIP])
tmpGold = g_ConfigValues[CFG_BANK_LIMIT];
}
}
}
formatex(szKey, charsmax(szKey), "%s-engine#", szKey);
formatex(szData, charsmax(szData), "%d|%d|%d|%d|%d|%d|%d|%d|%0.2f|%0.2f|%0.2f|%d|%d",
tmpMoney[id], g_PlayerInfo[id][PLAYER_FRAGS], g_PlayerHealthbar[id], g_PlayerHudSize[id],
g_PlayerHudColor[id][0], g_PlayerHudColor[id][1], g_PlayerHudColor[id][2],
g_PlayerSwapMoneyAutobuy[id], g_PlayerHealthbarScale[id],
g_PlayerHudPosition[id][0], g_PlayerHudPosition[id][1], g_PlayerGamePlayedNumber[id],
g_PlayerShowHitCrosshair[id])
nvault_set(iFile, szKey, szData);
}
на всякий случай, вот оригинал пабликов
PHP:
public LoadUserConfig(id)
public LoadUserConfig(id)
{
new iFile
if((iFile = nvault_open(NVAULT_FILE_NAME)) == INVALID_HANDLE)
return;
new szKey[48];
new szData[128];
switch(g_ConfigValues[CFG_DATA_SAVE_MODE])
{
case 1: get_user_name(id, szKey, 32);
case 2: get_user_ip(id, szKey, 32, 1);
case 3: get_user_authid(id, szKey, 32)
}
formatex(szKey, charsmax(szKey), "%s-engine#", szKey);
if(nvault_get(iFile, szKey, szData, charsmax(szData)))
{
new szTempInfo[13][8];
explode(szData, '|', szTempInfo, 13, 7);
g_PlayerInfo[id][PLAYER_GOLD] = str_to_num( szTempInfo[0] );
g_PlayerInfo[id][PLAYER_FRAGS] = str_to_num( szTempInfo[1] );
g_PlayerHealthbar[id] = str_to_num( szTempInfo[2] )
g_PlayerHudSize[id] = str_to_num( szTempInfo[3] );
g_PlayerHudColor[id][0] = str_to_num( szTempInfo[4] );
g_PlayerHudColor[id][1] = str_to_num( szTempInfo[5] );
g_PlayerHudColor[id][2] = str_to_num( szTempInfo[6] );
g_PlayerSwapMoneyAutobuy[id] = str_to_num( szTempInfo[7] );
g_PlayerHealthbarScale[id] = str_to_float( szTempInfo[8] );
g_PlayerHudPosition[id][0] = str_to_float( szTempInfo[9] );
g_PlayerHudPosition[id][1] = str_to_float( szTempInfo[10] );
g_PlayerGamePlayedNumber[id] = str_to_num( szTempInfo[11] );
g_PlayerShowHitCrosshair[id] = str_to_num( szTempInfo[12] );
new iMax;
new iFrags = g_PlayerInfo[id][PLAYER_FRAGS];
for(new i = 1; i <= MAX_LEVEL; i++)
if(iFrags >= g_LevelFrags[i])
iMax = i + 1;
g_PlayerInfo[id][PLAYER_LEVEL] = iMax;
if(g_PlayerInfo[id][PLAYER_LEVEL] > 1)
{
for(new i = 2; i <= iMax ; i++)
GiveUserSkillsByLevel(id, i);
}
}
nvault_close(iFile);
}
public GiveUserSkillsByLevel(iPlayer, iLevel)
{
switch(iLevel)
{
case 2: g_PlayerInfo[iPlayer][PLAYER_EXTRA_DAMAGE] += 6;
case 3: g_PlayerInfo[iPlayer][PLAYER_EXTRA_SPEED] += 25;
case 4: g_PlayerInfo[iPlayer][PLAYER_EXTRA_GOLD] += 1
case 5: g_PlayerInfo[iPlayer][PLAYER_EXTRA_MONEY] += 150
case 6: set_task(120.0, "GiveUserNapalmTask", iPlayer + TASK_GIVE_NAPALM, _, _, "b");
case 7: g_PlayerInfo[iPlayer][PLAYER_EXTRA_SPEED] += 50
case 8: g_PlayerInfo[iPlayer][PLAYER_EXTRA_DAMAGE] += 16;
case 9: set_task(120.0, "GiveUserFrozenTask", iPlayer + TASK_GIVE_FROZEN, _, _, "b");
}
}
stock explode(const string[],const character,output[][],const maxs,const maxlen)
{
new iDo = 0,
len = strlen(string),
oLen = 0;
do{
oLen += (1+copyc(output[iDo++],maxlen,string[oLen],character))
}while(oLen < len && iDo < maxs)
}
public SaveUserConfig(id, iFile)
{
new szKey[48];
new szData[128];
switch(g_ConfigValues[CFG_DATA_SAVE_MODE])
{
case 1: get_user_name(id, szKey, 32);
case 2: get_user_ip(id, szKey, 32, 1);
case 3: get_user_authid(id, szKey, 32)
}
new tmpGold = g_PlayerInfo[id][PLAYER_GOLD];
if(g_IsPlayerVip[id])
{
if(g_ConfigValues[CFG_BANK_LIMIT_VIP])
{
if(tmpGold > g_ConfigValues[CFG_BANK_LIMIT_VIP])
{
client_print_color(id, print_team_default, "%s^x01 Лимит переноса^x04 золота^x01 на следующую катру для ^x04VIP^x01 = ^x04%d^x01", CHAT_PREFIX, g_ConfigValues[CFG_BANK_LIMIT_VIP]);
tmpGold = g_ConfigValues[CFG_BANK_LIMIT_VIP];
}
}
}
else
{
if(g_ConfigValues[CFG_BANK_LIMIT])
{
if(tmpGold > g_ConfigValues[CFG_BANK_LIMIT])
{
client_print_color(id, print_team_default, "%s^x01 Лимит переноса^x04 золота^x01 на следующую карту = ^x04%d^x01", CHAT_PREFIX, g_ConfigValues[CFG_BANK_LIMIT]);
if(g_ConfigValues[CFG_VIP] && g_ConfigValues[CFG_BANK_LIMIT_VIP])
client_print_color(id, print_team_default, "%s^x01 Игроки с пакетом ^x04VIP^x01 могут сохранять ^x04%d^x01 золота", CHAT_PREFIX, g_ConfigValues[CFG_BANK_LIMIT_VIP])
tmpGold = g_ConfigValues[CFG_BANK_LIMIT];
}
}
}
formatex(szKey, charsmax(szKey), "%s-engine#", szKey);
formatex(szData, charsmax(szData), "%d|%d|%d|%d|%d|%d|%d|%d|%0.2f|%0.2f|%0.2f|%d|%d",
tmpGold, g_PlayerInfo[id][PLAYER_FRAGS], g_PlayerHealthbar[id], g_PlayerHudSize[id],
g_PlayerHudColor[id][0], g_PlayerHudColor[id][1], g_PlayerHudColor[id][2],
g_PlayerSwapMoneyAutobuy[id], g_PlayerHealthbarScale[id],
g_PlayerHudPosition[id][0], g_PlayerHudPosition[id][1], g_PlayerGamePlayedNumber[id],
g_PlayerShowHitCrosshair[id])
nvault_set(iFile, szKey, szData);
}
}
Последнее редактирование: