--This is a test file! if not nrequire then return end local reg = nrequire("item.lua") local pac if SERVER then pac = nrequire("core/pac/sv_pac.lua") end local skil = nrequire("sh_skillcommon.lua") skil.RegisterSkill({"Sailing","Paddleing"}) local paddleents = {} hook.Add("Tick","paddleents",function() for k,v in pairs(paddleents) do --Make sure the player is still on the boat --Find the entity below the player local tr = util.TraceLine({ start = v:GetPos() + Vector(0,0,20), endpos = v:GetPos() + Vector(0,0,-20), filter = v }) --And Add some velocity to it if tr.Entity and IsValid(tr.Entity) then --Move the boat local oldvel = tr.Entity:GetVelocity() local eye = v:EyeAngles():Forward() eye.z = 0 local newvel = oldvel + (eye * 5) * tr.Entity:GetPhysicsObject():GetMass() k:GetPhysicsObject():SetVelocity(newvel) print("newvel is", newvel) v:AddSkill("Paddleing",0.1) end --Add skill for the player --Turn the boat --local angdif = v:EyeAngles().yaw - k:GetAngles().yaw --k:GetPhysicsObject():SetAngleVelocity(Angle(0,angdif,0)) end end) local items = { { Name = "Axe", Tooltip = "Usefull for cutting down trees", Shape = { {true,true}, {true}, {true} }, Model = "error.mdl", pacname = "stranded_axe", onClick = function(self, ply) --Run server side print("Trying to chop...") local tr = ply:GetEyeTrace() print("Mattype:",tr.MatType,"Needed:",MAT_WOOD) if tr.MatType == MAT_WOOD then print("Chopping....") ply:ChopWood() end end }, { Name = "Pickaxe", Tooltip = "Maybe you can dig up rocks with this", Shape = { {true,true,true}, {false,true}, {false, true}, }, Model = "error.mdl", pacname = "stranded_pickaxe", onClick = function(self, ply) --Run server side print("Trying to pick...") local tr = ply:GetEyeTrace() print("Mattype:",tr.MatType,"Needed:",MAT_CONCRETE) if tr.MatType == MAT_CONCRETE then print("Chopping....") ply:MineRock() end end }, { Name = "Hammer", Tooltip = "You should be able to build things with this", Shape = { {true,true,true}, {false,true}, {false,true}, }, Model = "error.mdl", pacname = "stranded_hammer", onClick = function(self,ply) print("trying to hammer") local tr = ply:GetEyeTrace() local tents = {} local cursor = 0 local firstsucpos = nil while IsValid(tr.Entity) and tr.Entity != game.GetWorld() and cursor < 4 do firstsucpos = firstsucpos or tr.HitPos tents[#tents+1] = tr.Entity tnents = table.Copy(tents) tnents[#tnents + 1] = ply tr = util.TraceLine({ start = tr.HitPos, endpos = tr.HitPos + ply:EyeAngles():Forward() * 10, filter = tnents }) cursor = cursor + 1 end print("found ents:") PrintTable(tents) --See if the player has nails local nloc = ply:HasItem("Nail") if nloc then print("nlock was truthy, hammering...") ply:RemoveItem(nloc) local nail = ents.Create("prop_dynamic") print("Setting pos to:",firstsucpos) nail:SetPos(firstsucpos) nail:SetAngles(ply:EyeAngles()) nail:SetModel("models/crossbow_bolt.mdl") nail:Spawn() for k,v in pairs(tents) do for i,j in pairs(tents) do if v != j then print("Welding ",j," to ", v) constraint.Weld(j,v,0,0,100000,true,false) end end end nail:SetParent(tents[1]) end end }, { Name = "Paddle", Tooltip = "Row Row Row your boat", Shape = { {true}, {true}, {true} }, Model = "error.mdl", pacname = "stranded_axe", onClick = function(self, ply) --Run server side --If we're current paddleing, stop if self.paddleing then print("paddleing ent removed") paddleents[self.paddleing] = nil self.paddleing = nil return end --Find the entity below the player local tr = util.TraceLine({ start = ply:GetPos() + Vector(0,0,20), endpos = ply:GetPos() + Vector(0,0,-20), filter = ply }) --And Add some velocity to it if tr.Entity and IsValid(tr.Entity) then print("Paddleing ent added") self.paddleing = tr.Entity paddleents[tr.Entity] = ply end end }, } local base = {} function base:Serialize() return "" end function base:DeSerialize() return self end function base:DoOnPanel(dmodelpanel) dmodelpanel:SetModel(self.Model) end function base:DoOnEquipPanel(dmodelpanel) dmodelpanel:SetModel(self.Model) end base.Equipable = "Right Hand" function base:onDropped(ent) if CLIENT then return end pac.ApplyPac(ent,self.pacname) ent:SetAngles(Angle(180,0,0)) ent:SetColor(Color(0,0,0,0)) end function base:onEquip(ent) if CLIENT then return end pac.ApplyPac(ent,self.pacname) end function base:onUnEquip(ent) if CLIENT then return end pac.RemovePac(ent,self.pacname) end for k,v in pairs(items) do local tbase = table.Copy(base) for i,j in pairs(v) do tbase[i] = j end reg.RegisterItem(tbase) end