Help
Hai guys =D i need some help with this code. its an hnsshop code. i want to buy several times per round the shop stuffs but i cant.
can u help me??
Code:
#include <amxmodx>
#include <cstrike>
#include <engine>
#include <fakemeta_util>
#include <fun>
#include <hamsandwich>
#include <chatcolor>
#define PLUGIN "HNS Shop"
#define AUTHOR "Shadow"
#define VERSION "0.1"
new healthammount, healthcost;
new armorammount, armorcost;
new hecost, flashcost, frostcost;
new deaglecost, awpcost;
new respawncost;
new stealthcost, speedcost;
new userhealth[33], userarmor[33], userhe[33], userflash[33], userfrost[33], userdeagle[33], userawp[33];
new userrespawn[33], userstealth[33], userspeed[33];
new hasspeed[33];
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd( "say /shop", "hns_shop" )
register_clcmd( "say_team /shop", "hns_shop" )
register_clcmd( "say /hnsshop", "hns_shop" )
register_clcmd( "say_team /hnsshop", "hns_shop" )
// tasks
set_task( 150.0, "advertisement",_,_,_, "b" );
// events
register_event("DeathMsg", "eDeath", "a");
register_event("CurWeapon", "speed_on", "be");
// shop cvars
healthammount = register_cvar( "shop_healthammount", "100" )
healthcost = register_cvar( "shop_healthcost", "5000" )
armorammount = register_cvar( "shop_armorammount", "100" )
armorcost = register_cvar( "shop_armorcost", "5000" )
hecost = register_cvar( "shop_hecost", "12000" )
flashcost = register_cvar( "shop_flashcost", "4000" )
frostcost = register_cvar( "shop_frostcost", "4000" )
deaglecost = register_cvar( "shop_deaglecost", "16000" )
awpcost = register_cvar( "shop_awpcost", "16000" )
respawncost = register_cvar( "shop_respawncost", "16000" )
stealthcost = register_cvar( "shop_stealthcost", "8000" )
speedcost = register_cvar( "shop_speedcost", "8000" )
}
public advertisement()
{
new g_Maxplayers;
g_Maxplayers = get_maxplayers();
for(new i=1; i<=g_Maxplayers; i++)
{
if(is_user_connected(i))
{
client_print_color( i, Red, "^4[Shop] This server is using a custom^3 Hide'n'Seek Shop,^4 Type^3 /hnsshop^4 or^3 /shop");
}
}
}
public client_connect( id )
{
userhealth[id] =0;
userarmor[id] =0;
userhe[id] =0;
userflash[id] =0;
userfrost[id] =0;
userdeagle[id] =0;
userawp[id] =0;
userstealth[id] =0;
userspeed[id] =0;
hasspeed[id] =0;
}
public client_disconnect( id )
{
userhealth[id] =0;
userarmor[id] =0;
userhe[id] =0;
userflash[id] =0;
userfrost[id] =0;
userdeagle[id] =0;
userawp[id] =0;
userstealth[id] =0;
userspeed[id] =0;
hasspeed[id] =0;
}
public eDeath( id )
{
new victim = read_data(2);
userhealth[victim] =0;
userarmor[victim] =0;
userhe[victim] =0;
userflash[victim] =0;
userfrost[victim] =0;
userdeagle[victim] =0;
userawp[victim] =0;
userstealth[victim] =0;
userspeed[victim] =0;
hasspeed[victim] =0;
}
public hns_shop( id )
{
if( cs_get_user_team( id ) == CS_TEAM_T )
{
new szShop[64], szHealth[32], szArmor[32], szHE[32], szFlash[32], szFrost[32], szDeagle[42], szAwp[42], szRespawn[32];
new szStealth[32], szSpeed[32];
formatex( szShop, charsmax( szShop ), "\r[Shop] \wHide'N'Seek Shop^n\rYour cash: \y$%d", cs_get_user_money( id ) );
formatex( szHealth, charsmax( szHealth ), "%d HP \rCost: $%d", get_pcvar_num( healthammount ), get_pcvar_num( healthcost ) );
formatex( szArmor, charsmax( szArmor ), "%d Armor \rCost: $%d", get_pcvar_num( armorammount ), get_pcvar_num( armorcost ) );
formatex( szHE, charsmax( szHE ), "HE Grenade \rCost: $%d", get_pcvar_num( hecost ) );
formatex( szFlash, charsmax( szFlash ), "Flash Grenade \rCost: $%d", get_pcvar_num( flashcost ) );
formatex( szFrost, charsmax( szFrost ), "Frost Grenade \rCost: $%d", get_pcvar_num( frostcost ) );
formatex( szDeagle, charsmax( szDeagle ), "Deagle \rCost: $%d", get_pcvar_num( deaglecost ) );
formatex( szAwp, charsmax( szAwp ), "Awp \rCost: $%d", get_pcvar_num( awpcost ) );
formatex( szRespawn, charsmax( szRespawn ), "Respawn \rCost: $%d", get_pcvar_num( respawncost ) );
formatex( szStealth, charsmax( szStealth ), "Stealth (20 Sec) \rCost: $%d", get_pcvar_num( stealthcost ) );
formatex( szSpeed, charsmax( szSpeed ), "Speed (20 Sec) \rCost: $%d", get_pcvar_num( speedcost ) );
new shop = menu_create( szShop, "tshop_handler" );
menu_additem( shop, szHealth, "1", 0 );
menu_additem( shop, szArmor, "2", 0 );
menu_additem( shop, szHE, "3", 0 );
menu_additem( shop, szFlash, "4", 0 );
menu_additem( shop, szFrost, "5", 0 );
menu_additem( shop, szDeagle, "6", 0 );
menu_additem( shop, szAwp, "7", 0 );
menu_additem( shop, szRespawn, "8", 0 )
menu_additem( shop, szStealth, "9", 0 )
menu_additem( shop, szSpeed, "10", 0 )
menu_setprop( shop, MPROP_EXIT, MEXIT_ALL );
menu_display( id, shop, 0 );
}
if( cs_get_user_team( id ) == CS_TEAM_CT )
{
new szShop[64], szHealth[32], szArmor[32], szHE[32], szStealth[32], szSpeed[32], szRespawn[32];
formatex( szShop, charsmax( szShop ), "\yHide'N'Seek Shop^n\rYour cash: \w$%d", cs_get_user_money( id ) );
formatex( szHealth, charsmax( szHealth ), "%d HP \rCost: $%d", get_pcvar_num( healthammount ), get_pcvar_num( healthcost ) );
formatex( szArmor, charsmax( szArmor ), "%d Armor \rCost: $%d", get_pcvar_num( armorammount ), get_pcvar_num( armorcost ) );
formatex( szHE, charsmax( szHE ), "HE Grenade \rCost: $%d", get_pcvar_num( hecost ) );
formatex( szStealth, charsmax( szStealth ), "Stealth (20 Sec) \rCost: $%d", get_pcvar_num( stealthcost ) );
formatex( szSpeed, charsmax( szSpeed ), "Speed (20 Sec) \rCost: $%d", get_pcvar_num( speedcost ) );
formatex( szRespawn, charsmax( szRespawn ), "Respawn \rCost: $%d", get_pcvar_num( respawncost ) );
new shop = menu_create( szShop, "ctshop_handler" );
menu_additem( shop, szHealth, "1", 0 );
menu_additem( shop, szArmor, "2", 0 );
menu_additem( shop, szHE, "3", 0 );
menu_additem( shop, szStealth, "4", 0 )
menu_additem( shop, szSpeed, "5", 0 )
menu_additem( shop, szRespawn, "6", 0 )
menu_setprop( shop, MPROP_EXIT, MEXIT_ALL );
menu_display( id, shop, 0 );
}
}
public tshop_handler( id, shop, item )
{
if( item == MENU_EXIT )
{
menu_destroy( shop );
return PLUGIN_HANDLED;
}
new data[6], iName[64];
new access, callback;
menu_item_getinfo( shop, item, access, data, 6, iName, 63, callback )
new key = str_to_num( data );
switch( key )
{
case 1: // health
{
if( !is_user_alive( id ) )
{
client_print_color( id, Blue,"^4[Shop]^3 You cannot buy items when your dead!" );
return PLUGIN_HANDLED;
}
if(userhealth[id] > 0)
{
client_print_color( id, Blue, "^4[Shop]^3 You've already bought this before!" );
return PLUGIN_HANDLED;
}
new money = cs_get_user_money( id )
new cost = get_pcvar_num( healthcost )
if( money >= cost )
{
cs_set_user_money( id, money - cost )
new userhp = get_user_health( id )
new health = get_pcvar_num( healthammount )
fm_set_user_health( id, userhp + health )
userhealth[id]++;
client_cmd( id, "spk items/medshot4" )
client_print_color( id, Red, "^4[Shop] You've bought^3 %d Health!", get_pcvar_num( healthammount ) )
} else {
client_print_color( id, Red, "^4[Shop] You need more money to buy^3 %d Health!", get_pcvar_num( healthammount ) )
}
}
case 2: // armor
{
if( !is_user_alive( id ) )
{
client_print_color( id, Blue,"^4[Shop]^3 You cannot buy items when your dead!" );
return PLUGIN_HANDLED;
}
if(userarmor[id] > 0)
{
client_print_color( id, Blue, "^4[Shop]^3 You've already bought this before!" );
return PLUGIN_HANDLED;
}
new money = cs_get_user_money( id )
new cost = get_pcvar_num( armorcost )
if( money >= cost )
{
cs_set_user_money( id, money - cost )
new playerarmor = get_user_armor( id )
new armor = get_pcvar_num( armorammount )
fm_set_user_armor( id, playerarmor + armor )
userarmor[id]++;
client_print_color( id, Red, "^4[Shop] You've bought^3 %d Armor!", get_pcvar_num( armorammount ) )
} else {
client_print_color( id, Red, "^4[Shop] You need more money to buy^3 %d Armor!", get_pcvar_num( armorammount ) )
}
}
case 3: // he grenade
{
if( !is_user_alive( id ) )
{
client_print_color( id, Blue,"^4[Shop]^3 You cannot buy items when your dead." );
return PLUGIN_HANDLED;
}
if(userhe[id] > 0)
{
client_print_color( id, Blue, "^4[Shop]^3 You've already bought this before." );
return PLUGIN_HANDLED;
}
new money = cs_get_user_money( id )
new cost = get_pcvar_num( hecost )
if( money >= cost )
{
cs_set_user_money( id, money - cost )
fm_give_item( id, "weapon_hegrenade" )
userhe[id]++;
client_print_color( id, Red, "^4[Shop] You've bought a^3 HE Grenade!" )
} else {
client_print_color( id, Red, "^4[Shop] You need more money to buy a^3 HE Grenade!" )
}
}
case 4: // flash grenade
{
if( !is_user_alive( id ) )
{
client_print_color( id, Blue,"^4[Shop]^3 You cannot buy items when your dead." );
return PLUGIN_HANDLED;
}
if(userflash[id] > 0)
{
client_print_color( id, Blue, "^4[Shop]^3 You've already bought this before." );
return PLUGIN_HANDLED;
}
new money = cs_get_user_money( id )
new cost = get_pcvar_num( flashcost )
if( money >= cost && cs_get_user_team( id ) == CS_TEAM_T )
{
cs_set_user_money( id, money - cost )
fm_give_item( id, "weapon_flashbang" )
userflash[id]++;
client_print_color( id, Red, "^4[Shop] You've bought a^3 Flash Grenade!" )
} else {
client_print_color( id, Red, "^4[Shop] You need more money to buy a^3 Flash Grenade!" )
}
}
case 5: // frost grenade
{
if( !is_user_alive( id ) )
{
client_print_color( id, Blue,"^4[Shop]^3 You cannot buy items when your dead." );
return PLUGIN_HANDLED;
}
if(userfrost[id] > 0)
{
client_print_color( id, Blue, "^4[Shop]^3 You've already bought this before." );
return PLUGIN_HANDLED;
}
new money = cs_get_user_money( id )
new cost = get_pcvar_num( frostcost )
if( money >= cost )
{
cs_set_user_money( id, money - cost )
fm_give_item( id, "weapon_smokegrenade" )
userfrost[id]++;
client_print_color( id, Red, "^4[Shop] You've bought a^3 Frost Grenade!" )
} else {
client_print_color( id, Red, "^4[Shop] You need more money to buy a^3 Frost Grenade!" )
}
}
case 6: // deagle
{
if( !is_user_alive( id ) )
{
client_print_color( id, Blue,"^4[Shop]^3 You cannot buy items when your dead." );
return PLUGIN_HANDLED;
}
if(userdeagle[id] > 0)
{
client_print_color( id, Blue, "^4[Shop]^3 You've already bought this before." );
return PLUGIN_HANDLED;
}
new money = cs_get_user_money( id )
new cost = get_pcvar_num( deaglecost )
if( money >= cost )
{
cs_set_user_money( id, money - cost )
fm_give_item( id, "weapon_deagle" )
cs_set_weapon_ammo( find_ent_by_owner( 1, "weapon_deagle", id ), 1 )
new deaglename[42]
get_user_name(id, deaglename, 32)
set_hudmessage(255, 255, 255, -1.0, -1.0, 0, 6.0, 4.0)
show_hudmessage(0, "%s bought a Deagle! Watch out!", deaglename)
userdeagle[id]++;
client_print_color( id, Red, "^4[Shop] You've bought a^3 Deagle!" )
} else {
client_print_color( id, Red, "^4[Shop] You need more money to buy a^3 Deagle!" )
}
}
case 7: // awp
{
if( !is_user_alive( id ) )
{
client_print_color( id, Blue,"^4[Shop]^3 You cannot buy items when your dead." );
return PLUGIN_HANDLED;
}
if(userawp[id] > 0)
{
client_print_color( id, Blue, "^4[Shop]^3 You've already bought this before." );
return PLUGIN_HANDLED;
}
new money = cs_get_user_money( id )
new cost = get_pcvar_num( awpcost )
if( money >= cost )
{
cs_set_user_money( id, money - cost )
fm_give_item( id, "weapon_awp" )
cs_set_weapon_ammo( find_ent_by_owner( 1, "weapon_awp", id ), 1 )
new awpname[42]
get_user_name(id, awpname, 32)
set_hudmessage(255, 255, 255, -1.0, -1.0, 0, 6.0, 4.0)
show_hudmessage(0, "%s bought an Awp! Watch out!", awpname)
userawp[id]++;
client_print_color( id, Red, "^4[Shop] You've bought an^3 Awp!" )
} else {
client_print_color( id, Red, "^4[Shop] You need more money to buy an^3 Awp!" )
}
}
case 8: // respawn
{
if(userrespawn[id] > 0)
{
client_print_color( id, Red, "^4[Shop] You cannot buy a^3 Respawn^4 more than once per map." );
return PLUGIN_HANDLED;
}
new money = cs_get_user_money( id )
new cost = get_pcvar_num( respawncost )
if( money >= cost )
{
cs_set_user_money( id, money - cost )
ExecuteHamB(Ham_CS_RoundRespawn, id);
new respawnname[42]
get_user_name(id, respawnname, 32)
set_hudmessage(255, 255, 255, -1.0, -1.0, 0, 6.0, 4.0)
show_hudmessage(0, "%s bought a respawn! Kill him!", respawnname)
userrespawn[id]++;
client_print_color( id, Red, "^4[Shop] You've bought a^3 Respawn!" )
} else {
client_print_color( id, Red, "^4[Shop] You need more money to buy a^3 Respawn!" )
}
}
case 9: // stealth
{
if( !is_user_alive( id ) )
{
client_print_color( id, Blue,"^4[Shop]^3 You cannot buy items when your dead." );
return PLUGIN_HANDLED;
}
if(userstealth[id] > 0)
{
client_print_color( id, Blue, "^4[Shop]^3 You've already bought this before." );
return PLUGIN_HANDLED;
}
new money = cs_get_user_money( id )
new cost = get_pcvar_num( stealthcost )
if( money >= cost )
{
cs_set_user_money( id, money - cost )
fm_set_user_rendering( id, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 15 );
set_task( 20.0, "remove_stealth", id );
userstealth[id]++;
client_print_color( id, Red, "^4[Shop] You've bought^3 Stealth^4 for 20 seconds!" )
} else {
client_print_color( id, Red, "^4[Shop] You need more money to buy^3 Stealth!" )
}
}
case 10: // speed
{
if( !is_user_alive( id ) )
{
client_print_color( id, Blue,"^4[Shop]^3 You cannot buy items when your dead." );
return PLUGIN_HANDLED;
}
if(userspeed[id] > 0)
{
client_print_color( id, Blue, "^4[Shop]^3 You've already bought this before." );
return PLUGIN_HANDLED;
}
new money = cs_get_user_money( id )
new cost = get_pcvar_num( speedcost )
if( money >= cost )
{
cs_set_user_money( id, money - cost )
fm_set_user_maxspeed( id, 400.0 )
set_task( 20.0, "remove_speed", id );
userspeed[id]++;
client_print_color( id, Red, "^4[Shop] You've bought^3 Speed^4 for 20 seconds!" )
} else {
client_print_color( id, Red, "^4[Shop] You need more money to buy^3 Speed!" )
}
}
}
menu_destroy( shop );
return PLUGIN_HANDLED;
}
public ctshop_handler( id, shop, item )
{
if( item == MENU_EXIT )
{
menu_destroy( shop );
return PLUGIN_HANDLED;
}
new data[6], iName[64];
new access, callback;
menu_item_getinfo( shop, item, access, data, 6, iName, 63, callback )
new key = str_to_num( data );
switch( key )
{
case 1: // health
{
if( !is_user_alive( id ) )
{
client_print_color( id, Blue,"^4[Shop]^3 You cannot buy items when your dead." );
return PLUGIN_HANDLED;
}
if(userhealth[id] > 0)
{
client_print_color( id, Blue, "^4[Shop]^3 You've already bought this before." );
return PLUGIN_HANDLED;
}
new money = cs_get_user_money( id )
new cost = get_pcvar_num( healthcost )
if( money >= cost )
{
cs_set_user_money( id, money - cost )
new userhp = get_user_health( id )
new health = get_pcvar_num( healthammount )
fm_set_user_health( id, userhp + health )
client_cmd( id, "spk items/medshot4" )
userhealth[id]++;
client_print_color( id, Red, "^4[Shop] You've bought^3 %d Health!", get_pcvar_num( healthammount ) )
} else {
client_print_color( id, Red, "^4[Shop] You need more money to buy^3 %d Health!", get_pcvar_num( healthammount ) )
}
}
case 2: // armor
{
if( !is_user_alive( id ) )
{
client_print_color( id, Blue,"^4[Shop]^3 You cannot buy items when your dead." );
return PLUGIN_HANDLED;
}
if(userarmor[id] > 0)
{
client_print_color( id, Blue, "^4[Shop]^3 You've already bought this before." );
return PLUGIN_HANDLED;
}
new money = cs_get_user_money( id )
new cost = get_pcvar_num( armorcost )
if( money >= cost )
{
cs_set_user_money( id, money - cost )
new playerarmor = get_user_armor( id )
new armor = get_pcvar_num( armorammount )
fm_set_user_armor( id, playerarmor + armor )
userarmor[id]++;
client_print_color( id, Red, "^4[Shop] You've bought^3 %d Armor!", get_pcvar_num( armorammount ) )
} else {
client_print_color( id, Red, "^4[Shop] You need more money to buy^3 %d Armor!", get_pcvar_num( armorammount ) )
}
}
case 3: // he grenade
{
if( !is_user_alive( id ) )
{
client_print_color( id, Blue,"^4[Shop]^3 You cannot buy items when your dead." );
return PLUGIN_HANDLED;
}
if(userhe[id] > 0)
{
client_print_color( id, Blue, "^4[Shop]^3 You've already bought this before." );
return PLUGIN_HANDLED;
}
new money = cs_get_user_money( id )
new cost = get_pcvar_num( hecost )
if( money >= cost )
{
cs_set_user_money( id, money - cost )
fm_give_item( id, "weapon_hegrenade" )
userhe[id]++;
client_print_color( id, Red, "^4[Shop] You've bought a^3 HE Grenade!" )
} else {
client_print_color( id, Red, "^4[Shop] You need more money to buy a^3 HE Grenade!" )
}
}
case 4: // stealth
{
if( !is_user_alive( id ) )
{
client_print_color( id, Blue,"^4[Shop]^3 You cannot buy items when your dead." );
return PLUGIN_HANDLED;
}
if(userstealth[id] > 0)
{
client_print_color( id, Blue, "^4[Shop]^3 You've already bought this before." );
return PLUGIN_HANDLED;
}
new money = cs_get_user_money( id )
new cost = get_pcvar_num( stealthcost )
if( money >= cost )
{
cs_set_user_money( id, money - cost )
fm_set_user_rendering( id, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 15 );
set_task( 20.0, "remove_stealth", id );
userstealth[id]++;
client_print_color( id, Red, "^4[Shop] You've bought^3 Stealth^4 for 20 seconds!" )
} else {
client_print_color( id, Red, "^4[Shop] You need more money to buy^3 Stealth!" )
}
}
case 5: // speed
{
if( !is_user_alive( id ) )
{
client_print_color( id, Blue,"^4[Shop]^3 You cannot buy items when your dead." );
return PLUGIN_HANDLED;
}
if( userspeed[id] > 0 )
{
client_print_color( id, Blue, "^4[Shop]^3 You've already bought this before." );
return PLUGIN_HANDLED;
}
new money = cs_get_user_money( id )
new cost = get_pcvar_num( speedcost )
if( money >= cost )
{
cs_set_user_money( id, money - cost )
fm_set_user_maxspeed( id, 400.0 )
set_task( 20.0, "remove_speed", id )
userspeed[id]++
hasspeed[id]++
client_print_color( id, Red, "^4[Shop] You've bought^3 Speed^4 for 20 seconds!" )
} else {
client_print_color( id, Red, "^4[Shop] You need more money to buy^3 Speed!" )
}
}
case 6:
{
if(userrespawn[id] > 0)
{
client_print_color( id, Blue, "^4[Shop] You cannot buy a^3 Respawn^4 more than once per map." );
return PLUGIN_HANDLED;
}
new money = cs_get_user_money( id )
new cost = get_pcvar_num( respawncost )
if( money >= cost )
{
cs_set_user_money( id, money - cost )
ExecuteHamB(Ham_CS_RoundRespawn, id);
new respawnname[42]
get_user_name(id, respawnname, 32)
set_hudmessage(255, 255, 255, -1.0, -1.0, 0, 6.0, 4.0)
show_hudmessage(0, "%s bought a respawn! Kill him!", respawnname)
userrespawn[id]++;
client_print_color( id, Red, "^4[Shop] You have bought a^3 Respawn!" )
} else {
client_print_color( id, Red, "^4[Shop] You need more money to buy a^3 Respawn!" )
}
}
}
menu_destroy( shop );
return PLUGIN_HANDLED;
}
// remove stealth
public remove_stealth( id )
{
fm_set_user_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 255);
client_print_color( id, Red, "^4[Shop] You are now^3 visible.");
}
// give speed
public speed_on( id )
{
if(is_user_alive( id ) )
{
if( hasspeed[id] )
{
fm_set_user_maxspeed( id, 400.0 );
}
}
}
// remove speed
public remove_speed( id )
{
fm_set_user_maxspeed( id, 250.0 );
hasspeed[id] = 0;
client_print_color( id, Red, "^4[Shop] You're34 speed^4 is now normal.");
}
|