Request for create sniper shop

Сообщения
30
Реакции
3
Привет всем
Chat command /sniper
1. AWP [220$]
2. Scout [130$]
3. SG550 [260$]
4. G3SG1 [300$]
For players with flag "b" 25% discount for shop.
Here is example screen
Спасибо за внимание.
 

Вложения

Сообщения
2,751
Реакции
3,016
Помог
61 раз(а)
Написал вам плагин. Проверяйте.
upload_2017-4-30_13-34-46.png

AMXXPlugins/Sniper_Shop.sma at master · wopox1337/AMXXPlugins · GitHub
Код:
/* The flag to give the discount */
new const FLAGS_FOR_DISCOUNT[] = "b";
/* Size of discount in percent */
const PERCENT_TO_DISCOUNT = 25;



#include <amxmodx>
#include <amxmisc>
#include <reapi>

const bitsKeys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0;
#define PercentSub(%1,%2) (%1 - (%1 * %2) / 100)

new bool: g_bMenu_Used[MAX_CLIENTS];
new g_ibitsFlagsToDiscount;

public plugin_init()
{
register_plugin("Sniper Shop", "0.0.4f", "Dev-CS.ru Team");

RegisterHookChain(
RG_CSGameRules_RestartRound,
"CSGameRules_RestartRound",
.post = true
);

RegisterHookChain(
RH_SV_DropClient,
"SV_DropClient",
.post = true
);

RegisterHookChain(
RG_CBasePlayer_Killed,
"CBasePlayer_Killed",
.post = true
);

/* Commands to open Snipers menu */
new const CMDS[][] =
{
"say /sniper",
"say_team /sniper",
"/sniper"
}

for(new i; i < sizeof CMDS; i++)
{
register_clcmd(CMDS, "ShowMenu_ChooseSnipers");
}

register_menu("Menu_ChooseSnipers", bitsKeys , "MenuHandler_ChooseSnipers");

g_ibitsFlagsToDiscount = read_flags(FLAGS_FOR_DISCOUNT);
}

enum _:WEAPON_DATA_s { szMenuItemName[32], iCost, szClassname[32] }

/**
Allowed weapons in menu
Format:
[ Name - Cost - Classname item ]
*/
new const WeaponsArray[][WEAPON_DATA_s] =
{
{ "AWP", 220, "weapon_awp" }
,{ "Scout", 130, "weapon_scout" }
,{ "SG550", 260, "weapon_sg550" }
,{ "G3SG1", 300, "weapon_g3sg1" }
}

public ShowMenu_ChooseSnipers(pPlayerId)
{
new iAccount = get_member(pPlayerId, m_iAccount);

if(!iAccount)
{
client_print(pPlayerId, print_chat, "You have no money!");
return PLUGIN_HANDLED;
}

if(g_bMenu_Used[pPlayerId])
{
client_print(pPlayerId, print_chat, "Allowed to buy only 1 time!");
return PLUGIN_HANDLED;
}

new bIsVIPPlayer = get_user_flags(pPlayerId) & g_ibitsFlagsToDiscount;

new szMenu[512], iLen, iKeys, iItem, iKeyBit;
iLen = formatex(szMenu[iLen], charsmax(szMenu), "\ySelect your sniper weapon:^n%s", bIsVIPPlayer ? "^tYou have discount!^n" : "");

for(new i; i < sizeof WeaponsArray; i++)
{
new iWeaponConst = bIsVIPPlayer ? PercentSub(WeaponsArray[iCost], PERCENT_TO_DISCOUNT) : WeaponsArray[iCost];

if(iAccount >= iWeaponConst)
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r%i.\w %s [\r%i$\w]^n", ++iItem, WeaponsArray[szMenuItemName], iWeaponConst);
iKeys |= (1 << iKeyBit);
}
else
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r%i.\d %s [\r%i$\w]^n", ++iItem, WeaponsArray[szMenuItemName], iWeaponConst);
}

++iKeyBit;
}

iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r0. \yExit");
iKeys |= MENU_KEY_0;

show_menu(pPlayerId, iKeys, szMenu, 10, "Menu_ChooseSnipers");

return PLUGIN_HANDLED;
}

public MenuHandler_ChooseSnipers(pPlayerId, key)
{
if(key >= 9)
{
return;
}

rg_give_item(pPlayerId, WeaponsArray[key][szClassname], .type = GT_DROP_AND_REPLACE);

new iWeaponConst = get_user_flags(pPlayerId) & g_ibitsFlagsToDiscount ? PercentSub(WeaponsArray[key][iCost], PERCENT_TO_DISCOUNT) : WeaponsArray[key][iCost];

rg_add_account(
pPlayerId,
-iWeaponConst,
.typeSet = AS_ADD,
.bTrackChange = true
);

g_bMenu_Used[pPlayerId] = true;
}

public CSGameRules_RestartRound()
{
arrayset(g_bMenu_Used, false, sizeof(g_bMenu_Used));
}

public SV_DropClient(pPlayerId)
{
g_bMenu_Used[pPlayerId] = false;
}

public CBasePlayer_Killed(const pPlayerId, pKillerId, iGib)
{
g_bMenu_Used[pPlayerId] = false;
}

 
Последнее редактирование:
Сообщения
30
Реакции
3
Look at the picture, money
And i want you to edit it, the player to buy only once sniper, in a round.
30 Апр 2017
Now i cant open /sniper - shop.
I'm write /sniper and show me that message "Allowed to buy only 1 time!"

My mod is Re.CSDM
30 Апр 2017
Now, im connect in server, write /sniper, shop opening, im buy Scout - success, player kill me and i cant use /sniper in next time.
I want to open shop every time, and player buying only 1 items.
 

Download all Attachments

Сообщения
2,751
Реакции
3,016
Помог
61 раз(а)
Georgi-Arts, update to 0.0.3. Check now.
Чтобы я с первого раза сделал то, что вам нужно вы должны подробно описать плагин и его действия. А не так, как сейчас вы это сделали.
 
Последнее редактирование:
Сообщения
30
Реакции
3
First, i want to say respect for your work, thanks for this plugin :)

Create version for CSDM round not ending, i want to open shop every time, but all players buyng only 1-sniper per kill.
That is.
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу