#Combine Vendor

1 messages · Page 1 of 1 (latest)

brave panther
#

To avoid spamming the thread

regal plaza
#

thank

#

I like the idea of changing the tabs and buttons but

#

Im not sure what you meant by what you described

brave panther
#

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

hearty ermine
#

If you want an easy ratelimit function, to prevent spamming, I made one here #lua-help message

regal plaza
hearty ermine
#

I would suggest using vector:DistToSqr as its performance is superior

regal plaza
#

Ah that

hearty ermine
brave panther
#

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

regal plaza
#

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

hearty ermine
#

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

regal plaza
#

How would I get the Vector of the Entity?

brave panther
#

entity:GetPos()

hearty ermine
#

ent:GetPos() and ply:GetPos(), you have the player in the callback from the net message

regal plaza
#

Ah

brave panther
#

Excuse the art

regal plaza
#

I could just make a PNG and have it draw that for the button instead

#

or tab

brave panther
#

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

hearty ermine
#

surface.drawpoly has issues on x86-64

regal plaza
#

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

regal plaza
brave panther
#

I can give you some info on the basics if it would help

regal plaza
#

i didnt even know about that function though

regal plaza
brave panther
#

One sec, let me do some graphic design to explain it a little better

regal plaza
#

ah yes a developers worst nightmare, graphic design.

hearty ermine
#

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)

regal plaza
#

Does it crash the user or just mean they do not see the polygon properly

brave panther
#

The latter

regal plaza
#

I might just make a branch

#

ah

#

makes sense

hearty ermine
#

It just artifacts, I. E. Changing shape constantly

regal plaza
#

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

brave panther
#

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

regal plaza
#

are there any methods on getting the points themselves or is it just a guessing game

brave panther
#

You'll be making the points yourself

#

No guessing required

#

I can help with that as well

regal plaza
#

That'd be nice

#

If you could VC at all I think that'd be best if not that's fine

brave panther
#

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

regal plaza
#

Alright, no talking required I'd just like if you could see how I go along so you can provide tips or pointers

brave panther
#

Sure

regal plaza
#

Oh right, no streaming in GMod General Channels

#

thanks garry

brave panther
#

Is that right?

regal plaza
#

Doesn't let u

brave panther
#

I've honestly never been in them long enough to find that out

regal plaza
#

Idk if its a rule or not but it just dont let you

brave panther
#

So it doesn't

regal plaza
#

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.

brave panther
#

How did you achieve that?

regal plaza
#
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

brave panther
#

I'm going to make a suggestion, if you don't mind

regal plaza
#

Yes

brave panther
#

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

regal plaza
#

I'm gonna be so fr rn I suck at math in code so i have no clue how i would start that method

brave panther
#

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

hollow flame
#

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 😄

regal plaza
#

the amount of what?

hollow flame
regal plaza
#

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

hollow flame
#

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

regal plaza
#

Ah

hollow flame
#

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