[ZP] Buy Armor and health [Help]
Всем Привет, решил в плагин добавить лимит на использование
то есть броню можно купить только 2 раза за раунд.
1) Когда купил броню 2 раза, а потом покупаешь, Жизни пишет BbI y)I(E 6PAJIu ARMOR ( не понимаю как исправить, что бы это сообщение показывалось только тогда когда покупаешь Броню)
2) когда пере заходишь на сервер, что надо прописать в public client_disconnect ( что бы обнулялось, ( мне кажется это надо обнулить static bool:g_i_status[33] ) но не знаю как )
==
Sorry for my english
Hi all, I decided to add a plug-in limit on the use of
that is, the armor can be bought only 2 times per round.
1) When the armor purchased 2 times and then you pay, Life, writes BbI y) I (E 6PAJIu ARMOR (do not know how to fix what this message is displayed only when you buy armor)
2) When you come to transfer server that you can set a public client_disconnect (that would be zeroed out, (I think it should be zero static bool: g_i_status [33]), but I do not know how)
Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <cstrike>
#include <fakemeta_util>
#include <zombieplague>
#include <fun>
#include <hamsandwich>
/*================================================================================
[Plugin Customization]
================================================================================*/
new g_msgSayText
/*============================================================================*/
//Броня
new const g_item_name_hum[] = { "Броня+50" }
new const g_item_name_zm[] = { "Броня+250" }
new g_item_cost_h
new g_item_cost_z
new const g_sound_buyarmor[] = { "items/tr_kevlar.wav" }
new const g_sound_buyhealth[] = { "player/bhit_helmet-1.wav" }
new g_armor_amount_h
new g_armor_limit_h
new g_armor_amount_z
new g_armor_limit_z
/*============================================================================*/
// Жизни
new const g_item_name_health_h[] = { "Жизни+350" }
new const g_item_name_health_z[] = { "Жизни+1550" }
new g_health_amount_h
new g_health_limit_h
new g_item_cost_health_h
new g_health_amount_z
new g_health_limit_z
new g_item_cost_health_z
/*============================================================================*/
// Item IDs
//Броня
new g_itemid_humanarmor
new g_itemid_zombiearmor
//Жизни
new g_itemid_humanhealth
new g_itemid_zombiehealth
static bool:g_i_status[33]
new zombiehealth, humanhealth, humanarmor, zombiearmor
public plugin_precache()
{
precache_sound(g_sound_buyarmor)
precache_sound(g_sound_buyhealth)
}
public plugin_init()
{
/*============================================================================*/
register_plugin("[ZP] Extra: Anti-Infection Armor", "1.0", "MeRcyLeZZ")
register_logevent("round_start",2,"1=Round_Start")
zombiehealth = register_cvar("zombiehealth","1");
humanhealth = register_cvar("humanhealth","1");
humanarmor = register_cvar("humanarmor","1");
zombiearmor = register_cvar("zombiearmor","1");
g_msgSayText = get_user_msgid("SayText");
/*============================================================================*/
//CVARS Цена
g_item_cost_h = register_cvar("zp_armor_cost_h", "7")
g_item_cost_z = register_cvar("zp_armor_cost_z", "7")
/*============================================================================*/
//кол.в Брони
g_armor_amount_h = register_cvar("zp_armor_amount_h", "50") //сколько дается при покупке HUMMAN
g_armor_limit_h = register_cvar("zp_armor_limit_h", "100") //Лимит Брони HUMMAN
/*============================================================================*/
//Настройка Брони
g_armor_amount_z = register_cvar("zp_armor_amount_z", "250") //сколько дается при покупке ZOMBIE
g_armor_limit_z = register_cvar("zp_armor_limit_z", "700") //Лимит Брони ZOMBIE
/*============================================================================*/
//EXTRA ITEM Брони
if(get_pcvar_num(humanarmor) == 1)
{
g_itemid_humanarmor = zp_register_extra_item(g_item_name_hum, get_pcvar_num(g_item_cost_h), ZP_TEAM_HUMAN)
}
if(get_pcvar_num(zombiearmor) == 1)
{
g_itemid_zombiearmor = zp_register_extra_item(g_item_name_zm, get_pcvar_num(g_item_cost_z), ZP_TEAM_ZOMBIE)
}
/*============================================================================*/
//CVARS Цена
g_item_cost_health_h = register_cvar("zp_health_cost_h", "7")
g_item_cost_health_z = register_cvar("zp_health_cost_z", "7")
/*============================================================================*/
//кол.в Жизней
g_health_amount_h = register_cvar("zp_health_amount_h", "350") //сколько дается при покупке HUMMAN
g_health_limit_h = register_cvar("zp_health_limit_h", "1550") //Лимит при покупке HUMMAN
g_health_amount_z = register_cvar("zp_health_amount_z", "1550") //сколько дается при покупке ZOMBIE
g_health_limit_z = register_cvar("zp_health_limit_z", "8550") //Лимит при покупке ZOMBIE
/*============================================================================*/
//EXTRA ITEM Жизней
if(get_pcvar_num(humanhealth) == 1)
{
g_itemid_humanhealth = zp_register_extra_item(g_item_name_health_h, get_pcvar_num(g_item_cost_health_h), ZP_TEAM_HUMAN)
}
if(get_pcvar_num(zombiehealth) == 1)
{
g_itemid_zombiehealth = zp_register_extra_item(g_item_name_health_z, get_pcvar_num(g_item_cost_health_z), ZP_TEAM_ZOMBIE)
}
/*============================================================================*/
}
public client_connect(player)
g_i_status[player]=true
public round_start()
{
for(new a=1;a<33;a++)
g_i_status[a]=true
}
public zp_extra_item_selected(player, itemid)
{
if(g_i_status[player]==true)
{
//
/*============================================================================*/
//Броня Люди
if (itemid == g_itemid_humanarmor)
{
set_pev(player, pev_armorvalue, float(min(pev(player, pev_armorvalue)+get_pcvar_num(g_armor_amount_h), get_pcvar_num(g_armor_limit_h))))
engfunc(EngFunc_EmitSound, player, CHAN_BODY, g_sound_buyarmor, 1.0, ATTN_NORM, 0, PITCH_NORM)
client_printcolor(player, "/g[ZP] /gВы Купили /t%d /gБрони", get_pcvar_num(g_armor_amount_h))
g_i_status[player]=false
}
//
}
else
{
client_printcolor(player, "/g[ZP] /gBbI y)I(E 6PAJIu ARMOR")
}
/*============================================================================*/
//Броня Зомби
if (itemid == g_itemid_zombiearmor)
{
set_pev(player, pev_armorvalue, float(min(pev(player, pev_armorvalue)+get_pcvar_num(g_armor_amount_z), get_pcvar_num(g_armor_limit_z))))
client_printcolor(player, "/g[ZP] /gВы Купили /t%i /gБрони", get_pcvar_num(g_armor_amount_z))
}
/*============================================================================*/
//Жизни Люди
if (itemid == g_itemid_humanhealth)
{
//set_user_health(player,get_user_health(player)+get_pcvar_num(g_health_amount_h));
set_user_health(player, min(get_user_health(player) +get_pcvar_num(g_health_amount_h), get_pcvar_num(g_health_limit_h)))
engfunc(EngFunc_EmitSound, player, CHAN_BODY, g_sound_buyhealth, 1.0, ATTN_NORM, 0, PITCH_NORM)
client_printcolor(player, "/g[ZP] /gВы Купили /t%i /gHP", get_pcvar_num(g_health_amount_h))
}
/*============================================================================*/
//Жизни Зомби
if (itemid == g_itemid_zombiehealth)
{
//set_user_health(player,get_user_health(player)+get_pcvar_num(g_health_amount_z));
set_user_health(player, min(get_user_health(player) +get_pcvar_num(g_health_amount_z), get_pcvar_num(g_health_limit_z)))
client_printcolor(player, "/g[ZP] /gВы Купили /t%i /gHP", get_pcvar_num(g_health_amount_z))
}
/*============================================================================*/
}
stock client_printcolor(id, const input[], any:...)
{
static iPlayersNum[32], iCount; iCount = 1
static szMsg[191]
vformat(szMsg, charsmax(szMsg), input, 3)
replace_all(szMsg, 190, "/g", "^4") // green txt
replace_all(szMsg, 190, "/y", "^1") // orange txt
replace_all(szMsg, 190, "/t", "^3") // team txt
if(id) iPlayersNum[0] = id
else get_players(iPlayersNum, iCount, "ch")
for (new i = 0; i < iCount; i++)
{
if (is_user_connected(iPlayersNum[i]))
{
message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, iPlayersNum[i])
write_byte(iPlayersNum[i])
write_string(szMsg)
message_end()
}
}
}
|