• '=' expected near 'vBase'
    8 replies, posted
Error: [CODE][ERROR] lua/autorun/slopefix.lua:86: '=' expected near 'vBase' 1. unknown - lua/autorun/slopefix.lua:0[/CODE] Line 86: [CODE] float vBase = client:GetVelocity() -- idk if this is right, GetBaseVelocity()[/CODE] Slopefix.lua [CODE]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() end } 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 (https:--mxr.alliedmods.net/hl2sdk-sdk2013/source/game/shared/gamemovement.cpp#3145) 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) end 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 end client:SetVelocity(vVel); end end end end end end)[/CODE]
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
[QUOTE=MeepDarknessM;51841727]change float to local[/QUOTE] Thanks, I get a new error... [CODE][ERROR] lua/autorun/slopefix.lua:40: attempt to index global 'e' (a nil value)[/CODE] [CODE] filter = function(e1, e2) return not e:IsPlayer() end[/CODE]
[QUOTE=FiBzY;51842460]Thanks, I get a new error... [CODE][ERROR] lua/autorun/slopefix.lua:40: attempt to index global 'e' (a nil value)[/CODE] [CODE] filter = function(e1, e2) return not e:IsPlayer() end[/CODE][/QUOTE] [CODE] filter = function(e1, e2) return not e2:IsPlayer() and not e1:IsPlayer() end[/CODE]
Hmmm 'e2' is nil makes no sense.... I guess this code isn't fixable.
e1:IsPlayer() sorry, was thinking of another function. [editline]19th February 2017[/editline] [QUOTE=thejjokerr;51842615]Both of you 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~: [url]https://www.lua.org/manual/5.3/[/url][/QUOTE] 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.
Sorry, you need to Log In to post a reply to this thread.