Garry's Mod

Garry's Mod

Town Of Terror - More roles for TTT (The Original Custom Roles mod for TTT)
Herb 11 Feb, 2018 @ 8:27pm
Survivalist Weapons not showing in buy menu
I added the "ROLE_SURVIVALIST" to the canbuy of each weapon I wanted the survivalist to use but it just creates errors for each item in a different location.

Any Help?


[[TTT/Sandbox] Dragon Elites] lua/autorun/dragon_elites_sounds.lua:1: unfinished string near '")'
1. unknown - lua/autorun/dragon_elites_sounds.lua:0


[SirJink|] Lua Error:

[TTT - Grapple Hook] gamemodes/terrortown/entities/weapons/grapplehook/shared.lua:265: '(' expected near '<eof>'
1. unknown - gamemodes/terrortown/entities/weapons/grapplehook/shared.lua:0


[SirJink| Lua Error:

[[TTT/Sandbox] Dragon Elites] lua/weapons/weapon_dragon_elites/shared.lua:1: unexpected symbol near '/'
1. unknown - lua/weapons/weapon_dragon_elites/shared.lua:0


[SirJink|] Lua Error:

[Defibrillator - Trouble in Terrorist Town] lua/weapons/weapon_ttt_defib.lua:267: 'end' expected (to close 'if' at line 266) near '<eof>'
1. unknown - lua/weapons/weapon_ttt_defib.lua:0


[SirJink|] Lua Error:

[[TTT/Sandbox] Dragon Elites] gamemodes/terrortown/entities/weapons/weapon_ttt_dragon_elites/shared.lua:232: unfinished string near '<eof>'
1. unknown - gamemodes/terrortown/entities/weapons/weapon_ttt_dragon_elites/shared.lua:0
< >
Showing 1-15 of 20 comments
Herb 11 Feb, 2018 @ 8:33pm 
The default items like health station does work though. not sure what I'm doing differently in each case.
Jenssons  [developer] 11 Feb, 2018 @ 8:36pm 
you gotta post your code man
Herb 11 Feb, 2018 @ 8:39pm 
Which one?
Jenssons  [developer] 11 Feb, 2018 @ 8:44pm 
well from the error it looks like to me you did some thing wrong
Last edited by Jenssons; 11 Feb, 2018 @ 8:45pm
Jenssons  [developer] 11 Feb, 2018 @ 8:45pm 
so send any one
Herb 11 Feb, 2018 @ 8:45pm 
Ill start with grapple
Herb 11 Feb, 2018 @ 8:48pm 
GMADÃ= ÝtKR TTT - Grapple Hook This is a simple grappling hook that may be added to your server. You will probably need your own icon, everything can be edited via the shared.lua file.
This does NOT belong to me (I didnt make it) this is just a simple re-upload since I have not seen a grapple hook for TTT one the workshop. (so far.)
Message or comment with any questions or concerns. author   gamemodes/terrortown/entities/entities/trace1/cl_init.lua ‚ 0j gamemodes/terrortown/entities/entities/trace1/init.lua « |’9ê gamemodes/terrortown/entities/entities/trace1/shared.lua
 ó,s\ gamemodes/terrortown/entities/weapons/grapplehook/shared.lua 1 eóYþ
include('shared.lua')

//local matBeam = Material( "egon_middlebeam" )
local matBeam = Material( "cable/rope" )
//local matLight = Material( "sprites/gmdm_pickups/light" )
//local matRefraction = Material( "egon_ringbeam" )
//local matRefractRing = Material( "refract_ring" )
//local matHook = Material( "sprites/gmdm_pickups/light" )
//local hookTex = Texture:Download("sprites/yellowglow1")
//matHook:SetMaterialTexture( hookTex )

/*---------------------------------------------------------
Name: Initialize
---------------------------------------------------------*/
function ENT:Initialize()

self.Size = 0
self.MainStart = self.Entity:GetPos()
self.MainEnd = self:GetEndPos()
self.dAng = (self.MainEnd - self.MainStart):Angle()
//Changed from 3000 to match hook speed.
self.speed = 10000
self.startTime = CurTime()
self.endTime = CurTime() + self.speed
self.dt = -1

end

function ENT:Think()

self.Entity:SetRenderBoundsWS( self:GetEndPos(), self.Entity:GetPos(), Vector()*8 )

self.Size = math.Approach( self.Size, 1, 10*FrameTime() )

end


function ENT:DrawMainBeam( StartPos, EndPos, dt, dist )

local TexOffset = 0//CurTime() * -2.0

local ca = Color(255,255,255,255)
//local dist = EndPos:Distance(StartPos)
//self.endTime - self.startTime)
//self.endTime -

// I found the console spam! WTF was this for?
//Msg(dt .. "\n")

EndPos = StartPos + (self.dAng * ((1 - dt)*dist))
//StartPos = StartPos + (self.dAng * (((1 - dt)*dist)-3))

// Cool Beam
render.SetMaterial( matBeam )
render.DrawBeam( EndPos, StartPos,
//32
2,
TexOffset*-0.4, TexOffset*-0.4 + StartPos:Distance(EndPos) / 256,
ca )


end

function ENT:Draw()

local Owner = self.Entity:GetOwner()
if (!Owner || Owner == NULL) then return end

local StartPos = self.Entity:GetPos()
local EndPos = self:GetEndPos()
local ViewModel = (Owner == LocalPlayer())

if (EndPos == Vector(0,0,0)) then return end

// If it's the local player we start at the viewmodel
if ( ViewModel ) then

local vm = Owner:GetViewModel()
if (!vm || vm == NULL) then return end
local attachment = vm:GetAttachment( 1 )
StartPos = attachment.Pos

else
// If we're viewing another player we start at their weapon

StartPos = Owner:GetAttachment(3).Pos
if StartPos == NULL then return end

end


// offset the texture coords so it looks like it's scrolling
local TexOffset = CurTime() * -2

// Make the texture coords relative to distance so they're always a nice size
local Distance = EndPos:Distance( StartPos ) * self.Size

local et = (self.startTime + (Distance/self.speed))
if(self.dt != 0) then
self.dt = (et - CurTime()) / (et - self.startTime)
end
if(self.dt < 0) then
self.dt = 0
end
self.dAng = (EndPos - StartPos):Angle():Forward()

gbAngle = (EndPos - StartPos):Angle()
local Normal = gbAngle:Forward()

// Draw the beam
self:DrawMainBeam( StartPos, StartPos + Normal * Distance, self.dt, Distance )

// if (ViewModel) then
// render.IgnoreZ( true )
// end

// render.SetMaterial( matHook )
// if(self.dt == 0) then
// render.DrawSprite( EndPos + Normal, 44, 44, Color( 255, 255, 255, self.Size * 255 ) )
// else
// EndPos = StartPos + (self.dAng * ((1 - self.dt)*Distance))
// render.DrawSprite( EndPos, 44, 44, Color( 120, 120, 255, self.Size * 255 ) )
// end

// render.SetMaterial( matLight )
// render.DrawSprite( StartPos, 28, 28, Color( 255, 255, 255, 255 * self.Size ) )
// render.DrawSprite( StartPos, 64, 64, Color( 255, 255, 255, 255 * self.Size ) )
// + Normal * 32

// if (ViewModel) then
// render.IgnoreZ( false )
// end

end

/*---------------------------------------------------------
Name: IsTranslucent
---------------------------------------------------------*/
function ENT:IsTranslucent()
return true
end

AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )

include('shared.lua')

local sndOnline = Sound( "hl1/fvox/activated.wav" )

/*---------------------------------------------------------
Name: Initialize
---------------------------------------------------------*/
function ENT:Initialize()

self.Entity:DrawShadow( false )
self.Entity:SetSolid( SOLID_NONE )

end

function ENT:Think()
end

ENT.Type = "anim"


/*---------------------------------------------------------
---------------------------------------------------------*/
function ENT:SetEndPos( endpos )

self.Entity:SetNetworkedVector( 0, endpos )
self.Entity:SetCollisionBoundsWS( self.Entity:GetPos(), endpos, Vector() * 0.25 )

end


/*---------------------------------------------------------
---------------------------------------------------------*/
function ENT:GetEndPos()
return self.Entity:GetNetworkedVector( 0 )
end
if SERVER then
CreateConVar("grapple_distance", 10000, false) // dont edit this
AddCSLuaFile( "shared.lua" )
end

if CLIENT then
SWEP.PrintName = "Grapple Hook"
SWEP.Slot = 7 -- add 1 to get the slot number key

SWEP.ViewModelFOV = 72
SWEP.ViewModelFlip = false
end

SWEP.Base = "weapon_tttbase"

if CLIENT then
function SWEP:CustomAmmoDisplay()
self.AmmoDisplay = self.AmmoDisplay or {}
//attempt to remove ammo display
self.AmmoDisplay.Draw = false

self.AmmoDisplay.PrimaryClip = 1
self.AmmoDisplay.PrimaryAmmo = -1
self.AmmoDisplay.SecondaryAmmo = -1

return self.AmmoDisplay
end

function SWEP:SetWeaponHoldType( t )
// Just a fake function so we can define
// weapon holds in shared files without errors
end
end

SWEP.Spawnable = false
SWEP.AdminSpawnable = false
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = false
SWEP.ViewModel = "models/weapons/v_crossbow.mdl"
SWEP.WorldModel = "models/weapons/w_crossbow.mdl"

local sndPowerUp = Sound("weapons/crossbow/hit1.wav")
local sndPowerDown = Sound("Airboat.FireGunRevDown")
local sndTooFar = Sound("buttons/button10.wav")
//local sndShot = Sound("weapons/357/357_fire2.wav")

SWEP.Kind = WEAPON_EQUIP1
SWEP.AutoSpawnable = false
SWEP.AmmoEnt = "none"
SWEP.CanBuy = { ROLE_TRAITOR, ROLE_DETECTIVE, ROLE_SURVIVALIST } -- Remove ROLE_DETECTIVE or ROLE_TRAITOR to make it show only for traitor or detectives.
SWEP.InLoadoutFor = nil
SWEP.LimitedStock = true
SWEP.AllowDrop = true
SWEP.IsSilent = false
SWEP.NoSights = true

if CLIENT then
-- Path to the icon material
SWEP.Icon = "VGUI/ttt/ICONNAMEHERE" -- Replace with your own dont have one sorry :@

-- Text shown in the equip menu
SWEP.EquipMenuData = {
type = "Weapon",
desc = "Its a grappling hook."
};
end

if SERVER then
resource.AddFile("materials/VGUI/ttt/ICONNAMEHERE.vmt")
end

function SWEP:Initialize()

nextshottime = CurTime()
self:SetWeaponHoldType( "smg" )

end

function SWEP:Think()

if (!self.Owner || self.Owner == NULL) then return end

if ( self.Owner:KeyPressed( IN_ATTACK ) ) then

self:StartAttack()

elseif ( self.Owner:KeyDown( IN_ATTACK ) && inRange ) then

self:UpdateAttack()

elseif ( self.Owner:KeyReleased( IN_ATTACK ) && inRange ) then

self:EndAttack( true )

end

//Changed from KeyDown to prevent random stuck-in-zoom bug.
if ( self.Owner:KeyPressed( IN_ATTACK2 ) ) then

self:Attack2()

end

end

function SWEP:DoTrace( endpos )
local trace = {}
trace.start = self.Owner:GetShootPos()
trace.endpos = trace.start + (self.Owner:GetAimVector() * 14096) //14096 is length modifier.
if(endpos) then trace.endpos = (endpos - self.Tr.HitNormal * 7) end
trace.filter = { self.Owner, self.Weapon }

self.Tr = nil
self.Tr = util.TraceLine( trace )
end

function SWEP:StartAttack()
//Get begining and end poins of trace.
local gunPos = self.Owner:GetShootPos() //Start of distance trace.
local disTrace = self.Owner:GetEyeTrace() //Store all results of a trace in disTrace.
local hitPos = disTrace.HitPos //Stores Hit Position of disTrace.

//Calculate Distance
//Thanks to rgovostes for this code.
local x = (gunPos.x - hitPos.x)^2;
local y = (gunPos.y - hitPos.y)^2;
local z = (gunPos.z - hitPos.z)^2;
local distance = math.sqrt(x + y + z);

//Only latches if distance is less than distance CVAR
local distanceCvar = GetConVarNumber("grapple_distance")
inRange = false
if distance <= distanceCvar then
inRange = true
end

if inRange then
if (SERVER) then

if (!self.Beam) then //If the beam does not exist, draw the beam.
//grapple_beam
self.Beam = ents.Create( "trace1" )
self.Beam:SetPos( self.Owner:GetShootPos() )
self.Beam:Spawn()
end

self.Beam:SetParent( self.Owner )
self.Beam:SetOwner( self.Owner )

end

self:DoTrace()
self.speed = 10000 //Rope latch speed. Was 3000.
self.startTime = CurTime()
self.endTime = CurTime() + self.speed
self.stufff = -1

if (SERVER && self.Beam) then
self.Beam:GetTable():SetEndPos( self.Tr.HitPos )
end

self:UpdateAttack()

self.Weapon:EmitSound( sndPowerDown )
end
self.Weapon:EmitSound( sndPowerUp )
end

function SWEP:UpdateAttack()

self.Owner:LagCompensation( true )

if (!endpos) then endpos = self.Tr.HitPos end

if (SERVER && self.Beam) then
self.Beam:GetTable():SetEndPos( endpos )
end

lastpos = endpos


if ( self.Tr.Entity:IsValid() ) then

endpos = self.Tr.Entity:GetPos()
if ( SERVER ) then
self.Beam:GetTable():SetEndPos( endpos )
end

end

local vVel = (endpos - self.Owner:GetPos())
local Distance = endpos:Distance(self.Owner:GetPos())

local et = (self.startTime + (Distance/self.speed))
if(self.stufff != 0) then
self.stufff = (et - CurTime()) / (et - self.startTime)
end
if(self.stufff < 0) then
self.Weapon:EmitSound( sndPowerUp )
self.stufff = 0
end

if(self.stufff == 0) then
zVel = self.Owner:GetVelocity().z
vVel = vVel:GetNormalized()*(math.Clamp(Distance,0,7))
if( SERVER ) then
local gravity = GetConVarNumber("sv_Gravity")
vVel:Add(Vector(0,0,(gravity/100)*1.5)) //Player speed. DO NOT MESS WITH THIS VALUE!
if(zVel < 0) then
vVel:Sub(Vector(0,0,zVel/100))
end
self.Owner:SetVelocity(vVel)
end
end

endpos = nil

self.Owner:LagCompensation( false )

end

function SWEP:EndAttack( shutdownsound )

if ( shutdownsound ) then
self.Weapon:EmitSound( sndPowerDown )
end

if ( CLIENT ) then return end
if ( !self.Beam ) then return end

self.Beam:Remove()
self.Beam = nil

end

function SWEP:Attack2() //Zoom.

// self.Weapon:EmitSound( self.Secondary.Sound, 50, 100 )
if (CLIENT) then return end
local CF = self.Owner:GetFOV()
if CF == 90 then
self.Owner:SetFOV(30,.3)
elseif CF == 30 then
self.Owner:SetFOV(90,.3)
// self.Scope = true
// elseif CF == 0 then
// self.Owner:SetFOV(90,.3)
end
end

function SWEP:Holster()
self:EndAttack( false )
return true
end

function SWEP:OnRemove()
self:EndAttack( false )
return true
end


function SWEP:PrimaryAttack()
end

function SWEP:SecondaryAttack()
end
Herb 11 Feb, 2018 @ 8:48pm 
realized the whole thing didnt copy the first time.
Herb 11 Feb, 2018 @ 9:01pm 
All addons work when I dont add the "ROLE_SURVIVALIST" to the canbuy, no errors at all. So what did I do wrong? All I did was add that.
Jenssons  [developer] 11 Feb, 2018 @ 9:05pm 
try replacing 265 if (!self.Owner || self.Owner == NULL) then return end
with if (!self.Owner or self.Owner == NULL) then return end

as thats the line its says it has a error with
gamemodes/terrortown/entities/weapons/grapplehook/shared.lua:265: '(' expected near '<eof>'
Last edited by Jenssons; 11 Feb, 2018 @ 9:05pm
Herb 11 Feb, 2018 @ 9:10pm 
[TTT - Grapple Hook] gamemodes/terrortown/entities/weapons/grapplehook/shared.lua:265: '(' expected near '<eof>'
1. unknown - gamemodes/terrortown/entities/weapons/grapplehook/shared.lua:0

Herb 11 Feb, 2018 @ 9:11pm 
After changing what you said
Jenssons  [developer] 11 Feb, 2018 @ 9:13pm 
then idk what the problem is
Jenssons  [developer] 11 Feb, 2018 @ 9:14pm 
most likely another mod breaking it
Jenssons  [developer] 11 Feb, 2018 @ 9:14pm 
the town of terror mod that is
< >
Showing 1-15 of 20 comments
Per page: 1530 50