Territories

Hello,

I know I am a new player and I will likely be looked upon as just a useless Leecher to the Community, but I am afraid I am going to ask anyway.

I am currently looking for a way to have a GUI in the top left section of the screen (anywhere in all honesty) that will show territories which can be marked out in some way. For example, someone walks into a Bank, then it switches to “Government Territory”, or when someone is out in the middle of the road it says “Neutral”. This is a cosmetic thing I am searching for on the server and I was hoping someone could show me how to do it, or even link me to a GitHub which may hold the Addon.

Regards.

Since you want to draw stuff on the screen, you’d have to use the

GM:HUDPaint hook (if you don’t know what a hook is, read this). In that hook you can draw text using

draw.SimpleText.

As for the logic to determine in which territory you are, it’s a bit trickier. You want to loop through a table of tables of coordinates and see if your current position is in any of the boxes (

Vector:WithinAABox).

Once that’s done displaying the territory name becomes trivial because all you have to do is change a variable depending on the current territory and draw different texts accordingly.

As a reference this is how I would structure my territories table.

[lua]
local territories = {
{type = “Government”, start = Vector(0, 0, 0), endpos = Vector(100, 100, 100)},
{type = “Criminal”, start = Vector(200, 200, 200), endpos = Vector(400, 400, 400)},
}
[/lua]

You wouldn’t need to make Neutral territories; for a territory to be neutral, you simply don’t have to be inside one.

I don’t think dropping links without saying anything helps. I don’t believe it’s the first time you’ve done this either. It would help if you read the thread because making a DFrame doesn’t help in this case.

Cheers, but how could I take that and mark it out so it changes when people dwell into certain areas?

[editline]19th November 2017[/editline]

So after doing some fat research and learning how to do it, then actually making it. Would it have to go into the addon folder, or into the lua/autorun/server. (Sorry for the stupid question)

You can either make it an add-on or put it in lua/autorun. lua/autorun/server is for scripts that run only on the server, but since you want to make something GUI related you know it has to be clientside.

With all of the information you have given me, would I have to make it all one big lua file then place it into the clientside of things on the server. I am pretty dumb but I would very much like to learn.

If you want to put it on your server, then yeah you can make it in one big .lua file. You would place that file in the server’s lua/autorun/ folder and add this at the beginning of the file so clients can download it:

[lua]
AddCSLuaFile()
[/lua]