Raised This Month: $ Target: $400
 0% 

Base Builder Shop


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
ImYourBro
Senior Member
Join Date: Jun 2014
Old 07-08-2017 , 08:29   Base Builder Shop
Reply With Quote #1

Hello

I've been off for some time.

I have changed a shop code for my server, but im getting some errors.

Items in shop:
T:
- Superknife
- Speed
- Gravity

CT:
- SuperKnife
- Gravity
- Grenade
- SuperM4A1
- M249

PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <hamsandwich>
#include <fakemeta>
#include <engine>

#define NORMAL DontChange
#define GREEN DontChange
#define TEAM_COLOR DontChange
#define RED Red
#define BLUE Blue
#define GREY Grey
#define ColorChat client_print_color

#define VERSION "1.0"

#define IsPlayer(%1) ( 1 <= %1 <= g_iMaxPlayers )

#define Ham_Player_ResetMaxSpeed Ham_Item_PreFrame

#pragma semicolon 1

enum _:Colors {
   
DontChange,
   
Red,
   
Blue,
   
Grey
};

new const 
g_prefix[] = "[Zyphix]";

new const 
g_ModelSuperKnife[] = "models/zyphix/bb_shop/v_supercut.mdl";
new const 
g_ModelSuperM4A1[] = "models/zyphix/bb_shop/v_golden_deagle.mdl";

new 
bool:g_bHasSuperKnife[33],
   
bool:g_bHasSuperSpeed[33],
   
bool:g_bHasSuperM4A1[33],

new 
g_iMaxPlayers;

new 
g_pCvarCostSuperCutT,
   
g_pCvarCostSuperCutCT,
   
g_pCvarCostLowGrav,
   
g_pCvarQuantityLowGrav,
   
g_pCvarCostSpeed,
   
g_pCvarQuantitySpeed,
   
g_pCvarCostHE,
   
g_pCvarCostFlash,
   
g_pCvarCostSmoke,
   
g_pCvarCostSuperM4A1,


public 
plugin_init()
{
   
register_plugin("Base Builder Shop"VERSION"Kid");

   
register_clcmd("say /shop""ShowShop");
   
register_clcmd("say_team /shop""ShowShop");
   
register_clcmd("say shop""ShowShop");
   
register_clcmd("say_team shop""ShowShop");

   
// Cvars Mixtes
   
g_pCvarCostSuperCutT register_cvar("shopbb_supercut""10000");
   
g_pCvarCostSuperCutCT register_cvar("shopbb_supercut""800");
   
g_pCvarCostLowGrav register_cvar("shopbb_grav""8000");
   
g_pCvarQuantityLowGrav register_cvar("shopbb_quant_grav""0.150");
   
g_pCvarCostSpeed register_cvar("shopbb_speed""8000");
   
g_pCvarQuantitySpeed register_cvar("shopbb_quantity_speed""400.0");
   
   
// Cvars CT
   
g_pCvarCostHE register_cvar("shopbb_he""2500");
   
g_pCvarCostFlash register_cvar("shopbb_flash""2500");
   
g_pCvarCostSmoke register_cvar("shopbb_smoke""2500");
   
g_pCvarCostSuperM4A1 register_cvar("shopbb_super_m4a1""8000");
   
   
// Cvars T

   
RegisterHam(Ham_Spawn"player""Player_Spawn_Post"1);
   
RegisterHam(Ham_TakeDamage"player""ham_TakeDamage_Pre");
   
RegisterHam(Ham_Item_Deploy"weapon_knife""ham_ItemDeploy_Post_KNI"1);
   
RegisterHam(Ham_Item_Deploy"weapon_m4a1""ham_ItemDeploy_Post_M4"1);
   
RegisterHam(Ham_Player_ResetMaxSpeed"player""Player_ResetMaxSpeed",  1);
   
   
g_iMaxPlayers get_maxplayers();
}

public 
plugin_precache()
{
   
precache_model(g_ModelSuperKnife);
   
precache_model(g_ModelSuperM4A1;
}
 
public 
client_putinserverid )

   
g_bHasSuperKnife[id] = false;
   
g_bHasSuperSpeed[id] = false;
   
g_bHasSuperM4A1[id] = false;
}

public 
Player_Spawn_Postid )
{
   if(
is_user_alive(id))
   {
      
client_print(idprint_chat"[Base Builder] Write /shop to open shop menu!");
      
g_bHasSuperKnife[id] = false;
      
g_bHasSuperSpeed[id] = false;
      
g_bHasSuperM4A1[id] = false;
   }
}
 
public 
client_disconnect(id)
{
   
g_bHasSuperKnife[id] = false;
   
g_bHasSuperSpeed[id] = false;
   
g_bHasSuperM4A1[id] = false;
}
 
public 
ShowShop(id)
{
   if ( 
is_user_alive(id) )
   {
      new 
Text[64];
      
      if(
cs_get_user_team(id) == CS_TEAM_T)
      {
         new 
menu1 menu_create("\r[Base builder] \wShop Menu""ZombieShop");
         
formatex(Textcharsmax(Text), "\wSpeed \y[\r%d $\y]"get_pcvar_num(g_pCvarCostSpeed));
         
menu_additem(menu1Text"0");
         
formatex(Textcharsmax(Text), "\wGravity \y[\r%d $\y]"get_pcvar_num(g_pCvarCostLowGrav));
         
menu_additem(menu1Text"1");
         
formatex(Textcharsmax(Text), "\wSupercut Knife \y[\r%d $\y]"get_pcvar_num(g_pCvarCostSuperCutT));
         
menu_additem(menu1Text"2");

         
menu_setprop(menu1MPROP_EXITNAME"Quitter");

         
menu_display(idmenu1);
      }

      else if(
cs_get_user_team(id) == CS_TEAM_CT)
      {
         new 
menu2 menu_create ("\y[\rBase Builder Shop\y]""BaseBuilderShop");   
         
formatex(Textcharsmax(Text), "\wSupercut Knife \y[\r%d $\y]"get_pcvar_num(g_pCvarCostSuperCutCT));
         
menu_additem(menu2Text"0");
         
formatex(Textcharsmax(Text), "\wGravity \y[\r%d $\y]"get_pcvar_num(g_pCvarCostLowGrav));
         
menu_additem(menu2Text"1");
         
formatex(Textcharsmax(Text), "\wGrenade \y[\r%d $\y]"get_pcvar_num(g_pCvarCostHE));
         
menu_additem(menu2Text"2");
         
formatex(Textcharsmax(Text), "\wFlash \y[\r%d $\y]"get_pcvar_num(g_pCvarCostFlash));
         
menu_additem(menu2Text"3");
         
formatex(Textcharsmax(Text), "\wSmoke \y[\r%d $\y]"get_pcvar_num(g_pCvarCostSmoke));
         
menu_additem(menu2Text"4");
         
formatex(Textcharsmax(Text), "\wSuper M4A1 \y[\r%d $\y]"get_pcvar_num(g_pCvarCostSuperM4A1));
         
menu_additem(menu2Text"5");

         
menu_display(idmenu2);
      }
   }
}

public 
ZombieShop(idmenu1item)
{
   if (
item == MENU_EXIT || !is_user_alive(id) || cs_get_user_team(id) != CS_TEAM_T
   {
      
menu_destroy(menu1);
      return 
PLUGIN_HANDLED;
   }
   
   new 
iMoney cs_get_user_money(id);

   switch(
item)
   {
      case 
0:
      {
         if ( 
iMoney >= get_pcvar_num(g_pCvarCostSpeed))
         {
            
cs_set_user_money(idiMoney get_pcvar_num(g_pCvarCostSpeed));
            
g_bHasSuperSpeed[id] = true;
            
set_user_maxspeed(idget_pcvar_float(g_pCvarQuantitySpeed));
            
client_print_color(idDontChange"^4%s ^1You just bought the ^3Super Speed^1!"g_prefix);
         }
            
         else
         {
            
client_print_color(idDontChange"^4%s ^1You do not have enough ^3money^1!"g_prefix);
         }
      }

      case 
1:
      {
         if ( 
iMoney >= get_pcvar_num(g_pCvarCostLowGrav))
         {
            
cs_set_user_money(idiMoney get_pcvar_num(g_pCvarCostLowGrav));
            
set_user_gravity(idget_pcvar_float(g_pCvarQuantityLowGrav));
            
client_print_color(idDontChange"^4%s ^1You just bought the ^3Low Gravity^1!"g_prefix);
         }

         else
         {
            
client_print_color(idDontChange"^4%s ^1You do not have enough d'^3money^1!"g_prefix);
         }
      }

      case 
2:
      {
         if ( 
iMoney >= get_pcvar_num(g_pCvarCostSuperCutT))
         {
            
cs_set_user_money(idiMoney get_pcvar_num(g_pCvarCostSuperCutT));
            
g_bHasSuperKnife[id] = true;
            
client_print_color(idDontChange"^4%s ^1You just bought a ^3Super Knife^1!"g_prefix);
         }

         else
         {
            
client_print_color(idDontChange"^4%s ^1You do not have enough d'^3money^1!"g_prefix);
         }
      }
   }
   
menu_destroy(menu1);
   return 
PLUGIN_HANDLED;
}

/*public RemoveGodMode(id)
{
   set_user_godmode(id, 0);
   client_print_color(id, DontChange, "^4%s ^1You're not invincible!", g_prefix);
}*/

public BaseBuilderShop(idmenu2item)
{
   if (
item == MENU_EXIT || !is_user_alive(id) || cs_get_user_team(id) != CS_TEAM_CT
   {
      
menu_destroy(menu2);
      return 
PLUGIN_HANDLED;
   }
   
   new 
iMoney cs_get_user_money(id);

   switch(
item)
   {
      case 
0:
      {
         if ( 
iMoney >= get_pcvar_num(g_pCvarCostSuperCutCT))
         {
            
cs_set_user_money(idiMoney get_pcvar_num(g_pCvarCostSuperCutCT));
            
g_bHasSuperKnife[id] = true;
            
client_print_color(idDontChange"^4%s ^1You just bought a ^3Super knife^1!"g_prefix);
         }

         else
         {
            
client_print_color(idDontChange"^4%s ^1You do not have enough ^3money^1!"g_prefix);
         }
      }
      
      case 
1:
      {
         if ( 
iMoney >= get_pcvar_num(g_pCvarCostLowGrav))
         {
            
cs_set_user_money(idiMoney get_pcvar_num(g_pCvarCostLowGrav));
            
set_user_gravity(idget_pcvar_float(g_pCvarQuantityLowGrav));
            
client_print_color(idDontChange"^4%s ^1You just bought the ^3Low Gravity^1!"g_prefix);
         }
            
         else
         {
            
client_print_color(idDontChange"^4%s ^1You do not have enough ^3money^1!"g_prefix);
         }
      }

      case 
2:
      {
         if ( 
iMoney >= get_pcvar_num(g_pCvarCostHE))
         {
            
cs_set_user_money(idiMoney get_pcvar_num(g_pCvarCostHE));
            
give_item(id"weapon_hegrenade");
            
client_print_color(idDontChange"^4%s ^1You just bought a ^3HE^1!"g_prefix);
         }

         else
         {
            
client_print_color(idDontChange"^4%s ^1You do not have enough ^3money^1!"g_prefix);
         }
      }

      case 
3:
      {
         if ( 
iMoney >= get_pcvar_num(g_pCvarCostFlash))
         {
            
cs_set_user_money(idiMoney get_pcvar_num(g_pCvarCostFlash));
            
give_item(id"weapon_flashbang");
            
client_print_color(idDontChange"^4%s ^1You just bought a ^3Flash^1!"g_prefix);
         }
               
         else
         {
            
client_print_color(idDontChange"^4%s ^1You do not have enough ^3money^1!"g_prefix);
         }
      }

      case 
4:
      {
         if ( 
iMoney >= get_pcvar_num(g_pCvarCostSmoke))
         {
            
cs_set_user_money(idiMoney get_pcvar_num(g_pCvarCostSmoke));
            
give_item(id"weapon_smokegrenade");
            
client_print_color(idDontChange"^4%s ^1You just bought a ^3Smoke^1!"g_prefix);
         }
            
         else
         {
            
client_print_color(idDontChange"^4%s ^1You do not have enough ^3money^1!"g_prefix);
         }
      }

      case 
5:
      {
         if ( 
iMoney >= get_pcvar_num(g_pCvarCostSuperM4A1))
         {
            
cs_set_user_money(idiMoney get_pcvar_num(g_pCvarCostSuperM4A1));
            
give_item(id"weapon_m4a1");
            
cs_set_user_bpammo(idCSW_M4A1200);
            
g_bHasSuperM4A1[id] = true;
            
client_print_color(idDontChange"^4%s ^1You just bought a ^3Super M4A1^1!"g_prefix);
         }
            
         else
         {
            
client_print_color(idDontChange"^4%s ^1You do not have enough ^3money^1!"g_prefix);
         }
      }    
   }
   
menu_destroy(menu2);
   return 
PLUGIN_HANDLED;
}
 
public 
ham_TakeDamage_Pre(victiminflictorattackerFloat:damagedamage_bits)
{
   if( !
IsPlayerattacker ) || !is_user_aliveattacker ) || inflictor != attacker )
   {
      return;
   }

   if ( 
g_bHasSuperKnife[attacker] && cs_get_user_team victim ) == CS_TEAM_CT && get_user_weaponattacker ) == CSW_KNIFE )
   {
      
SetHamParamFloat4damage 999.9 );
      
client_print_colorattackerDontChange"^4%s ^4SuperCut^1: (^4 +%2.f^1 Extra damage to^3 %s^1)"g_prefixdamageszNamevictim ));
   }
   
   if ( 
g_bHasSuperM4A1[attacker] && get_user_weapon(attacker) == CSW_M4A1 )
   {
      
SetHamParamFloat4damage );
   }
}
 
 
public 
ham_ItemDeploy_Post_KNI(weapon_ent)
{
   static 
owner;
   
owner get_pdata_cbase(weapon_ent414);

   if(
is_user_alive(owner) && g_bHasSuperKnife[owner])
   {
      
set_pev(ownerpev_viewmodel2g_ModelSuperKnife);
   }
}

public 
ham_ItemDeploy_Post_M4(weapon_ent)
{
   static 
owner;
   
owner get_pdata_cbase(weapon_ent414);

   if(
is_user_alive(owner) && (g_bHasSuperM4A1[owner])
   {
      
set_pev(ownerpev_viewmodel2g_ModelSuperM4A1);
   }
}

public 
Player_ResetMaxSpeed(id)
{
   if( 
is_user_alive(id) && get_user_maxspeed(id) !=  -1.0 && g_bHasSuperSpeed[id])
   {
      
set_user_maxspeed(idget_pcvar_float(g_pCvarQuantitySpeed));
   }
}

stock const g_szTeamName[Colors][] = 
{
   
"UNASSIGNED",
   
"TERRORIST",
   
"CT",
   
"SPECTATOR"
};

stock client_print_color(idiColor=DontChange, const szMsg[], any:...)
{
   if( 
id && !is_user_connected(id) )
   {
      return 
0;
   }

   if( 
iColor Grey )
   {
      
iColor DontChange;
   }

   new 
szMessage[192];
   if( 
iColor == DontChange )
   {
      
szMessage[0] = 0x04;
   }
   else
   {
      
szMessage[0] = 0x03;
   }

   new 
iParams numargs();

   if(
id)
   {
      if( 
iParams == )
      {
         
copy(szMessage[1], charsmax(szMessage)-1szMsg);
      }
      else
      {
         
vformat(szMessage[1], charsmax(szMessage)-1szMsg4);
      }

      if( 
iColor )
      {
         new 
szTeam[11];
         
get_user_team(idszTeamcharsmax(szTeam));

         
Send_TeamInfo(ididg_szTeamName[iColor]);
         
Send_SayText(ididszMessage);
         
Send_TeamInfo(ididszTeam);
      }
      else
      {
         
Send_SayText(ididszMessage);
      }
   } 
   return 
1;
}

stock Send_TeamInfo(iReceiveriPlayerIdszTeam[])
{
   static 
iTeamInfo 0;
   if( !
iTeamInfo )
   {
      
iTeamInfo get_user_msgid("TeamInfo");
   }
   
message_begin(iReceiver MSG_ONE_UNRELIABLE MSG_BROADCASTiTeamInfo, .player=iReceiver);
   
write_byte(iPlayerId);
   
write_string(szTeam);
   
message_end();
}

stock Send_SayText(iReceiveriPlayerIdszMessage[])
{
   static 
iSayText 0;
   if( !
iSayText )
   {
      
iSayText get_user_msgid("SayText");
   }
   
message_begin(iReceiver MSG_ONE_UNRELIABLE MSG_BROADCASTiSayText, .player=iReceiver);
   
write_byte(iPlayerId);
   
write_string(szMessage);
   
message_end();
}

stock szName( const index )
{
    static 
g_szName32 ];
   
    
get_user_nameindexg_szNamecharsmaxg_szName ) );
   
    return 
g_szName;

__________________
Hello!
I'm learning AMXX right now, so please No Hate if i suck

-----------------------------------------------------------------------
Check out my Furien Mod v0.3 here

ImYourBro is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:17.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode