Author Topic: Return Island/District, Set positions etc..  (Read 8360 times)

Motley

  • Full Member
  • ***
  • Posts: 253
  • Karma: +32/-34
    • View Profile
Return Island/District, Set positions etc..
« on: November 24, 2016, 04:18:42 pm »
This is something I have been working on for a game system I have been building.

I plan to use this differently, But I figured I should upload it while it's still in a debug state.

You can really do a lot with this script, From setting random spawns in the players district to maybe setting hospital positions for that players Island, Good for roleplay servers, To much more.

I hope someone finds use of this script. I see many ideas from this and I hope your able to do something with it  ;).

Please notify me if there are any bugs, Only bugs I have seen is district names are named differently, GetDistrictName does not always return the same text as story mode example the airport..


#Code Updated
Code: [Select]
District_ID <- array(120, 0);
District_Name <- array(120, "");

function SetPlayersDistrict(Name, player)
{
    switch(Name)
    {
        /* Portland */
        case "Harwood":                                return District_ID[player.ID] = 1;
        case "Portland Beach":                         return District_ID[player.ID] = 2;
        case "Hepburn Heights":                        return District_ID[player.ID] = 3;
        case "Saint Marks":                            return District_ID[player.ID] = 4;
        case "Red Light District":                     return District_ID[player.ID] = 5;
        case "Chinatown":                              return District_ID[player.ID] = 6;
        case "Portland View":                          return District_ID[player.ID] = 7;
        case "Trenton":                                return District_ID[player.ID] = 8;
        case "Portland Harbor":                        return District_ID[player.ID] = 9;
        case "Atlantic Quays":                         return District_ID[player.ID] = 10;
        case "Callahan Point":                         return District_ID[player.ID] = 11;

        /* To Staunton Island */
        case "Callahan Bridge":                        return District_ID[player.ID] = 12;


        case "Torrington":                             return District_ID[player.ID] = 13;
        case "Bedford Point":                          return District_ID[player.ID] = 14;
        case "Belleville Park":                        return District_ID[player.ID] = 15;
        case "Liberty Campus":                         return District_ID[player.ID] = 16;
        case "Fort Staunton":                          return District_ID[player.ID] = 17;
        case "Rockford":                               return District_ID[player.ID] = 18;
        case "Aspatria":                               return District_ID[player.ID] = 19;

        /* To Shoreside Island */
        case "Francis International Airport":          return District_ID[player.ID] = 20;
        case "Pike Creek":                             return District_ID[player.ID] = 21;
        case "Wichita Gardens":                        return District_ID[player.ID] = 22;
        case "Cedar Grove":                            return District_ID[player.ID] = 23;
        case "Cochrane Dam":                           return District_ID[player.ID] = 24;

        /* Typically in the ocean */
        case "Liberty City":                           return District_ID[player.ID] = 25;
        case "Portland":                               return District_ID[player.ID] = 26;
        case "Staunton Island":                        return District_ID[player.ID] = 27;
        default:                                       return District_ID[player.ID] = 0;
}
}

function onPlayerDeath(player, reason)
{
    District_Name[player.ID] = GetDistrictName(player.Pos.x, player.Pos.y);
   
    SetPlayersDistrict(District_Name[player.ID], player); //Do not remove player, LOL..
}

function onPlayerSpawn(player, spawn)
{
    if ( ( District_ID[player.ID] >= 1 ) && ( District_ID[player.ID] <= 12 ) && (player.Island == 1) )
    {
        Message("Portland Island")
    }

    if ( ( District_ID[player.ID] >= 12 ) && ( District_ID[player.ID] <= 19 ) && (player.Island == 2) )
    {
        Message("Staunton Island")
    }

    if ( ( District_ID[player.ID] >= 20 ) && ( District_ID[player.ID] <= 24 ) && (player.Island == 3) )
    {
        Message("Shoreside Island")
    }

    if ( ( District_ID[player.ID] >= 25 ) && ( District_ID[player.ID] <= 27 ))
    {
         if (player.Island == 1 ) Message("Portland Island/ Lost island")
         if (player.Island == 2 ) Message("Staunton Island/ Lost island")
         if (player.Island == 3 ) Message("Shoreside Island/ Lost island")

    }
}

function onPlayerPart(player, reason)
{
    District_ID[player.ID] = 0;
    District_Name[player.ID] = "";
}
« Last Edit: November 24, 2016, 05:17:00 pm by Mötley »

JamesConway

  • Newbie
  • *
  • Posts: 39
  • Karma: +9/-3
    • View Profile
Re: Return Island/District, Set positions etc..
« Reply #1 on: November 24, 2016, 04:39:50 pm »
Thank you, this is useful.

Motley

  • Full Member
  • ***
  • Posts: 253
  • Karma: +32/-34
    • View Profile
Re: Return Island/District, Set positions etc..
« Reply #2 on: November 24, 2016, 04:53:42 pm »
Your welcome  :)

Motley

  • Full Member
  • ***
  • Posts: 253
  • Karma: +32/-34
    • View Profile
Re: Return Island/District, Set positions etc..
« Reply #3 on: March 05, 2019, 06:08:01 pm »
Wrote this yesterday, All of these vectors can be found in the gta3.zon file. One of the districts returned the wrong Island. So I changed it.

Version 2:
Code: ("Client-side script") [Select]
// Island
/* X1, Y1, Z1, X2, Y2, Z2, Island */ //format
local Zones = [
[617.442, -958.347, 6.26083, 1065.44, -908.347, 206.261, 1],
[751.68, -1178.22, -13.8723, 1065.68, -958.725, 136.128, 1],
[944.208, -1149.81, -9.72576, 1016.14, -1076.01, 40.2742, 1],
[1065.88, -1251.55, -13.5049, 1501.88, -1069.93, 136.495, 1],
[1363.68, -1069.65, -18.8643, 1815.68, -613.646, 131.136, 1],
[1065.88, -1069.85, 1.49868, 1363.38, -742.054, 151.499, 1],
[745.421, -908.289, -21.203, 1065.42, -463.69, 129.593, 1],
[745.378, -463.616, -22.6676, 1065.38, -282.616, 147.332, 1],
[745.421, -282.4, -13.4117, 1065.42, -78.7699, 136.588, 1],
[1065.9, -512.324, -14.296, 1388.9, -78.324, 135.704, 1],
[745.979, -78.1778, -48.5832, 1388.98, 322.676, 101.417, 1],
[1389.37, -613.467, -29.883, 1797.6, 199.628, 120.117, 1],
[1066.1, -741.806, -34.2068, 1363.6, -512.806, 115.793, 1],
[1135.8, -695.021, 6.9661, 1182.36, -631.021, 56.9661, 1],
[1136.09, -609.976, 6.287, 1182.09, -521.167, 56.287, 1],
[617.151, -1329.72, -117.535, 1902.66, 434.115, 482.465, 1],
[1037.53, -907.274, 0.0, 1065.16, -637.689, 30.0069, 1],
[966.079, -637.366, 0.0, 1064.83, -609.557, 30.0789, 1],
[965.795, -608.99, 0.0, 995.306, -470.23, 30.9302, 1],
[995.59, -511.092, 0.0, 1065.11, -470.23, 30.0789, 1],
[1035.88, -463.56, 0.0, 1064.83, -282.86, 30.3627, 1],
[1036.15, -281.96, 0.0, 1064.85, -179.224, 30.6465, 1],
[-265.444, 161.113, -41.7094, -121.287, 367.043, 358.291, 1],
[1363.77, -613.339, -4.43849, 1389.17, -512.539, 70.4322, 1],

[444.768, -958.298, 30.7441, 614.878, -908.298, 180.744, 2],
[239.878, -411.617, 7.62939e-005, 614.322, -61.6167, 163.819, 2],
[-225.764, -412.604, -9.53674e-005, 116.236, 160.496, 120.271, 2],
[199.766, -1672.42, -61.7588, 577.766, -1059.93, 432.688, 2],
[-224.438, -1672.05, -61.3183, 199.562, -1004.45, 432.352, 2],
[200.107, -1059.19, -0.000144958, 615.107, -412.193, 198.864, 2],
[-121.567, -1003.07, -46.7463, 199.271, -413.068, 224.163, 2],
[117.268, -411.622, 0.000190735, 239.268, -61.6218, 166.36, 2],
[117.236, -61.1105, -17.071, 615.236, 268.889, 83.754, 2],
[-265.479, -1719.97, -114.769, 615.52, 367.265, 485.231, 2],
[-265.434, 79.0922, -45.8201, -226.334, 161.064, 354.18, 2],

[-1632.97, -1344.71, -45.9404, -468.629, -268.443, 254.696, 3],
[-811.835, -268.074, -45.8745, -371.041, 92.7263, 254.241, 3],
[-867.229, 93.3882, -50.1134, -266.914, 650.058, 250.426, 3],
[-1407.57, -267.966, -49.6792, -812.306, 92.7559, 250.437, 3],
[-1394.5, 93.4441, -46.7412, -867.52, 704.544, 253.344, 3],
[-1644.64, -1351.38, -117.0, -266.895, 1206.35, 483.0, 3],
[-1238.59, 306.841, -0.48605, -910.445, 504.646, 39.514, 3]
];

local Current_Island = 0;
local Current_District = "Liberty City"

NewTimer("AreaChecker", 1000, 0);
function AreaChecker() {
  local Player_Vector = FindLocalPlayer().Pos; 
  for (local idx=0;idx<42;idx++) {
    if ( ( Player_Vector.x >= Zones[idx][0] ) && ( Player_Vector.x <= Zones[idx][3] ) && ( Player_Vector.y >= Zones[idx][1] ) && ( Player_Vector.y <= Zones[idx][4] ) ) {
        if (Current_Island != Zones[idx][6]) {
            Current_Island = Zones[idx][6];
            BigMessage("" + Island(Zones[idx][6]), 8000, 1); 
        }
        if (Current_District != GetDistrictName(Player_Vector.x, Player_Vector.y)) {
            Current_District = GetDistrictName(Player_Vector.x, Player_Vector.y);
            BigMessage("" + GetDistrictName(Player_Vector.x, Player_Vector.y), 1000, 6); 
        }
    }
  }
}

// Island

// Added for testing
function onClientCommand ( Command, Input ) {
    if (Command == "island") Message(Current_Island.tostring())
    if (Command == "district") Message(Current_District.tostring())

    return 1;
}

I can add District ID's, as well my own District name return versus using GetDistrictName, but I feel like it's wasted time. You should find good uses of this script as well using it to manipulate player positions.
« Last Edit: March 06, 2019, 05:32:19 am by Motley »

 

© Liberty Unleashed Team.