Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function GM.UseKeyHook(ply,key)
- local GM = GAMEMODE
- if key != IN_USE then return end
- if ply:KeyDown(1) then return end
- local tr = ply:TraceFromEyes(150)
- if tr.HitNonWorld then
- if tr.Entity and !GMS.IsInWater(tr.HitPos) then
- local ent = tr.Entity
- local mdl = tr.Entity:GetModel()
- local cls = tr.Entity:GetClass()
- 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
- if cls == "gms_food" then
- ply:SendMessage("Restored "..tostring((ent.Value / 1000) * 100).."% food.",3,Color(10,200,10,255))
- ply:SetFood(ply.Hunger + ent.Value)
- ent:Fadeout(2)
- ply:Heal(ent.Value / 20)
- ply:SendMessage("Regained "..tostring(ent.Value / 20).." hp.",3,Color(255,0,0,255))
- else
- local data = {}
- data.Entity = ent
- ply:DoProcess("EatFruit",2,data)
- end
- elseif ent:IsTreeModel() then
- if !ply:HasUnlock("Sprout_Collect") then
- ply:SendMessage("You don't have enough skill.",3,Color(200,0,0,255))
- return end
- ply:DoProcess("SproutCollect",5)
- elseif cls == "gms_resourcedrop" and (ply:GetPos()-tr.HitPos):Length() <= 80 and (SPropProtection.PlayerIsPropOwner(ply, ent) or SPropProtection.IsBuddy(ply, ent)) then
- ply:PickupResourceEntity(ent)
- elseif ent:IsOnFire() and (SPropProtection.PlayerIsPropOwner(ply, ent) or SPropProtection.IsBuddy(ply, ent)) then
- if GetConVarNumber("gms_CampFire") == 1 then
- ply:OpenCombiMenu("Cooking")
- end
- end
- end
- elseif tr.HitWorld then
- for k,v in pairs(ents.FindInSphere(tr.HitPos,100)) do
- if v:IsGrainModel() and (SPropProtection.PlayerIsPropOwner(ply, v) or SPropProtection.IsBuddy(ply, v))then
- local data = {}
- data.Entity = v
- ply:DoProcess("HarvestGrain",3,data)
- return
- elseif v:IsBerryBushModel() and (SPropProtection.PlayerIsPropOwner(ply, v) or SPropProtection.IsBuddy(ply, v)) then
- local data = {}
- data.Entity = v
- ply:DoProcess("HarvestBush",3,data)
- return
- end
- end
- 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
- local time = 5
- if ply:GetActiveWeapon():GetClass() == "gms_shovel" then time = 2 end
- ply:DoProcess("Foraging",time)
- end
- else
- local trace = {}
- trace.start = ply:GetShootPos()
- trace.endpos = trace.start + (ply:GetAimVector() * 150)
- trace.mask = MASK_WATER | MASK_SOLID
- trace.filter = ply
- local tr2 = util.TraceLine(trace)
- if (tr2.Hit and tr2.MatType == MAT_SLOSH and ply:WaterLevel() > 0) or ply:WaterLevel() == 3 then
- if ply.Thirst < 1000 and ply.Thirst > 950 then
- ply.Thirst = 1000
- ply:UpdateNeeds()
- if ply.Hasdrunk == false or ply.Hasdrunk == nil then
- ply:EmitSound(Sound("npc/barnacle/barnacle_gulp"..math.random(1,2)..".wav"))
- ply.Hasdrunk = true
- timer.Simple(0.9, function() ply.Hasdrunk = false end, ply)
- end
- elseif ply.Thirst < 950 then
- ply.Thirst = ply.Thirst + 50
- if ply.Hasdrunk == false or ply.Hasdrunk == nil then
- ply:EmitSound(Sound("npc/barnacle/barnacle_gulp"..math.random(1,2)..".wav"))
- ply.Hasdrunk = true
- timer.Simple(0.9, function() ply.Hasdrunk = false end, ply)
- end
- ply:UpdateNeeds()
- end
- elseif GMS.IsInWater(tr.HitPos) then
- ply:DoProcess("BottleWater",3)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement