Пользователь
- Сообщения
- 5
- Реакции
- 1
Всем здравствуйте, столкнулся с очередной проблемой.
Плагин должен выводить в конце раунда значение 100 -хп игрока в конце раунда, но всегда выводит 0.
Весь код:
Часть кода с выводом:
Варнинги в компиляторе:
Плагин должен выводить в конце раунда значение 100 -хп игрока в конце раунда, но всегда выводит 0.
Весь код:
Код:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
new bool: g_ModeStarted = false;
public plugin_init(){
register_clcmd("say /match", "Start1x1match");
register_clcmd("say /stop", "Stop1x1match");
register_logevent("RoundEnd", 2, "1=Round_End");
register_clcmd("say /t", "blockcommands");
register_clcmd("say /ct", "blockcommands");
register_clcmd("say /spec", "blockcommands");
}
public Start1x1match(id){
if(get_user_flags(id) & ADMIN_BAN){
if(g_ModeStarted == false){
g_ModeStarted = true;
new iPlayers[MAX_PLAYERS], iNum;
get_players(iPlayers, iNum, "ch");
for (new i; i < iNum; i++) {
new iPlayer = iPlayers[i];
cs_set_user_team(iPlayer, CS_TEAM_SPECTATOR);
user_kill(iPlayer);
}
new ADMIN[32];
get_user_name(id, ADMIN, 31);
client_print_color(0, print_chat, "^3%s ^1chooses players", ADMIN);
Menu(id);
set_cvar_num("mp_auto_join_team", 0);
}
else{
client_print_color(id, print_chat, "1x1 match already started");
}
}
}
public Menu(id){
new i_Menu = menu_create("\rPlayer menu:", "menu_handler");
new s_Players[32], i_Num, i_Player;
new s_Name[32], s_Player[10];
get_players(s_Players, i_Num);
for (new i; i < i_Num; i++){
if(cs_get_user_team(s_Players[i]) == CS_TEAM_SPECTATOR){
i_Player = s_Players[i];
get_user_name(i_Player, s_Name, charsmax(s_Name));
num_to_str(i_Player, s_Player, charsmax(s_Player));
menu_additem(i_Menu, s_Name, s_Player, 0);
}
}
menu_display(id, i_Menu, 0);
}
public menu_handler(id, menu, item){
new s_Data[6], s_Name[64], i_Access, i_Callback;
menu_item_getinfo(menu, item, i_Access, s_Data, charsmax(s_Data), s_Name, charsmax(s_Name), i_Callback);
new i_Player = str_to_num(s_Data);
for(new i = 0; i < 2; i++){
cs_set_user_team(i_Player, CS_TEAM_T);
Menu(id);
}
menu_destroy(menu);
client_print_color(0, print_chat, "1x1 match was started");
set_cvar_num("sv_restart", 1);
return PLUGIN_HANDLED;
}
public Stop1x1match(id){
if(g_ModeStarted == true){
g_ModeStarted = false;
client_print_color(0, print_chat, "1x1 match was stopped");
set_cvar_num("mp_auto_join_team", 1)
set_cvar_num("sv_restart", 1);
}
else{
client_print_color(id, print_chat, "1x1 match isn't running");
}
}
public RoundEnd(id){
new iPlayers[32], iPlayersNum;
get_players(iPlayers, iPlayersNum, "ch");
for(new i; i < iPlayersNum; i++){
new id = iPlayers[i];
if(is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT){
new Float: HealthPoints[32];
new name[32];
get_user_name(id, name, 31);
HealthPoints[id] = 100 - get_user_health(id);
client_print_color(0, print_chat, "^4%s^1 fall dmg ^4%.0f^1 HP for the round", name, HealthPoints[id]);
}
}
}
public blockcommands(id){
if(g_ModeStarted == true){
client_print_color(id, print_chat, "You can't use it, when 1x1 mode is running.");
return PLUGIN_HANDLED;
}
else{
return PLUGIN_HANDLED;
}
}
public client_connect(id){
if(g_ModeStarted == true){
set_task(3.0, "blockjointeam", 0, _, _, "a", 3);
}
}
Код:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
public plugin_init(){
register_logevent("RoundEnd", 2, "1=Round_End");
public RoundEnd(id){
new iPlayers[32], iPlayersNum;
get_players(iPlayers, iPlayersNum, "ch");
for(new i; i < iPlayersNum; i++){
new id = iPlayers[i];
if(is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT){
new Float: HealthPoints[32];
new name[32];
get_user_name(id, name, 31);
HealthPoints[id] = 100 - get_user_health(id);
client_print_color(0, print_chat, "^4%s^1 fall dmg ^4%.0f^1 HP for the round", name, HealthPoints[id]);
}
}
}
Варнинги в компиляторе: