SetModelScale - after gmod 13?


I need help to figure out what I am doing wrong here:

local matOutlineWhite 	= Material( "white_outline" )
local ScaleNormal		= Vector()
local ScaleOutline1		= Vector() * 1
local ScaleOutline2		= Vector() * 1.1
local matOutlineBlack 	= Material( "black_outline" )

function ENT:DrawEntityOutline( size )
	size = size or 1.0
	render.SuppressEngineLighting( true )
	render.SetAmbientLight( 1, 1, 1 )
	render.SetColorModulation( 1, 1, 1 )
		// First
		self:SetModelScale( ScaleOutline2 * size )
		render.MaterialOverride( matOutlineBlack )
		// Second
		self:SetModelScale( ScaleOutline1 * size )
		render.MaterialOverride( matOutlineWhite )
		// Revert everything back
		render.MaterialOverride( nil )
		self:SetModelScale( ScaleNormal )
	render.SuppressEngineLighting( false )
	local c = self:GetColor()
	local r,g,b,a = c.r, c.g, c.b
	render.SetColorModulation( c.r/255, c.g/255, c.b/255 )


I get this error:

bad argument #2 to 'SetModelScale' <expected, got no value>

I have tried changing it to some different things but nothing seams to be working? I know it changed in gmod 13 but I’m not sure how to convert it?

self:SetModelScale( ScaleOutline2 * size, 0 )

Edit -

Didn’t see that vector, derp

Didn’t work? Anyways thanks for the reply.

Any other ideas?

I use this:
local Entity = FindMetaTable(“Entity”)
if !Entity then return end

function Entity:SetModelScale(scale)
local mat = Matrix()
self:EnableMatrix(“RenderMultiply”, mat)

if CLIENT then

Uhmm okay. I have trouble making it work, but I’ll try some different things. ?

What do you mean? All the code I gave you works 100%.

The code you gave me is not the problem. The problem is to put it in the code I’m trying to fix, so it works correctly.

Derp, My bad, Didn’t see you where using Vector.

The new SetModelScale takes an overall scale, and a time to go into that scale, So using SetModelScale( 1, 0 ) will make it the original size.

SetModelScale( 0.5, 0 ) makes it half the size.

Thanks man! :). That worked.

I got this one too witch is a bit more complicated:

local SHeight = 5;
local SWidth = 2.5
local MaxHeight = 25;
local MaxWidth = 15;

function ENT:Draw()
	local GrowthPercent = (CurTime() - self.SpawnTime) / GROW_TIME;

	if GrowthPercent <= 1 then
		local W = SWidth + (GrowthPercent * MaxWidth );
		self:SetModelScale(.05 * Vector(W, W, SHeight + (GrowthPercent * MaxHeight)));

I tried doing this:

self:SetModelScale(.05 * Vector(W, W, 5 + (GrowthPercent * 25)));

But that didn’t work? What did I do wrong? Something about the Vector part?

Uhm. I should be able to use the:

local SHeight = 5;
local SWidth = 2.5
local MaxHeight = 25;
local MaxWidth = 15;


I tried this too be with no luck:

self:SetModelScale(.05 * Vector(W, W, 5 + (1 * 25)));

I don’t know what I’m doing wrong here? but i guess it this something about the first part with the: W, W?

Garry fucked up and basically forbidden us to scale anything using a vector, All you can do now is change the overall size. :confused:

Uhmm okay. Well that makes this really hard, the old code made a plant grow? I have not idea how to do that now?

[editline]28th December 2012[/editline]

Well I guess I could just use:

self:SetModelScale( 5, 0 )

But that only sets the size of it? Is there some way to set like a timer or something for how long it would take to grow? And make a size bigger and bigger over time?

You could change the scale constantly with a float, like say.

self.PlantSize = 0

if self.PlantSize < 5 then

self.PlantSize = math.Clamp(self.PlantSize + RealFrameTime()*5,0,5)

self:SetModelScale( self.PlantSize, 0 )


Hmm yes that kinda work, but It’s extremely laggy?

With the code I posted you can change it by a Vector scale.

Okay I’ll try use that then. Though I don’t understand it 100%. But thanks anyways. :slight_smile: