PHP Code:
#include <amxmodx>
#include <fakemeta>
#define OFFSET_MONEY 115
#define OFFSET_LINUX 5
#define SLOT ADMIN_RESERVATION
#define VIP ADMIN_LEVEL_B
#define LITEVIP ADMIN_LEVEL_C
#define FULLVIP ADMIN_LEVEL_E
#define MINIADMIN ADMIN_LEVEL_F
#define ADMIN ADMIN_LEVEL_G
#define HEAD ADMIN_LEVEL_H
new PLUGIN [] = "Buy Access"
new VERSION [] = "1.1"
new AUTHOR [] = "M1R0n,M'"
new bool:g_Bought[33];
new MenuBuy;
new g_Status;
new g_SlotCost;
new g_VipCost;
new g_LitevipCost;
new g_FullvipCost;
new g_MiniadminCost;
new g_AdminCost;
new g_HeadCost;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_clcmd("say /shop", "show_buymenu");
register_clcmd("say shop", "show_buymenu");
register_clcmd("say_team /shop","show_buymenu");
register_clcmd("say_team shop", "show_buymenu");
MenuBuy = register_menuid("Access Shop");
register_menucmd(MenuBuy, 1023, "pshop");
register_dictionary("vipaccess.txt");
g_Status = register_cvar( "amx_buy_access", "1" );
g_SlotCost = register_cvar( "amx_buy_slot", "1500" );
g_VipCost = register_cvar( "amx_buy_vip", "3000" );
g_LitevipCost = register_cvar( "amx_buy_litevip", "17000" );
g_FullvipCost = register_cvar( "amx_buy_fullvip", "19000" );
g_MiniadminCost = register_cvar( "amx_buy_miniadmin", "21000" );
g_AdminCost = register_cvar( "amx_buy_admin", "25000" );
g_AdminCost = register_cvar( "amx_buy_head", "50000" );
}
public show_buymenu(id)
{
if(get_pcvar_num(g_Status) == 1)
{
new iBuffer[512], iLen;
iLen = formatex(iBuffer, 511, "\w%L^n", id, "MENU_TITLE");
iLen += formatex(iBuffer[iLen], 511-iLen, "\r1\y. \w%L \y- \r%d$^n", id, "MENU_SLOT", get_pcvar_num(g_SlotCost));
iLen += formatex(iBuffer[iLen], 511-iLen, "\r2\y. \w%L \y- \r%d$^n", id, "MENU_VIP", get_pcvar_num(g_VipCost));
iLen += formatex(iBuffer[iLen], 511-iLen, "\r3\y. \w%L \y- \r%d$^n", id, "MENU_LITEVIP", get_pcvar_num(g_LitevipCost));
iLen += formatex(iBuffer[iLen], 511-iLen, "\r4\y. \w%L \y- \r%d$^n", id, "MENU_FULLVIP", get_pcvar_num(g_FullvipCost));
iLen += formatex(iBuffer[iLen], 511-iLen, "\r5\y. \w%L \y- \r%d$^n", id, "MENU_MINIADMIN", get_pcvar_num(g_MiniadminCost));
iLen += formatex(iBuffer[iLen], 511-iLen, "\r6\y. \w%L \y- \r%d$^n", id, "MENU_ADMIN", get_pcvar_num(g_AdminCost));
iLen += formatex(iBuffer[iLen], 511-iLen, "\r6\y. \w%L \y- \r%d$^n", id, "MENU_HEAD", get_pcvar_num(g_HeadCost));
iLen += formatex(iBuffer[iLen], 511-iLen, "\r0\y. \w%L", id, "MENU_EXIT");
new iKeys = ( 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7 | 1<< 8 | 1<<9 );
show_menu(id, iKeys, iBuffer, -1, "Access Shop");
}
else
client_print(id, print_chat, "%L", id, "BUYOFF");
return PLUGIN_HANDLED;
}
public pshop(id,key)
{
switch(key)
{
case 0:
{
if (g_Bought[id])
return;
new money = fm_get_user_money(id);
new costa = get_pcvar_num(g_SlotCost);
if( money >= costa )
{
set_user_flags(id, get_user_flags(id) | SLOT);
fm_set_user_money(id, money - costa );
client_print(id, print_chat, "%L", id, "BUY_SLOT");
g_Bought[id] = true
}
else
{
client_print(id, print_chat, "%L", id, "NOMONEY");
}
}
case 1:
{
new money = fm_get_user_money(id);
new costa = get_pcvar_num(g_VipCost);
if( money >= costa )
{
set_user_flags(id, get_user_flags(id) | VIP);
fm_set_user_money(id, money - costa );
client_print(id, print_chat, "%L", id, "BUY_VIP");
g_Bought[id] = true
}
else
{
client_print(id, print_chat, "%L", id, "NOMONEY");
}
}
case 2:
{
new money = fm_get_user_money(id);
new costa = get_pcvar_num(g_LitevipCost);
if( money >= costa )
{
set_user_flags(id, get_user_flags(id) | LITEVIP);
fm_set_user_money(id, money - costa );
client_print(id, print_chat, "%L", id, "BUY_LITEVIP");
g_Bought[id] = true
}
else
{
client_print(id, print_chat, "%L", id, "NOMONEY");
}
}
case 3:
{
new money = fm_get_user_money(id);
new costa = get_pcvar_num(g_FullvipCost);
if( money >= costa )
{
set_user_flags(id, get_user_flags(id) | FULLVIP);
fm_set_user_money(id, money - costa );
client_print(id, print_chat, "%L", id, "BUY_FULLVIP");
g_Bought[id] = true
}
else
{
client_print(id, print_chat, "%L", id, "NOMONEY");
}
}
case 4:
{
new money = fm_get_user_money(id);
new costa = get_pcvar_num(g_MiniadminCost);
if( money >= costa )
{
set_user_flags(id, get_user_flags(id) | MINIADMIN);
fm_set_user_money(id, money - costa );
client_print(id, print_chat, "%L", id, "BUY_MINIADMIN");
g_Bought[id] = true
}
else
{
client_print(id, print_chat, "%L", id, "NOMONEY");
}
}
case 5:
{
new money = fm_get_user_money(id);
new costa = get_pcvar_num(g_AdminCost);
if( money >= costa )
{
set_user_flags(id, get_user_flags(id) | ADMIN);
fm_set_user_money(id, money - costa );
client_print(id, print_chat, "%L", id, "BUY_ADMIN");
g_Bought[id] = true
}
else
{
client_print(id, print_chat, "%L", id, "NOMONEY");
}
}
case 6:
{
new money = fm_get_user_money(id);
new costa = get_pcvar_num(g_HeadCost);
if( money >= costa )
{
set_user_flags(id, get_user_flags(id) | HEAD);
fm_set_user_money(id, money - costa );
client_print(id, print_chat, "%L", id, "BUY_HEAD");
g_Bought[id] = true
}
else
{
client_print(id, print_chat, "%L", id, "NOMONEY");
}
}
}
}
fm_set_user_money(iPlrId, iMoney, iFlash=1)
{
set_pdata_int(iPlrId, OFFSET_MONEY, iMoney, OFFSET_LINUX);
static s_iMsgId_Money;
if( !s_iMsgId_Money )
s_iMsgId_Money = get_user_msgid("Money");
message_begin(MSG_ONE, s_iMsgId_Money, {0,0,0}, iPlrId)
write_long(iMoney);
write_byte(iFlash);
message_end();
}
stock fm_get_user_money(index)
{
return get_pdata_int(index, OFFSET_MONEY, OFFSET_LINUX);
}