#Combine Vendor
1 messages · Page 1 of 1 (latest)
thank
I like the idea of changing the tabs and buttons but
Im not sure what you meant by what you described
To check a player's distance to the vendor, you'll want to get the player's position when they try to buy something (On the server side!) and use Vector:Distance() to find out how far away they are from the position of the vendor entity
If you want an easy ratelimit function, to prevent spamming, I made one here #lua-help message
I'm afraid I do not know the functionality of ratelimiting could you describe how this would be useful to be implemented?
I would suggest using vector:DistToSqr as its performance is superior
Ah that
You would just add this in your project, then call the code underneath inside your net to prevent it from running within x
I wouldn't worry too much about optimizing your performance right now, just make sure it works. If performance is a problem in the future, you can revisit the issue
it works it's just I'm not sure how to use the DistToSqr function
I personally have not seen it's implementation and there are no examples in the Wiki
Whichever works for you, you use it the same as distance, except you sqr the number and compare
local near = positiona:DistToSqr(positionb) < 300*300 vs local near = positiona:Distance(positionb) < 300
How would I get the Vector of the Entity?
entity:GetPos()
ent:GetPos() and ply:GetPos(), you have the player in the callback from the net message
Ah
This is essentially what I was thinking
Excuse the art
Oh I see
I could just make a PNG and have it draw that for the button instead
or tab
If you'd like to learn a little bit more while you're doing it, you could draw a polygon instead of an image
That way it wouldn't ever look pixelated
Polygons can seem a little scary but it's really not as bad as it might seem
surface.drawpoly has issues on x86-64
I could but I dont know how I would even achieve the effect there using that, I wanted to do that quite some time ago but had no clue how to draw that
which is, funnily enough, what i run
I can give you some info on the basics if it would help
i didnt even know about that function though
That would help tremendously
One sec, let me do some graphic design to explain it a little better
ah yes a developers worst nightmare, graphic design.
that drawpoly issue affects a small amount of users from what I've seen, but it effectively causes many artifacts
(and it doesn't happen on mainbranch)
Does it crash the user or just mean they do not see the polygon properly
The latter
It just artifacts, I. E. Changing shape constantly
Btw I took inspiration from Power Plant RP in making this, I even used one of the sounds (tablet sound) for the command module boot
This is basically what you're going to be doing when drawing a polygon.
You define a bunch of points with X, Y coordinates and Garry's Mod is going to try to connect them together and fill in the middle with whatever color you're using
are there any methods on getting the points themselves or is it just a guessing game
You'll be making the points yourself
No guessing required
I can help with that as well
I'm coming down with something that's affecting my voice so I can't spend too much time talking but I'm happy to
Alright, no talking required I'd just like if you could see how I go along so you can provide tips or pointers
Sure
Is that right?
Doesn't let u
I've honestly never been in them long enough to find that out
Idk if its a rule or not but it just dont let you
So it doesn't
I was able to achieve the effect you presented, but on a HUD. I will transfer it and polish it here so it looks better.
How did you achieve that?
local cmbButton = {
{ x = 110, y = 200 },
{x = 75, y = 180},
{x = 210, y = 180},
{x = 210, y = 200},
}
hook.Add("HUDPaintBackground", "cmbButtonPoly", function()
-- draw the polygon in this hook
surface.SetDrawColor( 0, 90, 255, 255 )
surface.DrawPoly( cmbButton )
end) ```
It's backwards when drawn on the HUD but I can just flip it
I'm going to make a suggestion, if you don't mind
Yes
I'm working on a graphic to better illustrate this, but I would strongly suggest you create those points via math rather than manually defined points
I'm gonna be so fr rn I suck at math in code so i have no clue how i would start that method
Not a problem
It's going to be easier than you think
I'm going to visually outline how you might create the function
DrawCombineButton( buttonPos, buttonWidth, buttonHeight )
Okay, so just as a starting point, let's try drawing a simple rectangle using that function
There are four points required to draw a rectangle
I've left one of the points undefined here to give you a chance to play with it yourself
At the end of the day almost everything we're going to be doing here is some brand of addition or subtraction
I personally would make the users also send the amount of money they want to buy the weapon for inside the net messages
that way they can attempt change it and easily get detected 😄
the amount of what?
money or w.e currency
Ah
Paying for the weapon is tied within the net message itself so there would be no point as purchasing anything already subtracts a given number from the total
I mean if a gun costs $500 and they attempt to buy it at $1 you can log it and know someone is attempting to exploit
Ah
another thing I notice is that when you switch tabs there are 4 items on one page and another page with 4 items
yet the placement of the items change even though there is still 4 items
perhaps you could use https://wiki.facepunch.com/gmod/DGrid or https://wiki.facepunch.com/gmod/Panel:Dock