Advertisement
Guest User

Untitled

a guest
Aug 27th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.92 KB | None | 0 0
  1. #include "extdll.h"
  2. #include "util.h"
  3. #include "cbase.h"
  4. #include "monsters.h"
  5. #include "weapons.h"
  6. #include "nodes.h"
  7. #include "player.h"
  8.  
  9. LINK_ENTITY_TO_CLASS( weapon_beretta, CBeretta );
  10.  
  11. void CBeretta::Spawn( )
  12. {
  13.     pev->classname = MAKE_STRING("weapon_beretta"); // hack to allow for old names
  14.     Precache( );
  15.     SET_MODEL(ENT(pev), "models/w_Beretta.mdl"); // This should be your own weapon model
  16.     m_iId = WEAPON_BERETTA;
  17.  
  18.     m_iDefaultAmmo = 17; // this could be replaced with EXAMPLE_DEFAULT_GIVE if you had defined it
  19.  
  20.     FallInit();// get ready to fall down.
  21.  
  22. }
  23.  
  24.  
  25. void CBeretta::Precache( void )
  26. {
  27.  
  28. // Again, you must replace these precache models and sounds with your own models and sounds
  29.     PRECACHE_MODEL("models/v_Beretta.mdl");
  30.     PRECACHE_MODEL("models/w_Beretta.mdl");
  31.     PRECACHE_MODEL("models/p_Beretta.mdl");
  32.  
  33.     PRECACHE_SOUND("items/9mmclip1.wav");
  34.  
  35.     PRECACHE_SOUND("items/clipinsert1.wav");
  36.     PRECACHE_SOUND("items/cliprelease1.wav");
  37.  
  38.     PRECACHE_SOUND ("weapons/hks1.wav");
  39.     PRECACHE_SOUND ("weapons/hks2.wav"); PRECACHE_SOUND ("weapons/hks3.wav");
  40.  
  41. // this is to hook your client-side event
  42.     m_usBerettaFire = PRECACHE_EVENT( 1, "events/beretta.sc" );
  43. }
  44.  
  45. int CBeretta::GetItemInfo(ItemInfo *p)
  46. {
  47.     p->pszName = STRING(pev->classname);
  48.     p->pszAmmo1 = "9mm";
  49.     p->iMaxAmmo1 = 200;
  50.     p->iMaxClip = -1; // means that there is no clip
  51.     p->iSlot = 1;
  52.     p->iPosition = 2;
  53.     p->iFlags = 0;
  54.     p->iId = m_iId = WEAPON_BERETTA;
  55.     p->iWeight = BERETTA_WEIGHT; // weight is for autoswitching, so it doesn't really matter much
  56.     p->pszAmmo2 = NULL; // no secondary ammo
  57.     p->iMaxAmmo2 = -1;
  58.  
  59.     return 1;
  60. }
  61.  
  62. int CBeretta::AddToPlayer( CBasePlayer *pPlayer )
  63. {
  64.     if ( CBasePlayerWeapon::AddToPlayer( pPlayer ) )
  65.     {
  66.  MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev );
  67.   WRITE_BYTE( m_iId );
  68.  MESSAGE_END();
  69.  return TRUE;
  70.     }
  71.     return FALSE;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement