Jump to content

[REL] Custom Districts


Dzsozi (h03)

Recommended Posts

21366.png

 

With this script you are able to create your custom districts in MTA:SA, this is useful for almost "anything" (custom maps with your own districts, gang zones (which might require a little editing), protect zones, etc.)!
You can create your own districts in the districtC.lua file, an example is given.

Export functions:
- getDistrictName(element)
Get the custom district name of an element (works client and server side)
- onElementDistrictChange
This is a custom event, the source of this event is the element that changed district (currently working only client-side)
PARAMETERS: districtName - An integer representing the name of the current custom district

Note that the event works on client-side, but it is possible to do it on server-side if it's needed.

!! The source of the onElementDistrictChange event is the element that changed the district, could be a vehicle, a ped, a player, anything that is an element. !!

An example script for using the event and getting the district name is given in the exampleC.lua file, check that for usage and the example command.

Future versions MIGHT contain:
- Server-sided onElementDistrictChange event
- A command to add a district manually

Special thanks to for helping with the script to: Tails, pa3ck
If you have any question just write a comment! Feel free to edit, but please, keep the credits.

 

DOWNLOAD: https://community.multitheftauto.com/index.php?p=resources&s=details&id=13834

Images:

21365.png

/getpos - If currently NOT in a custom district

 

21364.png

/getpos - If currently in a custom district

 

21363.png

Entering a custom district

  • Like 1
Link to comment
local radarArea = createRadarArea (0, 0, 100, 200, 255, 225, 255, 150 )
setElementData(radarArea, "name", "Example District Name", false)

function GetAreaName()
	local x, y = getElementPosition(localPlayer)
	for key, area in pairs(getElementsByType("radararea")) do
		local sizeX,sizeY = getRadarAreaSize(area)
		local rX,rY = getElementPosition(area)
		if x > rX and x < rX+sizeX and y>rY and y<rY+sizeY then
			return getElementData(area, "name")
		end
	end
end

same "resource" in 12 lines

  • Like 2
Link to comment
1 hour ago, AfterAll14 said:

Absolutely agree. Masterpiece of scripting we have here. 56 lines of code in 3!!!!! lua files, and a separate export funtion is very reasonable for this case.

But the most important about this script - the guy was so genius, he didn't even bother making something new by himself. He simply renamed radar areas into "districs" - and BOOOM!!! It's a brand new entity for GTA SA!

Haha, thank you!!

  • Like 1
Link to comment
13 hours ago, AfterAll14 said:

Absolutely agree. Masterpiece of scripting we have here. 56 lines of code in 3!!!!! lua files, and a separate export funtion is very reasonable for this case.

But the most important about this script - the guy was so genius, he didn't even bother making something new by himself. He simply renamed radar areas into "districs" - and BOOOM!!! It's a brand new entity for GTA SA!

 

  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...