Printer wont print in front of printer always [DarkRP]

So I have my own DarkRP server and I have a money printer I made, so it sets the pos of the money it spawns based on the pos of the printer. See the thing is it doesnt get the angle so all it does is printers 25+ the x pos of the printer. I want to get it to always be able to print in front of the printer if you turn the printer or something, but I dont want to have to make it a storage type printer where it doesnt create money it just holds it and you click use to get the money. I tried getting the printer pos and I tested the four 90 degree angles but if I set the money to spawn depending on the angles it didnt work for me, any help would be appreciated please and thank you.



     local MoneyPos = self:GetPos()
     amount = 1000
	
     local moneybag = DarkRP.createMoneyBag(Vector(MoneyPos.x + 25, MoneyPos.y, MoneyPos.z + 5), amount)


https://github.com/FPtje/DarkRP/blob/master/entities/entities/money_printer/init.lua - use the lines 91 to 115 to help you.

Thats the pretty much the exact same code I have though. ;-;

Completely forgot DarkRP printers spawn the money on top, not needing to use vectors. So you will need to use this: https://wiki.garrysmod.com/page/Category:Vector.

I already use a vector though which spawns it in front of the printer or at least when it first spawns but then when you rotate it it still spawns the same place as last time which isnt the front of the printer anymore because its rotated.

You need to use vectors. I think you understand why your code isn’t working, but basically you’re just adding on to the X, Y or Z coordinates regardless of where the printer is facing.

If you think of the xpos you’re using now as this:
[LUA]MoneyPos.X + ( 25 * xDirection )[/LUA]

Then what you actually want is:
[LUA]MoneyPos.X + ( 25 * frontOfPrinterDirection )[/LUA]

Which in Glua would be done by:
[LUA]MoneyPos.X + ( 25 * MoneyPos:GetForward() )[/LUA]

If you don’t know about unit vectors and are confused why you need to multiply instead of add, then I’ll briefly try and explain it.
Unit (normalised) vectors are vectors with a length of 1. They basically just represent a direction in 3D space (in this case).
(x, y, z) is the format, so (1, 0, 0) would be a unit vector for the X direction.
Multiplying the unit vector for the X direction by a certain amount is the same as adding to that direction.

For example: (0, 0, 0) + (5, 0, 0) and (0, 0, 0) + ( 5 * (1, 0, 0) ) both give the same result, (5, 0, 0) which is 5 units in the X direction.

However, vectors don’t always have to be in a single direction. Say if your money printer is facing 45 degrees, so between the X and Y direction, it’s vector would be (0.5, 0.5, 0).
How would you then add 5 units in this direction? Just multiply the vector by 5 and add it to the position.

(0, 0, 0) + ( 5 * (0.5, 0.5, 0) ) gives (2.5, 2.5, 0), which is 5 units in the XY diagonal direction and is where the money would be placed.

The easy, no-need-to-think-about-it solution that accomplishes the same thing as the post above me is

Entity:LocalToWorld, used like this:

[lua]local moneybag = DarkRP.createMoneyBag(self:LocalToWorld(Vector(25, 0, 5)), amount)[/lua]

Would I multiply the getfoward to each of the x y and z or just x and y? or just x?

Edit: Nvm thank you
Nvm again if I do



local MoneyPos = self:GetPos()
local MoneyPosX = self:GetForward()
amount = 1000

DarkRP.createMoneyBag(Vector(MoneyPos.x + ( 25 * MoneyPosX ), MoneyPos.y + ( 25 * MoneyPosX ), MoneyPos.z + 5), amount)


It gives me the error Expected Vector got number any help on that unless im stupid and doing it wrong

[editline]27th July 2017[/editline]

Well this works but im a nerd so ima continue to test around the multiply the vector.