gmod_vehicle_viewmode - Error?

Hello everyone…

I got a problem with calcview.

The function:


function GM:CalcView( ply, origin, angles, fov )
	
	local Vehicle = ply:GetVehicle()
	lookForVT(Vehicle);
	
	local wep = ply:GetActiveWeapon()

	
	if ( IsValid( Vehicle ) && 
		(gmod_vehicle_viewmode:GetInt() == 1)                    **<--- This is the error line.**
		 /*&& ( !IsValid(wep) || !wep:IsWeaponVisible() )*/
		) then
		
		return GAMEMODE:CalcVehicleThirdPersonView( Vehicle, ply, origin*1, angles*1, fov )
		
	end


	local view = {}
	view.origin 	= origin
	view.angles		= angles
	
	
	if ply:InVehicle() then
	
	
		if (Vehicle.vehicleTable && Vehicle.vehicleTable.ViewAdjustments_FirstPerson) then
			if (Vehicle.vehicleTable.ViewAdjustments_FirstPerson == VIEW_LOCK) then
				view.angles	= ply:GetAimVector():Angle();
			else
				view.origin = origin + 
						(ply:GetVehicle():GetAngles():Up() * Vehicle.vehicleTable.ViewAdjustments_FirstPerson.z) + 
						(ply:GetVehicle():GetAngles():Forward() * Vehicle.vehicleTable.ViewAdjustments_FirstPerson.x) + 
						(ply:GetVehicle():GetAngles():Right() * Vehicle.vehicleTable.ViewAdjustments_FirstPerson.y);
			end
		end
	end;

	
	view.fov 		= fov
	
	
	if ( IsValid( wep ) ) then
	
		local func = wep.GetViewModelPosition
		if ( func ) then
			view.vm_origin,  view.vm_angles = func( wep, origin*1, angles*1 ) 
		end
		
		local func = wep.CalcView
		if ( func ) then
			view.origin, view.angles, view.fov = func( wep, ply, origin*1, angles*1, fov )
		end
	
	end
	
	return view
end

The error:


calc_view.lua:42: attempt to index global 'gmod_vehicle_viewmode' <a nil value>

I tried changing it to:


gmod_vehicle_viewmode = CreateClientConVar( "gmod_vehicle_viewmode", "1")

That didn’t work. I hope someone can help? :slight_smile:

gmod_vehicle_viewmode doesn’t exist, find out why?

Oh. So it was removed in Gmod 13?

Possibly, you may be accessing the convar wrong; that might of been changed in Gmod 13.

Hmm could be. But I looked at the wiki page and found this: Wiki Page

I can’t see any changes to it?

gmod_vehicle_viewmode was removed and changed to something different, stop trying to fix PERP.

Well I accept that you just don’t like PERP, but thanks still for the information. So now I am asking someone else…

So gmod_vehicle_viewmode was changed, I tried searching around on Google for any changes to it, but there was nothing to find there. I also tired putting in:


gmod_vehicle_viewmode = CreateClientConVar( "gmod_vehicle_viewmode", "1", true, true )

In the base/cl_init.lua. That removes the error, but the player disrepair from the vehicle… Plus I don’t think that that is the right fix for it?

[editline]2nd January 2013[/editline]

It’s working now…