The code is
if SERVER then
AddCSLuaFile( "shared.lua" )
end
SWEP.Base = "weapon_tttbase"
SWEP.Kind = WEAPON_EQUIP
SWEP.CanBuy = {ROLE_TRAITOR} -- only traitors can buy
SWEP.WeaponID = AMMO_C4
SWEP.HoldType = "grenade"
SWEP.ViewModelFOV = 70
SWEP.ViewModelFlip = true
SWEP.ViewModel = "models/weapons/v_Grenade.mdl"
SWEP.WorldModel = "models/weapons/w_pistol.mdl"
SWEP.ShowViewModel = true
SWEP.ShowWorldModel = true
SWEP.ViewModelBonescales = {["ValveBiped.Grenade_body"] = Vector(0.016, 0.016, 0.016)}
SWEP.WElements = {
["Turret"] = { type = "Model", model = "models/Combine_turrets/Floor_turret.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(0.156, 1.1, 14.512), angle = Angle(0, -10441.544, -166.375), size = Vector(0.4, 0.4, 0.4), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
}
SWEP.VElements = {
["WTurret"] = { type = "Model", model = "models/Combine_turrets/Floor_turret.mdl", bone = "ValveBiped.Grenade_body", rel = "", pos = Vector(-1.737, 1.325, 15.751), angle = Angle(176.25, -133.57, 0), size = Vector(0.453, 0.5, 0.4), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
}
SWEP.DrawCrosshair = false
SWEP.ViewModelFlip = false
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "none"
SWEP.Primary.Delay = 5.0
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = true
SWEP.Secondary.Ammo = "none"
SWEP.Secondary.Delay = 1.0
SWEP.NoSights = true
if CLIENT then
SWEP.PrintName = "Turret Placer"
SWEP.Slot = 6
SWEP.EquipMenuData = {
type = "item_weapon",
name = "Turret",
desc = [[Place automated turret.]]
};
SWEP.Icon = "vgui/ttt/icon_awp.vmt"
end
function SWEP:PrimaryAttack()
if self.Planted then return end
self:BombStick()
end
function SWEP:BombStick()
if SERVER then
local ply = self.Owner
if not ValidEntity(ply) then return end
if self.Planted then return end
local ignore = {ply, self.Weapon}
local spos = ply:GetShootPos()
local epos = spos + ply:GetAimVector() * 80
local tr = util.TraceLine({start=spos, endpos=epos, filter=ignore, mask=MASK_SOLID})
if tr.HitWorld then
local turret = ents.Create("ttt_turret")
if ValidEntity(turret) then
turret:PointAtEntity(ply)
local tr_ent = util.TraceEntity({start=spos, endpos=epos, filter=ignore, mask=MASK_SOLID}, turret)
if tr_ent.HitWorld then
local ang = tr_ent.HitNormal:Angle()
ang:RotateAroundAxis(ang:Right(), -90)
ang:RotateAroundAxis(ang:Up(), -180)
turret:SetPos(tr_ent.HitPos)
turret:SetAngles(ang)
turret:SetOwner(ply)
turret:SetCollisionGroup(COLLISION_GROUP_NONE)
turret:Spawn()
turret.fingerprints = self.fingerprints
local phys = turret:GetPhysicsObject()
if ValidEntity(phys) then
phys:EnableMotion(false)
end
self:Remove()
self.Planted = true
end
end
ply:SetAnimation( PLAYER_ATTACK1 )
end
end
end
function SWEP:SecondaryAttack()
return false
end
function SWEP:Reload()
return false
end
function SWEP:OnRemove()
if CLIENT and ValidEntity(self.Owner) and self.Owner == LocalPlayer() and self.Owner:Alive() then
RunConsoleCommand("lastinv")
end
end
Why is the turret not working? It kicks me and says "Too many Lua errors"!
Yes, I am a bit of a noob in LUA.
Can you put it in [lua] tags?
It's hard to read.
[lua]if SERVER then
AddCSLuaFile( "shared.lua" )
end
SWEP.Base = "weapon_tttbase"
SWEP.Kind = WEAPON_EQUIP
SWEP.CanBuy = {ROLE_TRAITOR} -- only traitors can buy
SWEP.WeaponID = AMMO_C4
SWEP.HoldType = "grenade"
SWEP.ViewModelFOV = 70
SWEP.ViewModelFlip = true
SWEP.ViewModel = "models/weapons/v_Grenade.mdl"
SWEP.WorldModel = "models/weapons/w_pistol.mdl"
SWEP.ShowViewModel = true
SWEP.ShowWorldModel = true
SWEP.ViewModelBonescales = {["ValveBiped.Grenade_body"] = Vector(0.016, 0.016, 0.016)}
SWEP.WElements = {
["Turret"] = { type = "Model", model = "models/Combine_turrets/Floor_turret.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(0.156, 1.1, 14.512), angle = Angle(0, -10441.544, -166.375), size = Vector(0.4, 0.4, 0.4), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
}
SWEP.VElements = {
["WTurret"] = { type = "Model", model = "models/Combine_turrets/Floor_turret.mdl", bone = "ValveBiped.Grenade_body", rel = "", pos = Vector(-1.737, 1.325, 15.751), angle = Angle(176.25, -133.57, 0), size = Vector(0.453, 0.5, 0.4), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
}
SWEP.DrawCrosshair = false
SWEP.ViewModelFlip = false
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "none"
SWEP.Primary.Delay = 5.0
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = true
SWEP.Secondary.Ammo = "none"
SWEP.Secondary.Delay = 1.0
SWEP.NoSights = true
if CLIENT then
SWEP.PrintName = "Turret Placer"
SWEP.Slot = 6
SWEP.EquipMenuData = {
type = "item_weapon",
name = "Turret",
desc = [[Place automated turret.]]
};
SWEP.Icon = "vgui/ttt/icon_awp.vmt"
end
function SWEP:PrimaryAttack()
if self.Planted then return end
self:BombStick()
end
function SWEP:BombStick()
if SERVER then
local ply = self.Owner
if not ValidEntity(ply) then return end
if self.Planted then return end
local ignore = {ply, self.Weapon}
local spos = ply:GetShootPos()
local epos = spos + ply:GetAimVector() * 80
local tr = util.TraceLine({start=spos, endpos=epos, filter=ignore, mask=MASK_SOLID})
if tr.HitWorld then
local turret = ents.Create("ttt_turret")
if ValidEntity(turret) then
turret:PointAtEntity(ply)
local tr_ent = util.TraceEntity({start=spos, endpos=epos, filter=ignore, mask=MASK_SOLID}, turret)
if tr_ent.HitWorld then
local ang = tr_ent.HitNormal:Angle()
ang:RotateAroundAxis(ang:Right(), -90)
ang:RotateAroundAxis(ang:Up(), -180)
turret:SetPos(tr_ent.HitPos)
turret:SetAngles(ang)
turret:SetOwner(ply)
turret:SetCollisionGroup(COLLISION_GROUP_NONE)
turret:Spawn()
turret.fingerprints = self.fingerprints
local phys = turret:GetPhysicsObject()
if ValidEntity(phys) then
phys:EnableMotion(false)
end
self:Remove()
self.Planted = true
end
end
ply:SetAnimation( PLAYER_ATTACK1 )
end
end
end
function SWEP:SecondaryAttack()
return false
end
function SWEP:Reload()
return false
end
function SWEP:OnRemove()
if CLIENT and ValidEntity(self.Owner) and self.Owner == LocalPlayer() and self.Owner:Alive() then
RunConsoleCommand("lastinv")
end
end[/lua]
Put this in your server.cfg when running it and it won't kick you.
sv_kickerrornum 0
Please give us where the error is happening. It'll help us resolve your problem.
[QUOTE=kaos2100;38798173]Can you put it in [lua] tags?
It's hard to read.
[lua]if SERVER then
AddCSLuaFile( "shared.lua" )
end
SWEP.Base = "weapon_tttbase"
SWEP.Kind = WEAPON_EQUIP
SWEP.CanBuy = {ROLE_TRAITOR} -- only traitors can buy
SWEP.WeaponID = AMMO_C4
SWEP.HoldType = "grenade"
SWEP.ViewModelFOV = 70
SWEP.ViewModelFlip = true
SWEP.ViewModel = "models/weapons/v_Grenade.mdl"
SWEP.WorldModel = "models/weapons/w_pistol.mdl"
SWEP.ShowViewModel = true
SWEP.ShowWorldModel = true
SWEP.ViewModelBonescales = {["ValveBiped.Grenade_body"] = Vector(0.016, 0.016, 0.016)}
SWEP.WElements = {
["Turret"] = { type = "Model", model = "models/Combine_turrets/Floor_turret.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(0.156, 1.1, 14.512), angle = Angle(0, -10441.544, -166.375), size = Vector(0.4, 0.4, 0.4), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
}
SWEP.VElements = {
["WTurret"] = { type = "Model", model = "models/Combine_turrets/Floor_turret.mdl", bone = "ValveBiped.Grenade_body", rel = "", pos = Vector(-1.737, 1.325, 15.751), angle = Angle(176.25, -133.57, 0), size = Vector(0.453, 0.5, 0.4), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
}
SWEP.DrawCrosshair = false
SWEP.ViewModelFlip = false
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "none"
SWEP.Primary.Delay = 5.0
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = true
SWEP.Secondary.Ammo = "none"
SWEP.Secondary.Delay = 1.0
SWEP.NoSights = true
if CLIENT then
SWEP.PrintName = "Turret Placer"
SWEP.Slot = 6
SWEP.EquipMenuData = {
type = "item_weapon",
name = "Turret",
desc = [[Place automated turret.]]
};
SWEP.Icon = "vgui/ttt/icon_awp.vmt"
end
function SWEP:PrimaryAttack()
if self.Planted then return end
self:BombStick()
end
function SWEP:BombStick()
if SERVER then
local ply = self.Owner
if not ValidEntity(ply) then return end
if self.Planted then return end
local ignore = {ply, self.Weapon}
local spos = ply:GetShootPos()
local epos = spos + ply:GetAimVector() * 80
local tr = util.TraceLine({start=spos, endpos=epos, filter=ignore, mask=MASK_SOLID})
if tr.HitWorld then
local turret = ents.Create("ttt_turret")
if ValidEntity(turret) then
turret:PointAtEntity(ply)
local tr_ent = util.TraceEntity({start=spos, endpos=epos, filter=ignore, mask=MASK_SOLID}, turret)
if tr_ent.HitWorld then
local ang = tr_ent.HitNormal:Angle()
ang:RotateAroundAxis(ang:Right(), -90)
ang:RotateAroundAxis(ang:Up(), -180)
turret:SetPos(tr_ent.HitPos)
turret:SetAngles(ang)
turret:SetOwner(ply)
turret:SetCollisionGroup(COLLISION_GROUP_NONE)
turret:Spawn()
turret.fingerprints = self.fingerprints
local phys = turret:GetPhysicsObject()
if ValidEntity(phys) then
phys:EnableMotion(false)
end
self:Remove()
self.Planted = true
end
end
ply:SetAnimation( PLAYER_ATTACK1 )
end
end
end
function SWEP:SecondaryAttack()
return false
end
function SWEP:Reload()
return false
end
function SWEP:OnRemove()
if CLIENT and ValidEntity(self.Owner) and self.Owner == LocalPlayer() and self.Owner:Alive() then
RunConsoleCommand("lastinv")
end
end[/lua]
Put this in your server.cfg when running it and it won't kick you.
sv_kickerrornum 0
Please give us where the error is happening. It'll help us resolve your problem.[/QUOTE]
The problem is the turret doesn't even deploy.
They are asking for the lua error... people on these forums generally arnt willing to actually spend the time to run your code to find it. It a good idea to give as much data as possible to get help quickly.
[QUOTE=xAceOfSpades;38805675]The problem is the turret doesn't even deploy.[/QUOTE]
If it doesn't deploy then that most likely means you're missing an entity called "ttt_turret", which is deployed at line 74.
If this isn't the case I have no idea, check console for errors as penguin said.
Sorry, you need to Log In to post a reply to this thread.