Guest User

Gmod 9 weapon functions.

a guest
May 23rd, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.10 KB | None | 0 0
  1.  
  2.  
  3. -- This is the base SWEP (Scripted Weapon).
  4. -- DO NOT change this file.
  5. -- When making a new weapon you only need to override what you need.
  6.  
  7. _OpenScript( "includes/defines.lua" );
  8. _OpenScript( "includes/vector3.lua" );
  9. _OpenScript( "includes/misc.lua" );
  10. _OpenScript( "includes/backcompat.lua" );
  11.  
  12.  
  13. -- These variables are passed by the engine
  14. -- Don't re-define them in your SWEP.
  15. MyIndex         =   0; -- Weapon's entity index.
  16. Owner           =   0; -- The player that owns this weapon
  17. CurrentTime     =   0; -- The current game time
  18.  
  19.  
  20.  
  21. -- Called when the weapon is created.
  22.  
  23.     function onInit( )
  24.     end
  25.    
  26.    
  27. -- Called when player picks up weapon
  28.     function onPickup( playerid )
  29.     end
  30.    
  31.    
  32. -- Called when player drops weapon
  33.     function onDrop( playerid )
  34.     end
  35.  
  36.  
  37. -- Weapon is about to be destroyed.
  38.     function onRemove( )
  39.     end
  40.  
  41.  
  42. -- Called every frame
  43.  
  44.     function onThink( )
  45.     end
  46.    
  47.  
  48. -- When the player presses left mouse button
  49.  
  50.     function onPrimaryAttack( )
  51.     end
  52.  
  53.    
  54.  
  55. -- When the player presses right mouse button
  56.  
  57.     function onSecondaryAttack( )      
  58.     end
  59.  
  60.  
  61. -- When Weapon is swapped to
  62.  
  63.     function Deploy( )
  64.     end
  65.    
  66.    
  67. -- When weapon swapped away from
  68.    
  69.     function Holster( )
  70.     end
  71.    
  72.  
  73. -- When player presses reload. Returning false means DON'T RELOAD. Although this will hitch on the client.
  74.  
  75.     function onReload( )
  76.         return true;
  77.     end
  78.  
  79.  
  80.  
  81. -- Primary Attack Settings
  82.  
  83.     function getDamage()
  84.         return 10;
  85.     end
  86.  
  87.     function getPrimaryShotDelay()
  88.         return 0.2;
  89.     end
  90.  
  91.     function getPrimaryIsAutomatic()
  92.         return true;
  93.     end
  94.  
  95.     function getBulletSpread()
  96.         return vector3( 0.01, 0.01, 0.01 );
  97.     end
  98.  
  99.     function getViewKick()
  100.         return vector3( 0.5, 0.0, 0.0);
  101.     end
  102.  
  103.     function getViewKickRandom()
  104.         return vector3( 0.5, 0.5, 0.2 );
  105.     end
  106.  
  107.     function getNumShotsPrimary()
  108.         return 1;
  109.     end
  110.  
  111.     function getPrimaryAmmoType()
  112.         return "pistol";
  113.     end
  114.  
  115.     function getMaxClipPrimary() -- return -1 if it doesn't use clips
  116.         return 25;
  117.     end
  118.    
  119.     function getDefClipPrimary() -- ammo in gun by default
  120.         return 25;
  121.     end
  122.    
  123.     function getTracerFreqPrimary() -- 0 = none, 1 = every bullet, 2 = every 2nd bullet etc
  124.         return 2;
  125.     end
  126.    
  127.    
  128. -- Secondary attack Settings
  129.  
  130.     function getDamageSecondary()
  131.         return 10;
  132.     end
  133.  
  134.     function getSecondaryShotDelay()
  135.         return 0.2;
  136.     end
  137.  
  138.     function getSecondaryIsAutomatic()
  139.         return false;
  140.     end
  141.  
  142.     function getBulletSpreadSecondary()
  143.         return vector3( 0.001, 0.001, 0.001 );
  144.     end
  145.  
  146.     function getViewKickSecondary()
  147.         return vector3( 0.5, 0.0, 0.0);
  148.     end
  149.  
  150.     function getViewKickRandomSecondary()
  151.         return vector3( 0.5, 0.5, 0.2 );
  152.     end
  153.  
  154.     function getNumShotsSecondary()
  155.         return 1;
  156.     end
  157.  
  158.     function getSecondaryAmmoType()
  159.         return "pistol";
  160.     end
  161.  
  162.     function getMaxClipSecondary() -- return -1 if it doesn't use clips
  163.         return -1;
  164.     end
  165.  
  166.     function getDefClipSecondary()
  167.         return 0;
  168.     end
  169.    
  170.     function getTracerFreqSecondary()
  171.         return 2;
  172.     end
  173.    
  174.    
  175.    
  176.    
  177. -- Weapon Configuration
  178.    
  179.     function getViewModel( )
  180.         return "models/weapons/v_smg_ump45.mdl";
  181.     end
  182.  
  183.     function getWorldModel( )
  184.         return "models/weapons/w_smg_ump45.mdl";
  185.     end
  186.  
  187.     function getClassName()
  188.         return "weapon_scripted";
  189.     end
  190.  
  191.     function getHUDMaterial( )
  192.         return "gmod/SWEP/default";
  193.     end
  194.  
  195.     function getDeathIcon( )
  196.         return "swep_default";
  197.     end
  198.  
  199.     function getWeaponSwapHands()
  200.         return false   
  201.     end
  202.  
  203.     function getWeaponFOV()
  204.         return 70
  205.     end
  206.  
  207.     function getWeaponSlot()
  208.         return 5   
  209.     end
  210.  
  211.     function getWeaponSlotPos()
  212.         return 2
  213.     end
  214.  
  215.     function getFiresUnderwater()
  216.         return true
  217.     end
  218.  
  219.     function getReloadsSingly()
  220.         return false
  221.     end
  222.    
  223.     -- How the player model holds the weapon:
  224.     -- pistol, smg, ar2, shotgun, rpg, phys, crossbow, melee, slam, grenade
  225.     function getAnimPrefix()
  226.         return "shotgun";
  227.     end
  228.  
  229.     function getPrintName()
  230.         return "The Boltgun";
  231.     end
  232.  
  233.     -- 0 = Don't override, shoot bullets, make sound and flash
  234.     -- 1 = Don't shoot bullets but do make flash/sounds
  235.     -- 2 = Only play animations
  236.     -- 3 = Don't do anything
  237.     function getPrimaryScriptOverride()
  238.         return 0;
  239.     end
  240.  
  241.     function getSecondaryScriptOverride()
  242.         return 0;
  243.     end
Add Comment
Please, Sign In to add comment