Hey! I have a little trouble making the printers that does not have text, but displays info by aiming at it. Familiar to the Default darkrp Doors “(Click F2 To own this door…)” If anyone knows how I canfix this I would Apprichate help!! Any info you need? Just ask, and I will try as hard as I can to answer you.
You can use an eyetrace to detect if they look at it, and if so then draw the info.
Um, how do I do this? I am quite new to lua, I know that the Hud has something to do with the Printer I wish to make.
No one seems to Reply… So.
Does it have anything to do with CL_Init.lua?
I replied on a thread earlier for you. Read the rest of the thread, because no one wants to help someone twice with the exact same thing.
I am 100% sure you are just waiting for the code, so you don’t waste your precious time writting 10 lines long function.
Otherwise you would be long time done by now.
Considering the fact that he added me, and was wanting me to write the entire thing up for him, you are right Netheous. Not to mention I had to leave and go do something, and he spammed my chat seeing if I was there…
I am Asking for help… Because I DONT KNOW HOW. Theese forums have nice people, also bad ones Like you!! Only because i really need help with this, you dont have to call me “Lazy” I spent a lot of tine reserching before posting this. Its not that easy with lua after 2 weeks since starting?
[editline]6th January 2014[/editline]
Sorry for typos, Iphone keyboard sucks
I think the members here just get sick of people demanding code, asking to be spoon-fed, or just expecting someone to whip up code for them.
I’d recommend you look over some tutorials so the concept they explained to you won’t be so difficult to understand.
Yes you’re correct, it does have something to do with the cl_init.lua file, the printers cl_init.lua file. Basically inside the entities draw hook, which should already be hooked inside that file, have it check your eye trace for the entity. This might help you understand traces more.
You set a variable to the player’s eye trace, and then that variable will be the TraceRes, information on it here.
The TraceRes is basically a table of data about your eye trace, like if it hit an entity, the world, what position the trace ends at, and a lot of other data. You would check to make sure the Entity value in the TraceRes table does exist and then check its class to see if it’s a printer. Then you would just have it draw text, although that part depends on how you want the text to look.
Now retrieving server-side data to display, like the amount of money that’s in it or the owner of the printer is another story. I would just get down making the printer display text when you hover over it first.
local tr = util.TraceLine( util.GetPlayerTrace( LocalPlayer() ) )
if ( IsValid( tr.Entity ) and tr.Entity:GetClass() == “money_printer” ) then draw.SimpleText( “This is a money printer.”, “ChatFont”, ScrW() / 2, ScrH() / 2, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
This is what i got, seems to generate an error located in garrysmod> lua> (somewhere)
[editline]7th January 2014[/editline]
Maybe its because modification loader does not work on my dev server? Editing the main cl_hud often fucks something up.
Try the player’s eye trace instead. On top of that you literally made a trace by feeding it a different trace.
Umm, Can you send me a fixed code xD? Its as easy as that…
http://wiki.garrysmod.com/page/Player/GetEyeTrace , This is helpfull , Do you know glua a bit ?
local tr = LocalPlayer():GetEyeTrace() if (IsValid( tr.Entity) and tr.Entity:GetClass() == "money_printer") then draw.SimpleText( "This is a money printer.", "ChatFont", ScrW() / 2, ScrH() / 2, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) end
This should work.
Simply just replace the drawing with what else you wanna draw.
He could at least say thanks to people who helped him.
Yes, he should, especially after saying that he wasnt asking for code but for help then
The end part making it sound very demanding, and saying it’s as easy as that when he obviously doesn’t know how to do it, (Not implying that I know how to)
(Yay 200 posts)
Learning instead of waiting for it to be done for me was one of the best decisions I made in my life. I wish the OP had some ability to actually try or at least thank people for helping him.