Function [Request]

Started by Mötley, May 11, 2016, 06:56 PM

Previous topic - Next topic

Mötley

Okay so I would like to Hopefully see sometime a function to get a players island,

This is vital in so many ways.. Please could you accept my request :)

Thijn

GetDistrictName( x, y )
You can probably steal some of it to only return the island.
const SQChar * GetDistrictName ( float x, float y )
{
if( x > -1613.03f && y > 413.218f && x < -213.73f && y < 1677.32f )
return "Downtown Vice City";
else if( x > 163.656f && y > -351.153f && x < 1246.03f && y < 1398.85f )
return "Vice Point";
else if( x > -103.97f && y > -930.526f && x < 1246.03f && y < -351.153f )
return "Washington Beach";
else if( x > -253.206f && y > -1805.37f && x < 1254.9f && y < -930.526f )
return "Ocean Beach";
else if( x > -1888.21f && y > -1779.61f && x < -1208.21f && y < 230.39f )
return "Escobar International Airport";
else if( x > -748.206f && y > -818.266f && x < -104.505f && y < -241.467f )
return "Starfish Island";
else if( x > -213.73f && y > 797.605f && x < 163.656f && y < 1243.47f )
return "Prawn Island";
else if( x > -213.73f && y > -241.429f && x < 163.656f && y < 797.605f )
return "Leaf Links";
else if( x > -1396.76f && y > -42.9113f && x < -1208.21f && y < 230.39f )
return "Junkyard";
else if( x > -1208.21f && y > -1779.61f &&  x < -253.206f && y < -898.738f )
return "Viceport";
else if( x > -1208.21f && y > -898.738f && x < -748.206f && y < -241.467f )
return "Little Havana";
else if( x > -1208.21f && y > -241.467f && x < -578.289f && y < 412.66f )
return "Little Haiti";
else
return "Vice City";
}

Mötley

Quote from: Thijn on May 11, 2016, 07:31 PMGetDistrictName( x, y )
You can probably steal some of it to only return the island.
const SQChar * GetDistrictName ( float x, float y )
{
if( x > -1613.03f && y > 413.218f && x < -213.73f && y < 1677.32f )
return "Downtown Vice City";
else if( x > 163.656f && y > -351.153f && x < 1246.03f && y < 1398.85f )
return "Vice Point";
else if( x > -103.97f && y > -930.526f && x < 1246.03f && y < -351.153f )
return "Washington Beach";
else if( x > -253.206f && y > -1805.37f && x < 1254.9f && y < -930.526f )
return "Ocean Beach";
else if( x > -1888.21f && y > -1779.61f && x < -1208.21f && y < 230.39f )
return "Escobar International Airport";
else if( x > -748.206f && y > -818.266f && x < -104.505f && y < -241.467f )
return "Starfish Island";
else if( x > -213.73f && y > 797.605f && x < 163.656f && y < 1243.47f )
return "Prawn Island";
else if( x > -213.73f && y > -241.429f && x < 163.656f && y < 797.605f )
return "Leaf Links";
else if( x > -1396.76f && y > -42.9113f && x < -1208.21f && y < 230.39f )
return "Junkyard";
else if( x > -1208.21f && y > -1779.61f &&  x < -253.206f && y < -898.738f )
return "Viceport";
else if( x > -1208.21f && y > -898.738f && x < -748.206f && y < -241.467f )
return "Little Havana";
else if( x > -1208.21f && y > -241.467f && x < -578.289f && y < 412.66f )
return "Little Haiti";
else
return "Vice City";
}


I like that...

I was going to get aggravated and play with something like


function onPlayerIslandArea(player) {
  local pos = player.Pos;
 
  if (pos.x > -874) return 1;
  if (pos.x < -132) return 3;
 
  return 2;
}

Then set the players Island according to the return

aXXo

function GetIslandName( pos )
{
local district = GetDistrictName( pos.x, pos.y );
switch( district )
{
case "Downtown Vice City":
case "Escobar International Airport":
case "Junkyard":
case "Viceport":
case "Little Havana":
case "Little Haiti":
return "West Mainland";

case "Vice Point":
case "Washington Beach":
case "Ocean Beach":
case "Leaf Links":
return "East Mainland";

case "Starfish Island":
case "Prawn Island":
return district;

default:
return "Open Seas"
}
}

Mötley

#4
Thanks Thijn and aXXo I will attempt to do this way.
The way I wanted to do it in the end would have less, but geting pos.x correct is mind blowing..

If I over script this I can get extremely precise coordinates, as well being capable of returning names. to any little thing I want, Thank you.

Well since this is a Request forum I would like to request something that was added to [LU]

That would be function onPlayerIslandChange(player, oldisland, newisland) {This is helpful if radar icons are ran with this to prevent confusion as well as keep the radar/map clean.
This is nothing big at all just putting it out there. .

I still might use the method I was aiming for pos.x as I have a lot of scripting to do and would rather work on this at another time.

Stormeus

Quote from: Mötley on May 11, 2016, 08:09 PMWell since this is a Request forum I would like to request something that was added to [LU]

That would be function onPlayerIslandChange(player, oldisland, newisland) {This is helpful if radar icons are ran with this to prevent confusion as well as keep the radar/map clean.
This is nothing big at all just putting it out there. .

This would be useless now that it's possible for people to completely replace the default map. The concept of island separation is irrelevant.

Also, the server isn't aware of what island people are on. All it knows is vector coordinates.

aXXo

#6
onPlayerIslandChange sounds too specific. An onAreaExit and onAreaEnter is useful.
With the introduction of client side scripts and onFrame, these can be achieved with what we have currently.