Правила форума Гаранты форума
Размещение рекламы AMX-X компилятор

Здравствуйте, гость Вход | Регистрация

Наши новости:

14-дек
24-апр
10-апр
11-апр

2 страниц V   1 2

Лимит в HP Shop

, Сделать ограничение в 255 НР
binky
сообщение 12.5.2014, 16:00
Сообщение #1
Стаж: 12 лет

Сообщений: 381
Благодарностей: 24
Полезность: 0

Плагин HP Shop. Когда пишешь /hpshop то можно докупить НР.
Есть неприятный баг!! Например у тебя 100НР, берёшь за 8000$ докупаешь ещё 100НР, потом за 6000$ ещё 80НР.
В сумме должно быть 280НР, но после 2й покупки - пишет у тебя всего 24 или 25 НР - выходит 14000$ потратил зря!!!
Короче упираешся в лимит 255 или 256 НР максимум.

Можно в этом плагине добавить, чтобы при покупке больше, чем 255НР присваивало максимально = 255 НР, а не сбрасывало по кругу.
И не снимало деньги если у тебя уже есть 255НР а блокировало покупку с сообщением "У тебя уже максимум 255НР, дальше покупка не возможна".

Код:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <fakemeta>

#define PLUGIN "Health Shop"
#define VERSION "1.0"
#define AUTHOR "ZaCkY"

#define FM_MONEY_OFFSET 115

new health40[200]
new health60[200]
new health80[200]
new health100[200]
new health120[200]
new health140[200]
new health160[200]

new cost_40hp, cost_60hp, cost_80hp, cost_100hp, cost_120hp, cost_140hp, cost_160hp

public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)

register_clcmd("say /hpshop", "show_menu_buy_hp")
register_clcmd("say_team /hpshop", "show_menu_buy_hp")

register_logevent("Event_Round_Start", 2, "1=Round_Start")

cost_40hp = register_cvar("hs_40hp_cost", "2000")
cost_60hp = register_cvar("hs_60hp_cost", "4000")
cost_80hp = register_cvar("hs_80hp_cost", "6000")
cost_100hp = register_cvar("hs_100hp_cost", "8000")
cost_120hp = register_cvar("hs_120hp_cost", "10000")
cost_140hp = register_cvar("hs_140hp_cost", "12000")
cost_160hp = register_cvar("hs_160hp_cost", "14000")
}

public show_menu_buy_hp(id)
{
new menu = menu_create("\rHealth Shop", "handle_buy_hp_menu")

formatex(health40, 199, "+40 Health - $%d", get_pcvar_num(cost_40hp))
menu_additem(menu, health40, "1")

formatex(health60, 199, "+60 Health - $%d", get_pcvar_num(cost_60hp))
menu_additem(menu, health60, "2")

formatex(health80, 199, "+80 Health - $%d", get_pcvar_num(cost_80hp))
menu_additem(menu, health80, "3")

formatex(health100, 199, "+100 Health - $%d", get_pcvar_num(cost_100hp))
menu_additem(menu, health100, "4")

formatex(health120, 199, "+120 Health - $%d", get_pcvar_num(cost_120hp))
menu_additem(menu, health120, "5")

formatex(health140, 199, "+140 Health - $%d", get_pcvar_num(cost_140hp))
menu_additem(menu, health140, "6")

formatex(health160, 199, "+160 Health - $%d", get_pcvar_num(cost_160hp))
menu_additem(menu, health160, "7")

menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, menu, 0)
}

public handle_buy_hp_menu(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}

new Data[6];
new Access;
new Callback;
new Name[64];
menu_item_getinfo(menu, item, Access, Data, 5, Name, 63, Callback)

new Key = str_to_num(Data);

switch (Key)
{
case 1:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_40hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +40 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, Health+40)
}
}

case 2:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_60hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +60 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, Health+60)
}
}

case 3:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_80hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +80 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, Health+80)
}
}

case 4:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_100hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +100 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, Health+100)
}
}

case 5:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_120hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +120 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, Health+120)
}
}

case 6:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_140hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +140 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, Health+140)
}
}

case 7:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_160hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +160 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, Health+160)
}
}
}
menu_destroy(menu)
return PLUGIN_HANDLED
}

public Event_Round_Start()
{
client_print(0, print_chat, "To Open Up Health Shop, Type /hpshop in chat")
}

stock fm_set_user_health(index, health)
{
health > 0 ? set_pev(index, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, index)
return 1
}

stock fm_get_user_money(index)
{
return get_pdata_int(index, FM_MONEY_OFFSET)
}

stock fm_set_user_money(index, money, flash = 1)
{
set_pdata_int(index, FM_MONEY_OFFSET, money);

message_begin(MSG_ONE, get_user_msgid("Money"), _, index);
write_long(money);
write_byte(flash ? 1 : 0);
message_end();
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1053\\ f0\\ fs16 \n\\ par }
*/
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   Цитировать сообщение
Статус пользователя vovan4ik1997
сообщение 12.5.2014, 16:03
Сообщение #2


Стаж: 13 лет

Сообщений: 1087
Благодарностей: 433
Полезность: 718

Вроде как это в худе хп просто пишет, что 24хп, а на самом деле у тебя будет 280.


Представь, что ты заплатил однажды, а получаешь прибыль постоянно.
Закажи правильный контент тут
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
binky
сообщение 12.5.2014, 18:56
Сообщение #3
Стаж: 12 лет

Сообщений: 381
Благодарностей: 24
Полезность: 0

Лучше чтоб сколько на самом деле, столько и в HUDe писалось. И максимум был 255НР - этого достаточно, больше и не надо.

Вообщем так как здесь писал ранее:
Цитата
Можно в этом плагине добавить, чтобы при покупке больше, чем 255НР присваивало максимально = 255 НР, а не сбрасывало по кругу.
И не снимало деньги если у тебя уже есть 255НР а блокировало покупку с сообщением "У тебя уже максимум 255НР, дальше покупка не возможна".
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
binky
сообщение 13.5.2014, 7:18
Сообщение #4
Стаж: 12 лет

Сообщений: 381
Благодарностей: 24
Полезность: 0

Прошу помощи скриптеров
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Vlad
сообщение 13.5.2014, 7:37
Сообщение #5


Стаж: 14 лет

Сообщений: 246
Благодарностей: 102
Полезность: 505

Вот попробуй отпиши работает ли, сделал что если хп больше 100 хп, то меню не откроет с сообщением что хп больше 100 - это не сделает людей с деньгами совсем бессметными и не позволит перебрать хп, когда у них подсняли а те кому нужно 255 купят стразу себе 155.
Код:

#include <amxmodx>
#include <fakemeta>

#define PLUGIN "Health Shop"
#define VERSION "1.0"
#define AUTHOR "ZaCkY"

#define FM_MONEY_OFFSET 115

new health40[200]
new health60[200]
new health80[200]
new health100[200]
new health120[200]
new health140[200]
new health155[200]

new cost_40hp, cost_60hp, cost_80hp, cost_100hp, cost_120hp, cost_140hp, cost_155hp

public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)

register_clcmd("say /hpshop", "show_menu_buy_hp")
register_clcmd("say_team /hpshop", "show_menu_buy_hp")

register_logevent("Event_Round_Start", 2, "1=Round_Start")

cost_40hp = register_cvar("hs_40hp_cost", "2000")
cost_60hp = register_cvar("hs_60hp_cost", "4000")
cost_80hp = register_cvar("hs_80hp_cost", "6000")
cost_100hp = register_cvar("hs_100hp_cost", "8000")
cost_120hp = register_cvar("hs_120hp_cost", "10000")
cost_140hp = register_cvar("hs_140hp_cost", "12000")
cost_155hp = register_cvar("hs_155hp_cost", "14000")
}

public show_menu_buy_hp(id)
{
if ( get_user_health(id) > 100 )
{
ChatColor ( id , "!g[HpShop]!y У тебя здоровья больше 100 ты не можешь купить сейчас сдровье !y!" );
return PLUGIN_HANDLED;
}

new menu = menu_create("\rHealth Shop", "handle_buy_hp_menu")

formatex(health40, 199, "+40 Health - $%d", get_pcvar_num(cost_40hp))
menu_additem(menu, health40, "1")

formatex(health60, 199, "+60 Health - $%d", get_pcvar_num(cost_60hp))
menu_additem(menu, health60, "2")

formatex(health80, 199, "+80 Health - $%d", get_pcvar_num(cost_80hp))
menu_additem(menu, health80, "3")

formatex(health100, 199, "+100 Health - $%d", get_pcvar_num(cost_100hp))
menu_additem(menu, health100, "4")

formatex(health120, 199, "+120 Health - $%d", get_pcvar_num(cost_120hp))
menu_additem(menu, health120, "5")

formatex(health140, 199, "+140 Health - $%d", get_pcvar_num(cost_140hp))
menu_additem(menu, health140, "6")

formatex(health144, 199, "+155 Health - $%d", get_pcvar_num(cost_155hp))
menu_additem(menu, health155, "7")

menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, menu, 0)
return PLUGIN_CONTINUE;
}

public handle_buy_hp_menu(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}

new Data[6];
new Access;
new Callback;
new Name[64];
menu_item_getinfo(menu, item, Access, Data, 5, Name, 63, Callback)

new Key = str_to_num(Data);

switch (Key)
{
case 1:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_40hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +40 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, Health+40)
}
}

case 2:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_60hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +60 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, Health+60)
}
}

case 3:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_80hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +80 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, Health+80)
}
}

case 4:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_100hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +100 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, Health+100)
}
}

case 5:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_120hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +120 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, Health+120)
}
}

case 6:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_140hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +140 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, Health+140)
}
}

case 7:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_155hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +155 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, Health+155)
}
}
}
menu_destroy(menu)
return PLUGIN_HANDLED
}

public Event_Round_Start()
{
client_print(0, print_chat, "To Open Up Health Shop, Type /hpshop in chat")
}

stock fm_set_user_health(index, health)
{
health > 0 ? set_pev(index, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, index)
return 1
}

stock fm_get_user_money(index)
{
return get_pdata_int(index, FM_MONEY_OFFSET)
}

stock fm_set_user_money(index, money, flash = 1)
{
set_pdata_int(index, FM_MONEY_OFFSET, money);

message_begin(MSG_ONE, get_user_msgid("Money"), _, index);
write_long(money);
write_byte(flash ? 1 : 0);
message_end();
}

stock ChatColor(const id, const input[], any:...) // Подключаем сток,который будет читать наши цветные сообщения.
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)

replace_all(msg, 190, "!g", "^4") // Green Color
replace_all(msg, 190, "!y", "^1") // Default Color
replace_all(msg, 190, "!team", "^3") // Team Color
replace_all(msg, 190, "!team2", "^0") // Team2 Color

if (id) players[0] = id; else get_players(players, count, "ch")
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}


Отредактировал: Vladddd, - 13.5.2014, 8:25
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
trollface
сообщение 13.5.2014, 8:06
Сообщение #6
Стаж: 12 лет

Сообщений: 1970
Благодарностей: 2423
Полезность: 0

Vladddd,
Код:
if ( get_user_health(id) > 100 )
{
ChatColor ( id , "!g[HpShop]!y У тебя здоровья больше 100 ты не можешь купить сейчас сдровье !y!" );
return PLUGIN_HANDLED;
}

эм... как бы в плагине нету колорчата и стока я тоже не вижу =|
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Vlad
сообщение 13.5.2014, 8:26
Сообщение #7


Стаж: 14 лет

Сообщений: 246
Благодарностей: 102
Полезность: 505

Код:

stock ChatColor(const id, const input[], any:...) // Подключаем сток,который будет читать наши цветные сообщения.
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)

replace_all(msg, 190, "!g", "^4") // Green Color
replace_all(msg, 190, "!y", "^1") // Default Color
replace_all(msg, 190, "!team", "^3") // Team Color
replace_all(msg, 190, "!team2", "^0") // Team2 Color

if (id) players[0] = id; else get_players(players, count, "ch")
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}

Да ладно нету? а внизу что? сначала подумал реально не добавил попер редактировать сообщение, а он есть)

Хм а сейчас нету, не понял почему конец когда режет?

Удалил пробел лишний в конце вроде сейчас норм показывает.

Отредактировал: Vladddd, - 13.5.2014, 8:22
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
Поблагодарили 1 раз
   + Цитировать сообщение
trollface
сообщение 13.5.2014, 8:32
Сообщение #8
Стаж: 12 лет

Сообщений: 1970
Благодарностей: 2423
Полезность: 0

Vladddd,
Цитата
Отредактировал: Vladddd, - Сегодня, 10:25

а мой пост написан был в
Цитата
Сегодня, 10:06

ты кого разводишь? -_-
вот такая же у тебя и контора по раскрутке. только на...б и больше ничего
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Vlad
сообщение 13.5.2014, 8:35
Сообщение #9


Стаж: 14 лет

Сообщений: 246
Благодарностей: 102
Полезность: 505

Пфф ты не по теме тут, я редактировал что бы стабильно показывало весь код, а то часть кода резалась через каждое обновление страницы когда был снос строки лишний перед павном.
Да и жаль, я был более высокого о тебе мнения.

Отредактировал: Vladddd, - 13.5.2014, 8:44
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
trollface
сообщение 13.5.2014, 11:32
Сообщение #10
Стаж: 12 лет

Сообщений: 1970
Благодарностей: 2423
Полезность: 0

Vladddd,
ну знаешь, при первом просмотре страницы не было колорчата > я тебе указал на это, ты же в свою очередь сказал что он там есть, хотя его не было и ты его потом добавил;)
ps.gif Это оффтоп. извините модераторы. f1nik %% тут явно не уместны. я указал человеку что у него колорчата и указал на то что он редактировал. Откуда мне знать что форум обрезает код?! Следовательно мысль одна... она озвучена в предыдущем моем посте.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
binky
сообщение 13.5.2014, 19:29
Сообщение #11
Стаж: 12 лет

Сообщений: 381
Благодарностей: 24
Полезность: 0

Ребята, давайте жить дружно.
Спасибо, но вы перемудрили с алгоритмом. Исли игрок купил себе 50НР (стало = 150НР), то почему он не может купить ещё 50НР, чтобы было 200НР.
А при первой покупке он может купить хоть 100 и будет 200НР.
Я думаю, не нужно выдумывать хитрые алгоритмы покупок, а просто ограничить лимит в 255НР, то есть как я писал в первом сообщении. А идеально было добавить возможность сохранения НР, если в конце раунда у тебя осталось 135 НР то следующий раунд начинался с 135, а не со 100НР.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя f1nik
сообщение 14.5.2014, 11:15
Сообщение #12


Иконка группы

Стаж: 15 лет

Сообщений: 1862
Благодарностей: 932
Полезность: 1010

trollface,
Что и где обрезает чего не хватает, можно обсудить без агра. Это раз. Проценты даны за попытку спровоцировать срач про раскрутку. Это совсем тут неуместно. Будте вежливее. Не надо пооецировать ошибки в оформлении поста с качеством предоставляемых услуг. Для этого есть другие разделы
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
binky
сообщение 15.5.2014, 23:29
Сообщение #13
Стаж: 12 лет

Сообщений: 381
Благодарностей: 24
Полезность: 0

Спасибо модератор удалил офтоп, который развели на пустом месте.
Помогите добавить в плагин лимит = 255НР так как я просил в первоом сообщении?
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
binky
сообщение 16.5.2014, 14:36
Сообщение #14
Стаж: 12 лет

Сообщений: 381
Благодарностей: 24
Полезность: 0

Такой интересный плагин и этот глюк с "переполнением".
К кому из скриптеров обратиться чтобы сделал лимит 255НР.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
trollface
сообщение 16.5.2014, 14:43
Сообщение #15
Стаж: 12 лет

Сообщений: 1970
Благодарностей: 2423
Полезность: 0

binky,
Попробуйте так:
Код:
#include <amxmodx>
#include <fakemeta>

#define PLUGIN "Health Shop"
#define VERSION "1.0"
#define AUTHOR "ZaCkY"

#define FM_MONEY_OFFSET 115

new health40[200]
new health60[200]
new health80[200]
new health100[200]
new health120[200]
new health140[200]
new health160[200]
new maxHP = 255

new cost_40hp, cost_60hp, cost_80hp, cost_100hp, cost_120hp, cost_140hp, cost_160hp

public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)

register_clcmd("say /hpshop", "show_menu_buy_hp")
register_clcmd("say_team /hpshop", "show_menu_buy_hp")

register_logevent("Event_Round_Start", 2, "1=Round_Start")

cost_40hp = register_cvar("hs_40hp_cost", "2000")
cost_60hp = register_cvar("hs_60hp_cost", "4000")
cost_80hp = register_cvar("hs_80hp_cost", "6000")
cost_100hp = register_cvar("hs_100hp_cost", "8000")
cost_120hp = register_cvar("hs_120hp_cost", "10000")
cost_140hp = register_cvar("hs_140hp_cost", "12000")
cost_160hp = register_cvar("hs_160hp_cost", "14000")
}

public show_menu_buy_hp(id)
{
new menu = menu_create("\rHealth Shop", "handle_buy_hp_menu")

formatex(health40, 199, "+40 Health - $%d", get_pcvar_num(cost_40hp))
menu_additem(menu, health40, "1")

formatex(health60, 199, "+60 Health - $%d", get_pcvar_num(cost_60hp))
menu_additem(menu, health60, "2")

formatex(health80, 199, "+80 Health - $%d", get_pcvar_num(cost_80hp))
menu_additem(menu, health80, "3")

formatex(health100, 199, "+100 Health - $%d", get_pcvar_num(cost_100hp))
menu_additem(menu, health100, "4")

formatex(health120, 199, "+120 Health - $%d", get_pcvar_num(cost_120hp))
menu_additem(menu, health120, "5")

formatex(health140, 199, "+140 Health - $%d", get_pcvar_num(cost_140hp))
menu_additem(menu, health140, "6")

formatex(health160, 199, "+160 Health - $%d", get_pcvar_num(cost_160hp))
menu_additem(menu, health160, "7")

menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, menu, 0)
}

public handle_buy_hp_menu(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}

new Data[6];
new Access;
new Callback;
new Name[64];
menu_item_getinfo(menu, item, Access, Data, 5, Name, 63, Callback)

new Key = str_to_num(Data);

switch (Key)
{
case 1:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_40hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +40 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, ((Health += 40) > maxHP)?maxHP:Health)
}
}

case 2:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_60hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +60 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, ((Health += 60) > maxHP)?maxHP:Health)
}
}

case 3:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_80hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +80 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, ((Health += 80) > maxHP)?maxHP:Health)
}
}

case 4:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_100hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +100 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, ((Health += 100) > maxHP)?maxHP:Health)
}
}

case 5:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_120hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +120 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, ((Health += 120) > maxHP)?maxHP:Health)
}
}

case 6:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_140hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +140 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, ((Health += 140) > maxHP)?maxHP:Health)
}
}

case 7:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_160hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +160 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, ((Health += 160) > maxHP)?maxHP:Health)
}
}
}
menu_destroy(menu)
return PLUGIN_HANDLED
}

public Event_Round_Start()
{
client_print(0, print_chat, "To Open Up Health Shop, Type /hpshop in chat")
}

stock fm_set_user_health(index, health)
{
health > 0 ? set_pev(index, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, index)
return 1
}

stock fm_get_user_money(index)
{
return get_pdata_int(index, FM_MONEY_OFFSET)
}

stock fm_set_user_money(index, money, flash = 1)
{
set_pdata_int(index, FM_MONEY_OFFSET, money);

message_begin(MSG_ONE, get_user_msgid("Money"), _, index);
write_long(money);
write_byte(flash ? 1 : 0);
message_end();
}
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
Поблагодарили 1 раз
   + Цитировать сообщение
binky
сообщение 16.5.2014, 16:57
Сообщение #16
Стаж: 12 лет

Сообщений: 381
Благодарностей: 24
Полезность: 0

Спасибо.
Вв вашем варианте, если у меня 200НР и я куплю ещё +60, у меня 200+60=260 > 255 и запишется = 255НР,
но дальше я всё равно могу покупать и тратить деньги, но всё равно будет 255НР.
Нужно если игрок набрал максимумальные 255НР - то чтобы следущая покупка не вообще осуществлялась,
писало что у вас максимум НР и деньги не снимались.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя GOOD FELLOW
сообщение 16.5.2014, 17:08
Сообщение #17


Иконка группы

Стаж: 13 лет

Сообщений: 2294
Благодарностей: 1187
Полезность: 890

Цитата(binky @ 16.5.2014, 16:57) *
Спасибо.
Вв вашем варианте, если у меня 200НР и я куплю ещё +60, у меня 200+60=260 > 255 и запишется = 255НР,
но дальше я всё равно могу покупать и тратить деньги, но всё равно будет 255НР.
Нужно если игрок набрал максимумальные 255НР - то чтобы следущая покупка не вообще осуществлялась,
писало что у вас максимум НР и деньги не снимались.


попробуй вот так

Код:
#include <amxmodx>
#include <fakemeta>

#define PLUGIN "Health Shop"
#define VERSION "1.0"
#define AUTHOR "ZaCkY"

#define FM_MONEY_OFFSET 115

new health40[200]
new health60[200]
new health80[200]
new health100[200]
new health120[200]
new health140[200]
new health160[200]
new maxHP = 255

new cost_40hp, cost_60hp, cost_80hp, cost_100hp, cost_120hp, cost_140hp, cost_160hp

public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)

register_clcmd("say /hpshop", "show_menu_buy_hp")
register_clcmd("say_team /hpshop", "show_menu_buy_hp")

register_logevent("Event_Round_Start", 2, "1=Round_Start")

cost_40hp = register_cvar("hs_40hp_cost", "2000")
cost_60hp = register_cvar("hs_60hp_cost", "4000")
cost_80hp = register_cvar("hs_80hp_cost", "6000")
cost_100hp = register_cvar("hs_100hp_cost", "8000")
cost_120hp = register_cvar("hs_120hp_cost", "10000")
cost_140hp = register_cvar("hs_140hp_cost", "12000")
cost_160hp = register_cvar("hs_160hp_cost", "14000")
}

public show_menu_buy_hp(id)
{
new user_health = get_user_health(id)

if(user_health >= maxHP) {
client_print(id, print_chat, "Недоступно. У вас максимальное кол-во HP")
return
} else {
new menu = menu_create("\rHealth Shop", "handle_buy_hp_menu")

formatex(health40, 199, "+40 Health - $%d", get_pcvar_num(cost_40hp))
menu_additem(menu, health40, "1")

formatex(health60, 199, "+60 Health - $%d", get_pcvar_num(cost_60hp))
menu_additem(menu, health60, "2")

formatex(health80, 199, "+80 Health - $%d", get_pcvar_num(cost_80hp))
menu_additem(menu, health80, "3")

formatex(health100, 199, "+100 Health - $%d", get_pcvar_num(cost_100hp))
menu_additem(menu, health100, "4")

formatex(health120, 199, "+120 Health - $%d", get_pcvar_num(cost_120hp))
menu_additem(menu, health120, "5")

formatex(health140, 199, "+140 Health - $%d", get_pcvar_num(cost_140hp))
menu_additem(menu, health140, "6")

formatex(health160, 199, "+160 Health - $%d", get_pcvar_num(cost_160hp))
menu_additem(menu, health160, "7")

menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, menu, 0)
}
}

public handle_buy_hp_menu(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}

new Data[6];
new Access;
new Callback;
new Name[64];
menu_item_getinfo(menu, item, Access, Data, 5, Name, 63, Callback)

new Key = str_to_num(Data);

switch (Key)
{
case 1:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_40hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +40 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, ((Health += 40) > maxHP)?maxHP:Health)
}
}

case 2:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_60hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +60 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, ((Health += 60) > maxHP)?maxHP:Health)
}
}

case 3:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_80hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +80 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, ((Health += 80) > maxHP)?maxHP:Health)
}
}

case 4:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_100hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +100 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, ((Health += 100) > maxHP)?maxHP:Health)
}
}

case 5:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_120hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +120 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, ((Health += 120) > maxHP)?maxHP:Health)
}
}

case 6:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_140hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +140 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, ((Health += 140) > maxHP)?maxHP:Health)
}
}

case 7:
{
if (!is_user_alive(id))
{
client_print(id, print_chat, "You Have To Be Alive To Buy Health")
return PLUGIN_HANDLED
}

new Money = fm_get_user_money(id)
new Pcvar = get_pcvar_num(cost_160hp)
new Health = get_user_health(id)

if (Money < Pcvar)
{
client_print(id, print_chat, "You don't have enough money to buy this")
}
else
{
client_print(id, print_chat, "You just purchared +160 HP")
fm_set_user_money(id, Money-Pcvar)
fm_set_user_health (id, ((Health += 160) > maxHP)?maxHP:Health)
}
}
}
menu_destroy(menu)
return PLUGIN_HANDLED
}

public Event_Round_Start()
{
client_print(0, print_chat, "To Open Up Health Shop, Type /hpshop in chat")
}

stock fm_set_user_health(index, health)
{
health > 0 ? set_pev(index, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, index)
return 1
}

stock fm_get_user_money(index)
{
return get_pdata_int(index, FM_MONEY_OFFSET)
}

stock fm_set_user_money(index, money, flash = 1)
{
set_pdata_int(index, FM_MONEY_OFFSET, money);

message_begin(MSG_ONE, get_user_msgid("Money"), _, index);
write_long(money);
write_byte(flash ? 1 : 0);
message_end();
}
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
Поблагодарили 1 раз
   + Цитировать сообщение
binky
сообщение 16.5.2014, 20:34
Сообщение #18
Стаж: 12 лет

Сообщений: 381
Благодарностей: 24
Полезность: 0

Спасибо за помощь. Это похоже!


Последняя хотелка - можно ли сделать, чтобы в начале следующего раунда количество НР не сбрасывалось на 100, если оно было больше 100.
Например, в предыдущем раунде я купил +100НР и всего у меня было 200НР. К концу раунда у меня осталось 145НР. Так вот я хочу, чтобы новый раунд начинался с моих 145НР, а не со 100НР. Такое возможно?
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя GOOD FELLOW
сообщение 16.5.2014, 21:20
Сообщение #19


Иконка группы

Стаж: 13 лет

Сообщений: 2294
Благодарностей: 1187
Полезность: 890

Возможно:) но я хз как:)
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Vlad
сообщение 16.5.2014, 21:37
Сообщение #20


Стаж: 14 лет

Сообщений: 246
Благодарностей: 102
Полезность: 505

Мой вариант с максимум хп, не позволял во время игры докупать хп.
Есть старт раунда на старте раунда определенное кол-во денег и человек покупает максимум хп себе сколько может и ему больше не нужно покупать его(зачем покупать 2 раза по 50 если можно купить разом все?)
Смысл того что сделал я что бы те у кого денег много(хорошо играют) не могли докупать хп во время игры набив денег и при этом не становиться бессметными.

Отредактировал: Vladddd, - 16.5.2014, 21:44
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
Поблагодарили 1 раз
   + Цитировать сообщение
2 страниц V   1 2
 
Ответить в данную темуНачать новую тему
 
0 пользователей и 1 гостей читают эту тему: