I'm trying to use the GDCW Base (used by Haven's Sweps) on TTT but on some weapons I get errors, all of them get an error similar to this when killing a person (then the person vanishes in thin air).
[LUA]
[ERROR] gamemodes/terrortown/gamemode/player.lua:581: attempt to call method 'DampenDrop' (a nil value)
1. unknown - gamemodes/terrortown/gamemode/player.lua:581
2. TakeDamageInfo - [C]:-1
3. unknown - addons/(gdcw)_desert_eagle_157291190/lua/entities/gdcwa_12.7
[/LUA]
Is there a way to merge the TTT Base with the GDCW base? How do I enhance compatibility (SWEPs are not my thing at all, where do I go from here)?
How about, don't. Or show us your code
I'm sorry if I'm being an idiot, I'm very ignorant to the subject. How about don't what?
[QUOTE=rbreslow;42643891]I'm sorry if I'm being an idiot, I'm very ignorant to the subject. How about don't what?[/QUOTE]
If he saying we can't help you unless you post the code that is broken
The code isn't broken. I'm not using the TTT weapon base and TTT has unique functions and methods that require it's method base. I want to know if I can merge the TTT weapon base with another weapon base.
You can do anything you want. The real question is how much time and effort you want to put into it for just a simple weapon pack.
EDIT: I'll give you a headstart, what you want to do will take quite some time.
With the deagle I keep getting this error.
[lua]
[(GDCW) Desert Eagle] gamemodes/terrortown/gamemode/player.lua:581: attempt to call method 'DampenDrop' (a nil value)
1. unknown - gamemodes/terrortown/gamemode/player.lua:581
2. TakeDamageInfo - [C]:-1
3. Think - lua/entities/gdcwa_12.7
[/lua]
[editline]25th October 2013[/editline]
I believe it's due to the fact that instead of standard weapons GDCW fires an entity which kills people.
We can't help you without seeing your code
[QUOTE=rbreslow;42644780]
I believe it's due to the fact that instead of standard weapons GDCW fires an entity which kills people.[/QUOTE]
No, the error message clearly explains the problem if you are not willing to fix this yourself post on coderhire and pay someone we are not here to spoon feed people who are not willing to learn or do any work them self.
I've gone over it for over 2 hours. It's not that I'm not willing to, [U]I don't know [I][B]HOW[/B][/I] to[/U]. I'd love to learn how if you could actually explain.
Then start learning? lua.org/pil/contents.html
This is an easy error for even a new coder
I know how to program in Lua. But I have no idea what is wrong with the error, I've checked all those places. I found nothing wrong. I've never worked with SWEPs before and the TTT base is extremely confusing.
You seem to be so sure of yourself, you can't take 5 minutes to explain what to do to fix it?
[QUOTE=rbreslow;42651715]I know how to program in Lua.[/QUOTE]
If that was true this would have taken you two minutes of figure out
The below is part of the TTT weapon base...
[lua]
function SWEP:DampenDrop()
-- For some reason gmod drops guns on death at a speed of 400 units, which
-- catapults them away from the body. Here we want people to actually be able
-- to find a given corpse's weapon, so we override the velocity here and call
-- this when dropping guns on death.
local phys = self:GetPhysicsObject()
if IsValid(phys) then
phys:SetVelocityInstantaneous(Vector(0,0,-75) + phys:GetVelocity() * 0.001)
phys:AddAngleVelocity(phys:GetAngleVelocity() * -0.99)
end
end
[/lua]
TTT then attempts to directly call this where your error is happening as seen below
[lua]
-- Drop all weapons
for k, wep in pairs(ply:GetWeapons()) do
WEPS.DropNotifiedWeapon(ply, wep, true) -- with ammo in them
wep:DampenDrop() -- Its time for an error
end
[/lua]
The guns you are adding don't have this function and thus it is nil when TTT tries to call it,
So with all that in mind surely since you know how to program in Lua you should be able to easily fix that?
[QUOTE=King Penisless;42651752]If that was true this would have taken you two minutes of figure out
The below is part of the TTT weapon base...
function SWEP:DampenDrop() -- For some reason gmod drops guns on death at a speed of 400 units, which -- catapults them away from the body. Here we want people to actually be able -- to find a given corpse's weapon, so we override the velocity here and call -- this when dropping guns on death. local phys = self:GetPhysicsObject() if IsValid(phys) then phys:SetVelocityInstantaneous(Vector(0,0,-75) + phys:GetVelocity() * 0.001) phys:AddAngleVelocity(phys:GetAngleVelocity() * -0.99) endend
TTT then attempts to directly call this where your error is happening as seen below
-- Drop all weapons for k, wep in pairs(ply:GetWeapons()) do WEPS.DropNotifiedWeapon(ply, wep, true) -- with ammo in them wep:DampenDrop() -- Its time for an error end
The guns you are adding don't have this function and thus it is nil when TTT tries to call it,
So with all that in mind surely since you know how to program in Lua you should be able to easily fix that?[/QUOTE]
They guns I'm adding [B]DO[/B] have this function, that was the first thing I tried. That's why I'm posting here.
[QUOTE=rbreslow;42651811]They guns I'm adding [B]DO[/B] have this function, [/QUOTE]
If they did then this error would not be happening, that is all the help we can offer you since you are unwilling to post any of your actually code.
Example M16 Shared.lua
[lua]
// Variables that are used on both client and server
SWEP.Category = "Khris' GDCW"
SWEP.Author = "Khristopher"
SWEP.Contact = "It should be pretty obvious."
SWEP.Purpose = "I made this for you, baby"
SWEP.Instructions = "Use your index finger to shoot and your middle finger to aim."
SWEP.MuzzleAttachment = "1" -- Should be "1" for CSS models or "muzzle" for hl2 models
SWEP.ShellEjectAttachment = "2" -- Should be "2" for CSS models or "1" for hl2 models
SWEP.DrawCrosshair = false
SWEP.Kind = WEAPON_HEAVY
SWEP.WeaponID = AMMO_M16
SWEP.ViewModelFOV = 75
SWEP.ViewModelFlip = true
SWEP.ViewModel = "models/weapons/v_khr_m1a4.mdl"
SWEP.WorldModel = "models/weapons/w_rif_m4a1.mdl"
SWEP.Base = "gdcw_base_assault"
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.Primary.Sound = Sound("Weapon_M1A4.Single")
SWEP.Primary.Round = ("gdcwa_5.56x45_ball")
SWEP.Primary.RPM = 950 // This is in Rounds Per Minute
SWEP.Primary.ClipSize = 30 // Size of a clip
SWEP.Primary.DefaultClip = 30
SWEP.Primary.ConeSpray = 3.0 // Hip fire accuracy
SWEP.Primary.ConeIncrement = 1.0 // Rate of innacuracy
SWEP.Primary.ConeMax = 4.0 // Maximum Innacuracy
SWEP.Primary.ConeDecrement = 1.1 // Rate of accuracy
SWEP.Primary.KickUp = 0.5 // Maximum up recoil (rise)
SWEP.Primary.KickDown = 0.3 // Maximum down recoil (skeet)
SWEP.Primary.KickHorizontal = 0.4 // Maximum up recoil (stock)
SWEP.Primary.Automatic = true // Automatic/Semi Auto
SWEP.Primary.Ammo = "Pistol"
SWEP.AmmoEnt = "item_ammo_pistol_ttt"
SWEP.Secondary.ClipSize = 1 // Size of a clip
SWEP.Secondary.DefaultClip = 1 // Default number of bullets in a clip
SWEP.Secondary.Automatic = false // Automatic/Semi Auto
SWEP.Secondary.Ammo = ""
SWEP.Secondary.IronFOV = 50 // How much you 'zoom' in. Less is more!
SWEP.data = {} // The starting firemode
SWEP.data.ironsights = 1
SWEP.SightsPos = Vector(2.039, 0, 0.239)
SWEP.SightsAng = Vector(0, 0, 0)
SWEP.RunSightsPos = Vector(0, 0, -0.709)
SWEP.RunSightsAng = Vector(-10.749, -14.606, 16.26)
SWEP.Offset = {
Pos = {
Up = -1.1,
Right = 1.0,
Forward = -3.0,
},
Ang = {
Up = 0,
Right = 6.5,
Forward = 0,
}
}
function SWEP:DrawWorldModel( )
local hand, offset, rotate
if not IsValid( self.Owner ) then
self:DrawModel( )
return
end
if not self.Hand then
self.Hand = self.Owner:LookupAttachment( "anim_attachment_rh" )
end
hand = self.Owner:GetAttachment( self.Hand )
if not hand then
self:DrawModel( )
return
end
offset = hand.Ang:Right( ) * self.Offset.Pos.Right + hand.Ang:Forward( ) * self.Offset.Pos.Forward + hand.Ang:Up( ) * self.Offset.Pos.Up
hand.Ang:RotateAroundAxis( hand.Ang:Right( ), self.Offset.Ang.Right )
hand.Ang:RotateAroundAxis( hand.Ang:Forward( ), self.Offset.Ang.Forward )
hand.Ang:RotateAroundAxis( hand.Ang:Up( ), self.Offset.Ang.Up )
self:SetRenderOrigin( hand.Pos + offset )
self:SetRenderAngles( hand.Ang )
self:DrawModel( )
end
function SWEP:DampenDrop()
-- For some reason gmod drops guns on death at a speed of 400 units, which
-- catapults them away from the body. Here we want people to actually be able
-- to find a given corpse's weapon, so we override the velocity here and call
-- this when dropping guns on death.
local phys = self:GetPhysicsObject()
if IsValid(phys) then
phys:SetVelocityInstantaneous(Vector(0,0,-75) + phys:GetVelocity() * 0.001)
phys:AddAngleVelocity(phys:GetAngleVelocity() * -0.99)
end
end
[/lua]
Example M16 Init.lua
[lua]
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include('shared.lua')
SWEP.Weight = 30 // Decides whether we should switch from/to this
SWEP.AutoSwitchTo = true // Auto switch to if we pick it up
SWEP.AutoSwitchFrom = true // Auto switch from if you pick up a better weapon
function SWEP:Initialize()
self:SetWeaponHoldType("ar2")
end
function SWEP:OnRemove()
end
[/lua]
Example M16 Cl_init
[lua]
include('shared.lua')
SWEP.PrintName = "M4A1 Aimpoint" // 'Nice' Weapon name (Shown on HUD)
SWEP.Slot = 2 // Slot in the weapon selection menu
SWEP.SlotPos = 5 // Position in the slot
SWEP.DrawAmmo = true // Should draw the default HL2 ammo counter // Should draw the default crosshair
SWEP.DrawWeaponInfoBox = true // Should draw the weapon info box
SWEP.BounceWeaponIcon = true // Should the weapon icon bounce?
SWEP.Icon = "VGUI/ttt/icon_m16"
[/lua]
I can post the weapon base if you want also.
Put a print inside the DampenDrop function in your weapon and see if that function is called correctly if it is then I would assume that the error is coming from another file
Well yeah, that was made clear here.
[lua]
2. TakeDamageInfo - [C]:-1
3. Think - lua/entities/gdcwa_12.7
[/lua]
gdcwa_12.7 is the bullet that is shot from the gun, as I tried to explain earlier it has nothing to do with my shared.lua/client/init.
[QUOTE=rbreslow;42652189]Well yeah, that was made clear here.
2. TakeDamageInfo - [C]:-1 3. Think - lua/entities/gdcwa_12.7
gdcwa_12.7 is the bullet that is shot from the gun, as I tried to explain earlier it has nothing to do with my shared.lua/client/init.[/QUOTE]
So just add an empty function called DampenDrop to the affected code, TTT will run as normal and nothing will be dropped surely.
If you're having an issue with bodies vanishing, add SWEP.Base = "weapon_tttbase" to your base's code. What it does is stack the bases on top of each other, but the functions that both bases have are replaced by yours, the one that's on top.
Not sure about dampen though
Sorry, you need to Log In to post a reply to this thread.