Скриптер
Участник
Пользователь
- Сообщения
- 673
- Реакции
- 242
- Помог
- 11 раз(а)
Добрый день!
Столкнулся с ньюансом
Имеется ранги как за зеков так и за охрану
при смены команды, ранг не обновляется, т.е. ранг зека не обновляет ранк за КТ, а обновляется после таска jbe_update_rank
вроде вызвал форвард на смену команды:
все же без результата. в чем может быть проблема?
Столкнулся с ньюансом
Имеется ранги как за зеков так и за охрану
Код:
#include <amxmodx>
#include <jbe_core>
enum _:(+= 100)
{
TASK_RANK_REWARD_EXP = 200,
TASK_RANK_UPDATE_RANK
}
#define TOTAL_PLAYER_LEVELS 16
#define MAX_LEVEL TOTAL_PLAYER_LEVELS - 1
new g_iLevel[MAX_PLAYERS + 1];
forward jbe_set_team_fwd(pId);
native get_login(pPlayer);
new const g_szExp[TOTAL_PLAYER_LEVELS]=
{
0,
16,
40,
80,
150,
200,
290,
500,
796,
1000,
1580,
2900,
3900,
5000,
8000,
12000
};
#if defined DEBUG
new const g_szRankName[TOTAL_PLAYER_LEVELS][]=
{
"JBE_ID_HUD_RANK_NAME_1",
"JBE_ID_HUD_RANK_NAME_2",
"JBE_ID_HUD_RANK_NAME_3",
"JBE_ID_HUD_RANK_NAME_4",
"JBE_ID_HUD_RANK_NAME_5",
"JBE_ID_HUD_RANK_NAME_6",
"JBE_ID_HUD_RANK_NAME_7",
"JBE_ID_HUD_RANK_NAME_8",
"JBE_ID_HUD_RANK_NAME_9",
"JBE_ID_HUD_RANK_NAME_10",
"JBE_ID_HUD_RANK_NAME_11",
"JBE_ID_HUD_RANK_NAME_12",
"JBE_ID_HUD_RANK_NAME_13",
"JBE_ID_HUD_RANK_NAME_14",
"JBE_ID_HUD_RANK_NAME_15",
"JBE_ID_HUD_RANK_NAME_16"
};
new const g_szRankNameCT[16][]=
{
"JBE_ID_HUD_RANK_NAME_CT_1",
"JBE_ID_HUD_RANK_NAME_CT_2",
"JBE_ID_HUD_RANK_NAME_CT_3",
"JBE_ID_HUD_RANK_NAME_CT_4",
"JBE_ID_HUD_RANK_NAME_CT_5",
"JBE_ID_HUD_RANK_NAME_CT_6",
"JBE_ID_HUD_RANK_NAME_CT_7",
"JBE_ID_HUD_RANK_NAME_CT_8",
"JBE_ID_HUD_RANK_NAME_CT_9",
"JBE_ID_HUD_RANK_NAME_CT_10",
"JBE_ID_HUD_RANK_NAME_CT_11",
"JBE_ID_HUD_RANK_NAME_CT_12",
"JBE_ID_HUD_RANK_NAME_CT_13",
"JBE_ID_HUD_RANK_NAME_CT_14",
"JBE_ID_HUD_RANK_NAME_CT_15",
"JBE_ID_HUD_RANK_NAME_CT_16"
};
#endif
//#if definde DEBUG
native jbe_mysql_get_exp(id, iType);
native jbe_mysql_set_exp(id, iType, set);
forward jbe_rank_start(id)
forward jbe_rank_end(id)
public plugin_init()
{
register_plugin("[MYSQL] Regs Rank", "1.0a", "DalgaPups");
#if defined DEBUG
register_clcmd("say /mestat", "ClCmd_statsme");
#endif
}
public plugin_natives()
{
register_native("jbe_get_user_ranks", "jbe_get_user_ranks", 1);
register_native("jbe_get_user_exp_next", "jbe_get_user_exp_next", 1);
}
public jbe_get_user_ranks(pId) return g_iLevel[pId]
#if defined DEBUG
public ClCmd_statsme(pId)
{
client_print_color(pId, 0, "^x04[RankSystems] ^x01Опыт: %d",jbe_mysql_get_exp( pId, jbe_get_user_team(pId) ))
client_print_color(pId, 0, "^x04[RankSystems] ^x01ЛВЛ: %d",jbe_get_user_level(pId) + 1)
switch(jbe_get_user_team(pId))
{
case 1: client_print_color(pId, 0, "^x04[RankSystems] ^x01ЛВЛ: %L", LANG_PLAYER,g_szRankName[g_iLevel[pId]])
case 2: client_print_color(pId, 0, "^x04[RankSystems] ^x01ЛВЛ: %L", LANG_PLAYER,g_szRankNameCT[g_iLevel[pId]])
}
}
#endif
public jbe_get_user_exp_next(pId)
{
new iLevel = g_iLevel[pId] == MAX_LEVEL ? MAX_LEVEL : (g_iLevel[pId] + 1);
return g_szExp[iLevel];
}
jbe_get_user_level(pId)
{
new iCurrentLevel;
for(new i = 0; i <= TOTAL_PLAYER_LEVELS; i++)
{
switch(i)
{
case TOTAL_PLAYER_LEVELS: iCurrentLevel = MAX_LEVEL;
default:
{
if(jbe_mysql_get_exp( pId, jbe_get_user_team(pId) ) < g_szExp[i])
{
iCurrentLevel = i - 1;
break;
}
}
}
}
return iCurrentLevel;
}
public jbe_rank_start(id)
{
set_task(1.0, "jbe_update_rank", id + TASK_RANK_UPDATE_RANK);
}
public jbe_update_rank(id)
{
id -= TASK_RANK_UPDATE_RANK;
#if defined DEBUG
new szName[34];
get_user_name(id, szName, charsmax(szName));
log_amx("forward for called - %d, Name - %s", id, szName);
#endif
new iCurrentLevel = jbe_get_user_level(id);
if(g_iLevel[id] != iCurrentLevel)
{
if(iCurrentLevel > MAX_LEVEL) iCurrentLevel = MAX_LEVEL;
g_iLevel[id] = iCurrentLevel;
}
if(!task_exists(id + TASK_RANK_REWARD_EXP))
set_task(30.0, "jbe_rank_reward_exp", id + TASK_RANK_REWARD_EXP, .flags = "b");
}
public jbe_rank_end(id)
{
remove_task(id + TASK_RANK_REWARD_EXP);
jbe_mysql_set_exp(id, 1, 0);
jbe_mysql_set_exp(id, 2, 0);
g_iLevel[id] = 0;
#if defined DEBUG
new szName[34];
get_user_name(id, szName, charsmax(szName));
log_amx("forward END for called - %d, Name - %s", id, szName);
#endif
}
public jbe_rank_reward_exp(pPlayer)
{
pPlayer -= TASK_RANK_REWARD_EXP;
new Exp_Time = random_num(2, 5);
if(jbe_get_user_team(pPlayer) != 3)
{
if(jbe_mysql_get_exp(pPlayer, jbe_get_user_team(pPlayer)) < 12000)
{
jbe_mysql_set_exp(pPlayer, jbe_get_user_team(pPlayer), jbe_mysql_get_exp( pPlayer, jbe_get_user_team(pPlayer) ) + Exp_Time)
client_print_color(pPlayer, 0, "^x04[RankSystems] ^x01Ваш авторитет повысился на %d/%d", Exp_Time,jbe_mysql_get_exp( pPlayer, jbe_get_user_team(pPlayer) ))
}
new iCurrentLevel = jbe_get_user_level(pPlayer);
if(g_iLevel[pPlayer] != iCurrentLevel)
{
if(iCurrentLevel > MAX_LEVEL) iCurrentLevel = MAX_LEVEL;
g_iLevel[pPlayer] = iCurrentLevel;
}
}
}
public jbe_set_team_fwd(pPlayer)
{
//log_amx("Forwad team select call");
if(get_login(pPlayer))
{
new iCurrentLevel = jbe_get_user_level(pPlayer);
if(g_iLevel[pPlayer] != iCurrentLevel)
{
if(iCurrentLevel > MAX_LEVEL) iCurrentLevel = MAX_LEVEL;
g_iLevel[pPlayer] = iCurrentLevel;
}
}
}
public client_disconnected(id)
{
if(task_exists(id + TASK_RANK_REWARD_EXP)) remove_task(id + TASK_RANK_REWARD_EXP);
}
вроде вызвал форвард на смену команды:
Код:
public jbe_set_team_fwd(pPlayer)
{
//log_amx("Forwad team select call");
if(get_login(pPlayer))
{
new iCurrentLevel = jbe_get_user_level(pPlayer);
if(g_iLevel[pPlayer] != iCurrentLevel)
{
if(iCurrentLevel > MAX_LEVEL) iCurrentLevel = MAX_LEVEL;
g_iLevel[pPlayer] = iCurrentLevel;
}
}
}
26 Апр 2019
Код:
public jbe_mysql_set_exp(id, iType, set)
{
switch(iType)
{
case 1: g_iExpT[id] = set;
case 2: g_iExpCT[id] = set;
}
}