Advertisement
Guest User

Untitled

a guest
Mar 14th, 2015
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.91 KB | None | 0 0
  1.  
  2. AddCSLuaFile()
  3.  
  4. DEFINE_BASECLASS( "player_default" )
  5.  
  6. local PLAYER = {}
  7.  
  8. PLAYER.DisplayName          = "Horror Story player"
  9.  
  10. PLAYER.WalkSpeed            = 200       -- How fast to move when not running
  11. PLAYER.RunSpeed             = 400       -- How fast to move when running
  12. PLAYER.CrouchedWalkSpeed    = 0.3       -- Multiply move speed by this when crouching
  13. PLAYER.DuckSpeed            = 0.3       -- How fast to go from not ducking, to ducking
  14. PLAYER.UnDuckSpeed          = 0.3       -- How fast to go from ducking, to not ducking
  15. PLAYER.JumpPower            = 200       -- How powerful our jump should be
  16. PLAYER.CanUseFlashlight     = false     -- Can we use the flashlight
  17. PLAYER.MaxHealth            = 100       -- Max health we can have
  18. PLAYER.StartHealth          = 100       -- How much health we start with
  19. PLAYER.StartArmor           = 0         -- How much armour we start with
  20. PLAYER.DropWeaponOnDie      = false     -- Do we drop our weapon when we die
  21. PLAYER.TeammateNoCollide    = false     -- Do we collide with teammates or run straight through them
  22. PLAYER.AvoidPlayers         = true      -- Automatically swerves around other players
  23. PLAYER.UseVMHands           = true      -- Uses viewmodel hands
  24.  
  25. PLAYER.SelectableModels = {
  26.     "models/player/guard_pack/guard_01.mdl",
  27.     "models/player/guard_pack/guard_02.mdl",
  28.     "models/player/guard_pack/guard_03.mdl",
  29.     "models/player/guard_pack/guard_04.mdl",
  30.     "models/player/guard_pack/guard_05.mdl",
  31.     "models/player/guard_pack/guard_06.mdl",
  32.     "models/player/guard_pack/guard_07.mdl",
  33.     "models/player/guard_pack/guard_08.mdl",
  34.     "models/player/guard_pack/guard_09.mdl"
  35. }
  36.  
  37. PLAYER.SelectedWeapons = {
  38.     "weapon_doom3_flashlight",
  39.     "taser",
  40.     "weapon_baton",
  41.     "weapon_empty_hands"
  42. }
  43. PLAYER.DefaultWeapon = "weapon_doom3_flashlight"
  44.  
  45.  
  46.  
  47. --
  48. -- Name: PLAYER:SetupDataTables
  49. -- Desc: Set up the network table accessors
  50. -- Arg1:
  51. -- Ret1:
  52. --
  53. function PLAYER:SetupDataTables()
  54.  
  55.     self.Player:NetworkVar( "String", 0, "HSModel" );
  56.  
  57. end
  58.  
  59. --
  60. -- Name: PLAYER:Init
  61. -- Desc: Called when the class object is created (shared)
  62. -- Arg1:
  63. -- Ret1:
  64. --
  65. function PLAYER:Init()
  66.  
  67.  
  68. end
  69.  
  70. function PLAYER:SetModel()
  71.  
  72.     if self.Player:GetHSModel() == "" then
  73.         self.Player:SetHSModel( table.Random( self.SelectableModels ) )
  74.     end
  75.    
  76.     self.Player:SetModel( self.Player:GetHSModel() )
  77.    
  78. end
  79.  
  80. --
  81. -- Name: PLAYER:Spawn
  82. -- Desc: Called serverside only when the player spawns
  83. -- Arg1:
  84. -- Ret1:
  85. --
  86. function PLAYER:Spawn()
  87.    
  88.     local oldhands = self.Player:GetHands();
  89.     if ( IsValid( oldhands ) ) then
  90.         oldhands:Remove()
  91.     end
  92.  
  93.     local hands = ents.Create( "gmod_hands" )
  94.     if ( IsValid( hands ) ) then
  95.         hands:DoSetup( self.Player )
  96.         hands:Spawn()
  97.     end
  98.    
  99.     self.Player:SetCollisionGroup( COLLISION_GROUP_WEAPON )
  100.  
  101. end
  102.  
  103. --
  104. -- Name: PLAYER:Loadout
  105. -- Desc: Called on spawn to give the player their default loadout
  106. -- Arg1:
  107. -- Ret1:
  108. --
  109. function PLAYER:Loadout()
  110.  
  111.     for _, wep in pairs( self.SelectedWeapons ) do
  112.         self.Player:Give( wep )
  113.     end
  114.     self.Player:SelectWeapon( self.DefaultWeapon )
  115.  
  116. end
  117.  
  118. -- Clientside only
  119. function PLAYER:CalcView( view ) end        -- Setup the player's view
  120. function PLAYER:CreateMove( cmd ) end       -- Creates the user command on the client
  121. function PLAYER:ShouldDrawLocal() end       -- Return true if we should draw the local player
  122.  
  123. -- Shared
  124. function PLAYER:StartMove( cmd, mv ) end    -- Copies from the user command to the move
  125. function PLAYER:Move( mv ) end              -- Runs the move (can run multiple times for the same client)
  126. function PLAYER:FinishMove( mv ) end        -- Copy the results of the move back to the Player
  127.  
  128.  
  129. --
  130. -- Name: PLAYER:ViewModelChanged
  131. -- Desc: Called when the player changes their weapon to another one causing their viewmodel model to change
  132. -- Arg1: Entity|viewmodel|The viewmodel that is changing
  133. -- Arg2: string|old|The old model
  134. -- Arg3: string|new|The new model
  135. -- Ret1:
  136. --
  137. function PLAYER:ViewModelChanged( vm, old, new )
  138. end
  139.  
  140. --
  141. -- Name: PLAYER:PreDrawViewmodel
  142. -- Desc: Called before the viewmodel is being drawn (clientside)
  143. -- Arg1: Entity|viewmodel|The viewmodel
  144. -- Arg2: Entity|weapon|The weapon
  145. -- Ret1:
  146. --
  147. function PLAYER:PreDrawViewModel( vm, weapon )
  148. end
  149.  
  150. --
  151. -- Name: PLAYER:PostDrawViewModel
  152. -- Desc: Called after the viewmodel has been drawn (clientside)
  153. -- Arg1: Entity|viewmodel|The viewmodel
  154. -- Arg2: Entity|weapon|The weapon
  155. -- Ret1:
  156. --
  157. function PLAYER:PostDrawViewModel( vm, weapon )
  158.  
  159.     if ( weapon.UseHands || !weapon:IsScripted() ) then
  160.  
  161.         local hands = self.Player:GetHands()
  162.         if ( IsValid( hands ) ) then
  163.             hands:DrawModel()
  164.         end
  165.  
  166.     end
  167.  
  168. end
  169.  
  170. --
  171. -- Name: PLAYER:GetHandsModel
  172. -- Desc: Called on player spawn to determine which hand model to use
  173. -- Arg1:
  174. -- Ret1: table|info|A table containing model, skin and body
  175. --
  176. function PLAYER:GetHandsModel()
  177.  
  178.     -- return { model = "models/weapons/c_arms_cstrike.mdl", skin = 1, body = "0100000" }
  179.  
  180.     local cl_playermodel = self.Player:GetHSModel()
  181.     return player_manager.TranslatePlayerHands( cl_playermodel )
  182.  
  183. end
  184.  
  185. player_manager.RegisterClass( "player_horrorstory", PLAYER, "player_default" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement