I might be able to make this. Give me some time since I'm new to coding.
I got this so far,
Help fix this up if you can lol
if SERVER then
AddCSLuaFile("shared.lua")
end
if CLIENT then
SWEP.PrintName = "Teleport"
SWEP.Slot = 0
SWEP.SlotPos = 3
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = false
end
SWEP.Base = "weapon_cs_base2"
SWEP.Author = "Kropp"
SWEP.Instructions = "Left Click to Teleport"
SWEP.Contact = "james-kropp@hotmail.com"
SWEP.Purpose = "Teleport"
SWEP.IconLetter = "w"
SWEP.ViewModelFOV = 62
SWEP.ViewModelFlip = false
SWEP.AnimPrefix = "stunstick"
SWEP.Spawnable = false
SWEP.AdminSpawnable = true
SWEP.NextStrike = 0
SWEP.ViewModel = Model("models/weapons/v_stunbaton.mdl")
SWEP.WorldModel = Model("models/weapons/w_stunbaton.mdl")
SWEP.Sound = Sound("weapons/stunstick/stunstick_swing1.wav")
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = 0
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = ""
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = 0
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = ""
function SWEP:Deploy()
function SWEP:Initialize()
self:SetWeaponHoldType("normal")
self.Hit = {
Sound("weapons/stunstick/stunstick_impact1.wav"),
Sound("weapons/stunstick/stunstick_impact2.wav")
}
self.FleshHit = {
Sound("weapons/stunstick/stunstick_fleshhit1.wav"),
Sound("weapons/stunstick/stunstick_fleshhit2.wav")
}
end
function SWEP:PrimaryAttack()
if CurTime() < self.NextStrike then return end
self:SetWeaponHoldType("melee")
timer.Simple(0.3, function(wep) if wep:IsValid() then wep:SetWeaponHoldType("normal") end end, self)
self.Owner:SetAnimation(PLAYER_ATTACK1)
self.Weapon:EmitSound(self.Sound)
self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)
self.NextStrike = CurTime() + .3
if CLIENT then return end
local trace = self.Owner:GetEyeTrace();
local Gear = self.Owner:GetTable().CurGear or 1;
function("Teleport", "Teleports you to a targeted location.", true,
function ( Player, Trace )
local EndPos = Player:GetEyeTrace().HitPos;
local CloserToUs = (Player:GetPos() - EndPos):Angle():Forward();
Player:SetPos(EndPos + (CloserToUs * 20));
Player:PrintMessage(HUD_PRINTTALK, "Teleported.");
end
function SWEP:SecondaryAttack()
if CurTime() < self.NextStrike then return end
self.Owner:SetAnimation(PLAYER_ATTACK1)
self.Weapon:EmitSound(self.Sound)
self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)
self.NextStrike = CurTime() + .3
self:SetWeaponHoldType("melee")
timer.Simple(0.3, function(wep) if wep:IsValid() then wep:SetWeaponHoldType("normal") end end, self)
if CLIENT then return end
("Kill Player", "Aim at a player to slay him.", false,
function ( Player, Trace )
if IsValid(Trace.Entity) and Trace.Entity:IsPlayer() then
Trace.Entity:Kill();
Player:PrintMessage(HUD_PRINTTALK, "Player killed.");
end
end
);
function SWEP:Reload()
self:SetWeaponHoldType("melee")
timer.Destroy("rp_stunstick_threaten")
timer.Create("rp_stunstick_threaten", 1, 1, function() self:SetWeaponHoldType("normal") end)
if not SERVER then return end
if self.LastReload and self.LastReload > CurTime() - 0.1 then self.LastReload = CurTime() return end
self.LastReload = CurTime()
self.Owner:EmitSound("weapons/stunstick/spark"..math.random(1,3)..".wav")
end
if CLIENT then
local function StunStickFlash()
local alpha = 255
hook.Add("HUDPaint", "Teleport Stick", function()
alpha = Lerp(0.05, alpha, 0)
surface.SetDrawColor(255,255,255,alpha)
surface.DrawRect(0,0,ScrW(), ScrH())
if math.Round(alpha) == 0 then
hook.Remove("HUDPaint", "Teleport Stick")
end
end)
end
usermessage.Hook("StunStickFlash", StunStickFlash)
end