'=' expected near 'vBase'


[ERROR] lua/autorun/slopefix.lua:86: '=' expected near 'vBase'
  1. unknown - lua/autorun/slopefix.lua:0

Line 86:

 float vBase = client:GetVelocity() -- idk if this is right, GetBaseVelocity()


local g_vCurrent = {} -- vector/angle;
local g_vLast = {} -- vector/angle;

local g_bOnGround = {}
local g_bLastOnGround = {}

local g_hSlopeFixEnable = CreateConVar("slopefix_enable", "1", FCVAR_NOTIFY, "Enables slope fix.");

hook.Add("StartCommand", "IDKWHATTHISISHONESTLY", function(client, cmd)

    if (g_hSlopeFixEnable:GetBool() == true) then
        g_bLastOnGround[client] = g_bOnGround[client] or false
        g_bOnGround[client] = client:IsOnGround()
        g_vLast[client]    = g_vCurrent[client];
        g_vCurrent[client] = client:GetVelocity()
        -- Check if player landed on the ground
        if (g_bOnGround[client] and not g_bLastOnGround[client]) then
            -- Set up and do tracehull to find out if the player landed on a slope
            local vPos = client:GetPos()

            local vMins = client:OBBMins()

            local vMaxs = client:OBBMaxs()

            local vEndPos = vPos * 1
            vEndPos.z = vEndPos.z - GetConVar "sv_maxvelocity":GetFloat()

            local tr = util.TraceHull{
                start = vPos,
                endpos = vEndPos,
                mins = vMins,
                maxs = vMaxs,
                mask = MASK_PLAYERSOLID_BRUSHONLY,

                filter = function(e1, e2)
                    return not e:IsPlayer()
            if(tr.Fraction ~= 1) then
                -- Gets the normal vector of the surface under the player
                local vPlane, vLast = tr.HitNormal, Vector()
                -- Make sure it's not flat ground and not a surf ramp (1.0 = flat ground, < 0.7 = surf ramp)
                if(0.7 <= vPlane.z and vPlane.z < 1.0) then
                    Copy the ClipVelocity function from sdk2013 
                    With some minor changes to make it actually work
                    vLast.x = g_vLast[client][0];
                    vLast.y = g_vLast[client][1];
                    vLast.z = g_vLast[client][2];
                    vLast.z = vLast.z - (GetConVar "sv_gravity":GetFloat() * engine.TickInterval() * 0.5);
                    local fBackOff = vLast:Dot(vPlane)

                    local change, vVel = nil, Vector()
                    change  = vPlane.x * fBackOff
                    vVel.x = vLast.x - change
                    change  = vPlane.y * fBackOff
                    vVel.x = vLast.y - change
                    change  = vPlane.z * fBackOff
                    vVel.z = vLast.z - change
                    local fAdjust = vVel:Dot(vPlane);
                    if (fAdjust < 0.0) then
                        vVel.x = vVel.x - (vPlane.x * fAdjust)
                        vVel.y = vVel.y - (vPlane.y * fAdjust)
                        vVel.z = vVel.z - (vPlane.z * fAdjust)
                    vVel.z = 0.0;
                    vLast.z = 0.0;
                    -- Make sure the player is going down a ramp by checking if they actually will gain speed from the boost
                    if (vVel:Length() > vLast:Length()) then
                        -- Teleport the player, also adds basevelocity
                        if (bit.band(client:GetFlags(), FL_BASEVELOCITY) ~= 0) then
                            float vBase = client:GetVelocity() -- idk if this is right, GetBaseVelocity()

                            vVel = vVel + vBase

Lua is weakly typed – you can only declare a variable as local to the scope, not as a specific data type.

[editline]18th February 2017[/editline]

The type wouldn’t even be right anyway, GetVelocity returns a vector.

change float to local

Thanks, I get a new error…

[ERROR] lua/autorun/slopefix.lua:40: attempt to index global 'e' (a nil value)

                filter = function(e1, e2)
                    return not e:IsPlayer()

Ok so at first I thought you just made a conversion mistake and needed our help, but now I’m getting the idea you have no idea what you’re doing and are ripping scripts from all outa nowhere getting facepunch to fix it?

Where do you expect “e” to come from? The filter function should only have one argument, make it “e” and that error will be fixed and you’ll be on to your next one. Having fun?

                filter = function(e1, e2)
                    return not e2:IsPlayer() and not e1:IsPlayer()

Hmmm ‘e2’ is nil makes no sense… I guess this code isn’t fixable.

[del]Both of you[/del]FiBzY go read the wiki. I didn’t even open the game and could read on the wiki that the filter function in util.TraceHull only is given 1 argument. Like I said in my last post.

Also not fixable? Nothing in programming is unfixable.

Here’s a resource to get you off to the right start mate, take some time to read through it and you might learn ~something~:


sorry, was thinking of another function.

[editline]19th February 2017[/editline]

Way to be an asshole, by the way I made this script for him on facepunch for free out of my own time almost exactly a year ago. No need to be a douche to him for not knowing what the code that I made, and am trying to help him does.

Go learn some manners.