Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.55 KB | None | 0 0
  1. function GM.UseKeyHook(ply,key)
  2. local GM = GAMEMODE
  3. if key != IN_USE then return end
  4. if ply:KeyDown(1) then return end
  5.  
  6. local tr = ply:TraceFromEyes(150)
  7.  
  8. if tr.HitNonWorld then
  9. if tr.Entity and !GMS.IsInWater(tr.HitPos) then
  10. local ent = tr.Entity
  11. local mdl = tr.Entity:GetModel()
  12. local cls = tr.Entity:GetClass()
  13.  
  14. if (ent:IsFoodModel() or cls == "gms_food") and ((ply:GetPos()-ent:LocalToWorld(ent:OBBCenter())):Length() <= 65) and (SPropProtection.PlayerIsPropOwner(ply, ent) or SPropProtection.IsBuddy(ply, ent)) then
  15. if cls == "gms_food" then
  16. ply:SendMessage("Restored "..tostring((ent.Value / 1000) * 100).."% food.",3,Color(10,200,10,255))
  17. ply:SetFood(ply.Hunger + ent.Value)
  18. ent:Fadeout(2)
  19. ply:Heal(ent.Value / 20)
  20. ply:SendMessage("Regained "..tostring(ent.Value / 20).." hp.",3,Color(255,0,0,255))
  21. else
  22. local data = {}
  23. data.Entity = ent
  24. ply:DoProcess("EatFruit",2,data)
  25. end
  26.  
  27. elseif ent:IsTreeModel() then
  28. if !ply:HasUnlock("Sprout_Collect") then
  29. ply:SendMessage("You don't have enough skill.",3,Color(200,0,0,255))
  30. return end
  31.  
  32. ply:DoProcess("SproutCollect",5)
  33.  
  34. elseif cls == "gms_resourcedrop" and (ply:GetPos()-tr.HitPos):Length() <= 80 and (SPropProtection.PlayerIsPropOwner(ply, ent) or SPropProtection.IsBuddy(ply, ent)) then
  35. ply:PickupResourceEntity(ent)
  36. elseif ent:IsOnFire() and (SPropProtection.PlayerIsPropOwner(ply, ent) or SPropProtection.IsBuddy(ply, ent)) then
  37. if GetConVarNumber("gms_CampFire") == 1 then
  38. ply:OpenCombiMenu("Cooking")
  39. end
  40. end
  41. end
  42. elseif tr.HitWorld then
  43. for k,v in pairs(ents.FindInSphere(tr.HitPos,100)) do
  44. if v:IsGrainModel() and (SPropProtection.PlayerIsPropOwner(ply, v) or SPropProtection.IsBuddy(ply, v))then
  45. local data = {}
  46. data.Entity = v
  47.  
  48. ply:DoProcess("HarvestGrain",3,data)
  49. return
  50. elseif v:IsBerryBushModel() and (SPropProtection.PlayerIsPropOwner(ply, v) or SPropProtection.IsBuddy(ply, v)) then
  51. local data = {}
  52. data.Entity = v
  53.  
  54. ply:DoProcess("HarvestBush",3,data)
  55. return
  56. end
  57. end
  58.  
  59. if (tr.MatType == MAT_DIRT or tr.MatType == MAT_GRASS or tr.MatType == MAT_SAND or tr.MatType == MAT_SNOW) and !GMS.IsInWater(tr.HitPos) then
  60. local time = 5
  61. if ply:GetActiveWeapon():GetClass() == "gms_shovel" then time = 2 end
  62.  
  63. ply:DoProcess("Foraging",time)
  64. end
  65. else
  66.  
  67. local trace = {}
  68. trace.start = ply:GetShootPos()
  69. trace.endpos = trace.start + (ply:GetAimVector() * 150)
  70. trace.mask = MASK_WATER | MASK_SOLID
  71. trace.filter = ply
  72.  
  73. local tr2 = util.TraceLine(trace)
  74.  
  75. if (tr2.Hit and tr2.MatType == MAT_SLOSH and ply:WaterLevel() > 0) or ply:WaterLevel() == 3 then
  76. if ply.Thirst < 1000 and ply.Thirst > 950 then
  77. ply.Thirst = 1000
  78. ply:UpdateNeeds()
  79. if ply.Hasdrunk == false or ply.Hasdrunk == nil then
  80. ply:EmitSound(Sound("npc/barnacle/barnacle_gulp"..math.random(1,2)..".wav"))
  81. ply.Hasdrunk = true
  82. timer.Simple(0.9, function() ply.Hasdrunk = false end, ply)
  83. end
  84. elseif ply.Thirst < 950 then
  85. ply.Thirst = ply.Thirst + 50
  86. if ply.Hasdrunk == false or ply.Hasdrunk == nil then
  87. ply:EmitSound(Sound("npc/barnacle/barnacle_gulp"..math.random(1,2)..".wav"))
  88. ply.Hasdrunk = true
  89. timer.Simple(0.9, function() ply.Hasdrunk = false end, ply)
  90. end
  91. ply:UpdateNeeds()
  92. end
  93. elseif GMS.IsInWater(tr.HitPos) then
  94. ply:DoProcess("BottleWater",3)
  95. end
  96. end
  97. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement