Multiple TTT Issues.

  1. Set it so knife goes 25% faster and am getting the following error:
    Hook ‘SetKnifeSpeed’ Failed: [@gamemodes errortown\gamemode\speed.lua:12] Tried to use a NULL entity!
    CODE:
    [lua]
    function SetKnifeSpeed()
    for k,v in pairs( player.GetAll() ) do
    if IsValid( v ) and v:IsPlayer() and v:GetActiveWeapon():GetClass() == “weapon_ttt_knife” then – line 12
    v:SetSpeed( 1 )
    end
    end
    end
    hook.Add( “Think”, “SetKnifeSpeed”, SetKnifeSpeed )
    [/lua]

  2. Trying to make itso traitors recieve 1 hp every second untill they reach 100 hp, no errors.

[lua]
function HPRegen()
for k,v in pairs( player.GetAll() ) do
–timer.Create( “checkplayerhpcrap”, 1, 0, function()
if v:Health() < 100 and v:GetRole() == ROLE_TRAITOR and GetRoundState == ROUND_ACTIVE then
timer.Create( “hpregren”, 1, 0, function()
if v:Health() >= 100 then timer.Destroy( “hpregen” ) end
Playersnewhp = v:Health() + 1
v:SetHealth( Playersnewhp )
end )
end
–end )
end
end
hook.Add( “Think”, “HPRegen”, HPRegen )
[/lua]

  1. Radar is supposed to scan every 20 seconds for traitors and 15 for detectives: http://www.facepunch.com/threads/1103873-TTT-Radar

For the first problem, which one is line 12?

Oh yah, sorry about that. Editing OP

Think the problem is v:GetActiveWeapon() is returning nothing. Try printing it, see what you get.

For the speed of knife. I think you should edit the file of the knife and in a deploy function add self:Owner:SetSpeed(x) and in holster function add self.Owner:SetSpeed(y).

Yah, it’s printing “[NULL Entity]”

[editline]4th July 2011[/editline]

I’m trying to cut down on editing the base files of the TTT so this way works too.

SetSpeed is a variable that goes to a function that sets the speeds and crap. :stuck_out_tongue:

[editline]4th July 2011[/editline]

Actually I printed v:GetActiveWeapon() the first time. I then printed v:GetActiveWeapon():GetClass() and it printed nothing.

Oh and for your second problem, you’re creating a timer everytime the hook runs. Try using this instead:

[lua]
local CTime = 0
function HPRegen()
if CTime > CurTime() then return end
for _, v in pairs( player.GetAll() ) do
if v:Health() < 100 and v:GetRole( ROLE_TRAITOR ) and GetRoundState == ROUND_ACTIVE then
v:SetHealth(v:Health() + 1)
end
end
CTime = CurTime() + 1
end
hook.Add( “Think”, “HPRegen”, HPRegen )
[/lua]

Try adding this to the end of weapon_ttt_knife\shared.lua
[lua]
function SWEP:Deploy()
local speed = self.Owner:GetWalkSpeed()
self.Owner:SetWalkSpeed(speed *1.25)
return true
end

function SWEP:Holster( wep )
local speed = self.Owner:GetWalkSpeed()
self.Owner:SetWalkSpeed(speed / 1.25)
return true
end
[/lua]

Not sure if works, didn’t tested.

Doesn’t work. TTT code overwrites setwalkspeed and crap. I tried changing it to work the way it should but it still doesn’t work that way.

[editline]4th July 2011[/editline]

And the hpregen still doesn’t work :confused:

Try :SetRunSpeed() then

TTT Does SetWalkSpeed, SetRunSpeed, AND SetMaxSpeed. That’s why I used SetSpeed because that’s the function that sets all 3 of those.

player_ext.lua
[lua]
function plymeta:SetSpeed(slowed)
if slowed then – badly injured
self:SetWalkSpeed(120)
self:SetRunSpeed(120)
self:SetMaxSpeed(120)
elseif slowed == 1 then – knife
self:SetWalkSpeed(275)
self:SetRunSpeed(344)
self:SetMaxSpeed(344)
else – normal
self:SetWalkSpeed(220)
self:SetRunSpeed(275)
self:SetMaxSpeed(275)
end
end
[/lua]

I edited a lil. It used to be if slowed then and else and i edited the numbers of speed

Oh god, Oh god, Oh God. Thats going every frame of the game holy SHIT. Try putting this in the SWEP of the knife’s think.

self.Owner:SetSpeed( 1 )

Erm, okay. I’ll try it.

[editline]5th July 2011[/editline]

[weapons\weapon_ttt_knife\shared.lua:52] attempt to call method ‘SetSpeed’ (a nil value)

SetWalkSpeed
SetDuckSpeed
SetRunSpeed

SetSpeed doesn’t exist.

Also people will watch the traitors heal and know they are traitors.

Try printing what ‘v:GetRole( ROLE_TRAITOR )’ and ‘GetRoundState’ return, and is GetRoundState a function? If it is, you’ll need to ensure you include the parentheses ‘()’.

SetSpeed is a function that sets SetWalkSpeed SetRunSpeed and SetMaxSpeed, as I noted in posts above…

The injury indication will not be seen.
[editline]5th July 2011[/editline]

I got the hpregen fixed. Still need help on the set speed crap though.

Are you specifying the SetSpeed function in one environment and calling it in another? i.e. server/clientside.

Oh shucks. player_ext is server isn’t it. And SWEPs are clientside for the most part…