local ITEM = {} ITEM.Name = "Teleport" ITEM.Class = "weapon" ITEM.Desc = "Right click to set target location, left click to open a portal there." ITEM.Model = "models/props_debris/wood_board02a.mdl" ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_spellteleport.png") ITEM.HoldType = "magic" --Load some nessessary stuff game.AddParticles("particles/particletest.pcf") PrecacheParticleSystem("firetest") ITEM.Structure = { { Bone = "ValveBiped.Bip01_R_Hand", Model = "models/props_junk/Rock001a.mdl", Size = Vector(1,1,1), Pos = Vector(0,0,0), Ang = Angle(0,0,0), }, } ITEM.CD = 0.25 ITEM.Range = 9999 --[[ All saved points are stored in a global table where ITEM.savedpoint[player] = ]] local savedpoint = {} function ITEM:DoTeleport(score,pl,self) print("DoTeleport called!") if savedpoint[pl] == nil then return end print("Fully successfull teleport callback:") print(pl) local aim = pl:GetAimVector() local D = ents.Create("ws_teleporter") D:SetPos(pl:GetShootPos() + aim * 200) -- D:SetOwner(pl) D:SetAngles(aim:Angle()) D.endpoint = savedpoint[pl] D:Spawn() D:Activate() pl:EmitSound(Sound("physics/flesh/flesh_impact_hard.wav"),100,math.random(90,110)) end -- local teleportfunc = function(score, pl, self) -- print("teleportfunc called!") -- if ITEM.savedpoint[ == nil then return end -- if score != 100 then return end -- print("Fully successfull teleport callback:") -- print(pl) -- pl:SetPos(self.savedpoint) -- -- local aim = pl:GetAimVector() -- -- local D = ents.Create("ws_teleporter") -- D:SetModel("models/props_wasteland/wood_fence02a.mdl") -- -- D:SetPos(pl:GetShootPos()+aim*200) -- D:SetOwner(pl) -- D:SetAngles(aim:Angle()) -- D:Spawn() -- D.endpoint = self.savedpoint -- -- pl:EmitSound(Sound("physics/flesh/flesh_impact_hard.wav"),100,math.random(90,110)) -- end function ITEM:OnSecondary(pl,tr) pl:ChatPrint("Endpoint set?") ParticleEffect("firetest",pl:GetPos(),pl:GetAngles(),pl) savedpoint[pl] = pl:GetPos() end function ITEM:OnPrimary(pl,tr) if CLIENT then return end print("Attempting to cast...") pl:Cast("Gateway",function(score,pl,s) self:DoTeleport(score,pl,s) end,self) end RegisterItem(ITEM)