1. Post #1
    flyguy88's Avatar
    July 2007
    336 Posts
    The jetpack seems to be less effective as your ping goes up, i tested it with other players and myself using net_fakelag 200.
    My boost wouldn't be nearly as powerful if i had net_fakelag on and my bots would stay the same.

    I have a jetpack function in shared.lua -
    Code:
    local meta = FindMetaTable("Player")
    if (!meta) then return end
    
    function meta:JetPack()
    
    --Vector(0,0,self:GetVelocity()[3]) <cool
        local boostmagnitude = 10
        if (self.boost > 0) then
            --self.boost = self.boost - global_boostreductionrate
        self:SetGroundEntity(NULL)
            --self:SetGroundEntity(NULL)
            self:SetVelocity(self:GetUp() * boostmagnitude)
            local effectdata = EffectData()
            effectdata:SetOrigin(self:GetPos())
            util.Effect( "pixiehit", effectdata)
        end
    end
    I am running it here, in init.lua -
    Code:
    function Handlejetpack()
    
        for k,v in pairs(player.GetAll()) do if v.jetpack == true then v:JetPack() else v:JetPackRegen() end end
        
    end
    
    --hook.Add("Think", "handlingjets", Handlejetpack)
    timer.Create( "JetPackCheckTimer", 0.01, 0, Handlejetpack)
    The jetpack is toggled here -
    Code:
    function Toggleonjet(pl, key)
        if key == IN_ATTACK2 then
            pl.jetpack = true
        end
    end
    hook.Add("KeyPress", "tooto", Toggleonjet)
    
    function Toggleoffjet(pl, key)
        if key == IN_ATTACK2 then
            pl.jetpack = false
        end
    end
    hook.Add("KeyRelease", "foekfosokf", Toggleoffjet)
    I'd be grateful if anyone could shed any light on the problem.

    Here is a video example, I have net_fakelag on 200 here and a bot(the bot has no ping of course).

    http://farmpolice.com/content/videos...YELsIgmGr.webm


  2. Post #2
    flyguy88's Avatar
    July 2007
    336 Posts
    Fixed

    I'm not sure why this was happening but here is what i did.

    new jetpack function, essentially the same.

    Code:
    function meta:JetPackOn()
        local boostmagnitude = 50
        if (self.boost > 0) then
        self:SetGroundEntity(NULL)
        self:SetVelocity(self:GetUp() * boostmagnitude)
                local effectdata = EffectData()
            effectdata:SetOrigin(self:GetPos())
            util.Effect( "pixiehit", effectdata)
        end
    end
    Code:
    function Toggleonjet(pl, key)
        if key == IN_ATTACK2 then
            pl.jetpack = true
            --timer.Start(pl:GetName())
            timer.Create(pl:GetName(), 0.1, 0, function () pl:JetPackOn() end)
        end
    end
    hook.Add("KeyPress", "tooto", Toggleonjet)
    Toggling timers for each individual worked perfectly compared to the other method.

    Code:
    function Toggleoffjet(pl, key)
        if key == IN_ATTACK2 then
            pl.jetpack = false
            --timer.Stop(pl:GetName())
            timer.Destroy(pl:GetName())
        end
    end
    hook.Add("KeyRelease", "foekfosokf", Toggleoffjet)