Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 2.0 San Andreas Map
- // Made by Srdjan on 03/09/2011
- /* Changelog:
- 2.0 San Andreas Maps - in this version you no longer can go "into" the buildings, "through" the ground, etc.
- MapAndreas plug has been added and it works like a charm. Also there is new command, /trackveh and it will track
- the nearest vehicle, distance is measured in 2D. If the vehicle goes underneat the bridge or a building or in
- underground garage, the effect is lost. Also, you can use steering keys to break the effect. Zooming will not
- break the tracking effect.
- 1.0 San Andreas Maps - initial release; /map on; /map off.
- */
- #include <a_samp>
- #include <mapandreas>
- new CheckingMap [MAX_PLAYERS];
- new OldPlayerVehID [MAX_PLAYERS];
- new OldPlayerSeat [MAX_PLAYERS];
- new Float: OldPos [MAX_PLAYERS][3];
- new OldInt [MAX_PLAYERS];
- new MapTimer [MAX_PLAYERS];
- new Float: CameraPos [MAX_PLAYERS][3];
- new Float: LookAt [MAX_PLAYERS][3];
- new Float: Degrees [MAX_PLAYERS];
- new MovePlayerTimer [MAX_PLAYERS];
- new Text: MapsTD;
- new Text: Coords [MAX_PLAYERS];
- new Text: MapsAltimeterPlus;
- new Text: MapsAltimeterMinus;
- new Text: MapsAltimeterLines;
- new Altitude [MAX_PLAYERS];
- new Text: MapsMainAltLine [MAX_PLAYERS];
- new VehFocus [MAX_PLAYERS];
- enum Zones
- {
- ZoneName [28],
- Float: ZoneCoords[6]
- };
- new Location [][Zones] =
- {
- {"Los Santos", {44.60, -2892.90, 2997.00, -768.00}},
- {"Las Venturas", {869.40, 596.30, 2997.00, 2993.80}},
- {"Bone County", {-480.50, 596.30, 869.40, 2993.80}},
- {"Tierra Robada", {-2997.40, 1659.60, -480.50, 2993.80}},
- {"Tierra Robada", {-1213.90, 596.30, -480.50, 1659.60}},
- {"San Fierro", {-2997.40, -1115.50, -1213.90, 1659.60}},
- {"Red County", {-1213.90,-768.00, 2997.00, 596.30}},
- {"Flint County", {-1213.90,-2892.90, 44.60, -768.00}},
- {"Whetstone", {-2997.40, -2892.90, -1213.90, -1115.50}}
- };
- forward CheckKeys (playerid);
- forward MovePlayer (playerid);
- forward FollowVehicle (playerid, vehid);
- public OnFilterScriptInit ()
- {
- MapsTD = TextDrawCreate (10.0, 440.0, "San Andreas Maps, all rights reserved.");
- TextDrawSetShadow (MapsTD, 0);
- TextDrawUseBox (MapsTD, 1);
- TextDrawBoxColor (MapsTD, 0x00000022);
- TextDrawLetterSize (MapsTD, 0.3, 0.7);
- TextDrawTextSize (MapsTD, 300, 400);
- MapsAltimeterPlus = TextDrawCreate (10.0, 100.0, "~b~+");
- TextDrawSetShadow (MapsAltimeterPlus, 0);
- TextDrawLetterSize (MapsAltimeterPlus, 0.3, 0.7);
- TextDrawUseBox (MapsAltimeterPlus, 1);
- TextDrawBoxColor (MapsAltimeterPlus, 0xFFFFFFAA);
- TextDrawTextSize (MapsAltimeterPlus, 17.0, 8.0);
- MapsAltimeterMinus = TextDrawCreate (11.0, 225.0, "~b~-");
- TextDrawSetShadow (MapsAltimeterMinus, 0);
- TextDrawLetterSize (MapsAltimeterMinus, 0.3, 0.7);
- TextDrawUseBox (MapsAltimeterMinus, 1);
- TextDrawBoxColor (MapsAltimeterMinus, 0xFFFFFFAA);
- TextDrawTextSize (MapsAltimeterMinus, 17.0, 8.0);
- MapsAltimeterLines = TextDrawCreate (10.7, 109.0, "-~n~-~n~-~n~-~n~-~n~-~n~-~n~-~n~-~n~-~n~-~n~-~n~-~n~-~n~-~n~-~n~-~n~-");
- TextDrawSetShadow (MapsAltimeterLines, 0);
- TextDrawLetterSize (MapsAltimeterLines, 0.4, 0.7);
- for (new i = 0; i < MAX_PLAYERS; i++)
- {
- Coords [i] = TextDrawCreate (400.0, 430.0, " Location: ~n~Coordinates:");
- TextDrawSetShadow (Coords [i], 0);
- TextDrawLetterSize (Coords [i], 0.3, 0.7);
- MapsMainAltLine [i] = TextDrawCreate (9.7, 102.8, " ");
- TextDrawLetterSize (MapsMainAltLine [i], 0.6, 0.7);
- Degrees [i] = 0.0;
- CheckingMap [i] = 0;
- LookAt [i][0] = 0.0;
- LookAt [i][1] = 0.0;
- LookAt [i][2] = 0.0;
- }
- MapAndreas_Init (MAP_ANDREAS_MODE_FULL);
- printf ("\nSan Andreas Map by Srdjan loaded.\n");
- return 1;
- }
- public OnPlayerCommandText (playerid, cmdtext[])
- {
- if (!strcmp (cmdtext, "/map on", false))
- {
- if (CheckingMap [playerid]) return 1;
- CheckingMap [playerid] = 1;
- if (IsPlayerInAnyVehicle (playerid))
- {
- OldPlayerVehID [playerid] = GetPlayerVehicleID (playerid);
- OldPlayerSeat [playerid] = GetPlayerVehicleSeat (playerid);
- }
- OldInt [playerid] = GetPlayerInterior (playerid);
- GetPlayerPos (playerid, OldPos [playerid][0], OldPos [playerid][1], OldPos [playerid][2]);
- MapTimer [playerid] = SetTimerEx ("CheckKeys", 80, 1, "d", playerid);
- CheckMap (playerid);
- return 1;
- }
- if (!strcmp (cmdtext, "/map off", false))
- {
- if (!CheckingMap [playerid]) return 1;
- CheckingMap [playerid] = 0;
- TogglePlayerControllable (playerid, 1);
- SetPlayerPos (playerid, OldPos [playerid][0], OldPos [playerid][1], OldPos [playerid][2]);
- SetPlayerInterior (playerid, OldInt [playerid]);
- SetCameraBehindPlayer (playerid);
- KillTimer (MapTimer [playerid]);
- KillTimer (MovePlayerTimer [playerid]);
- Degrees [playerid] = 0.0;
- TextDrawHideForPlayer (playerid, MapsTD);
- TextDrawHideForPlayer (playerid, Coords [playerid]);
- TextDrawHideForPlayer (playerid, MapsAltimeterPlus);
- TextDrawHideForPlayer (playerid, MapsAltimeterMinus);
- TextDrawHideForPlayer (playerid, MapsAltimeterLines);
- TextDrawHideForPlayer (playerid, MapsMainAltLine [playerid]);
- if (OldPlayerVehID [playerid] > 0)
- {
- PutPlayerInVehicle (playerid, OldPlayerVehID [playerid], OldPlayerSeat [playerid]);
- }
- return 1;
- }
- if (!strcmp (cmdtext, "/trackveh", false))
- {
- if (!CheckingMap [playerid]) return 1;
- if (VehFocus [playerid] > 0) return 1;
- new Float: distance = 250.0, ID = -1;
- for (new vehid = 1; vehid < MAX_VEHICLES; vehid++)
- {
- new Float: x, Float: y, Float: z;
- if (GetVehiclePos (vehid, x, y, z))
- {
- x -= CameraPos [playerid][0];
- y -= CameraPos [playerid][1];
- new Float: dist = floatsqroot ((floatpower (x, 2)) + (floatpower (y, 2)));
- if (distance > dist)
- {
- distance = dist;
- ID = vehid;
- }
- }
- }
- if (ID > 0)
- {
- VehFocus [playerid] = SetTimerEx ("FollowVehicle", 100, 1, "dd", playerid, ID);
- }
- return 1;
- }
- return 0;
- }
- public CheckKeys (playerid)
- {
- new keys, updown, leftright, boost, Float: maxZ;
- GetPlayerKeys (playerid, keys, updown, leftright);
- if (!CheckingMap [playerid]) return 1;
- if (updown == KEY_UP)
- {
- if (keys == KEY_WALK)
- {
- MapAndreas_FindZ_For2DCoord (CameraPos [playerid][0], CameraPos [playerid][1], maxZ);
- if (CameraPos [playerid][2] - 15 >= maxZ)
- {
- CameraPos [playerid][2] = CameraPos [playerid][2] - 10.0;
- Altitude [playerid] --;
- }
- }
- else
- {
- if (CameraPos [playerid][2] < 75.0)
- {
- boost = 2;
- }
- else if (CameraPos [playerid][2] < 150.0)
- {
- boost = 5;
- }
- else if (CameraPos [playerid][2] < 300.0)
- {
- boost = 10;
- }
- else if (CameraPos [playerid][2] >= 300.0)
- {
- boost = 30;
- }
- MapAndreas_FindZ_For2DCoord (CameraPos [playerid][0], CameraPos [playerid][1], maxZ);
- while (maxZ > CameraPos [playerid][2])
- {
- CameraPos [playerid][2] = CameraPos [playerid][2] + 10.0;
- Altitude [playerid]++;
- }
- if (VehFocus [playerid] > -1)
- {
- KillTimer (VehFocus [playerid]);
- VehFocus [playerid] = -1;
- }
- }
- CameraPos [playerid][0] = CameraPos [playerid][0] + (boost * floatsin (-Degrees [playerid], degrees));
- CameraPos [playerid][1] = CameraPos [playerid][1] + (boost * floatcos (-Degrees [playerid], degrees));
- MovePlayerCamera (playerid);
- }
- else if (updown == KEY_DOWN)
- {
- if (keys == KEY_WALK)
- {
- if (CameraPos [playerid][2] < 650.0)
- {
- CameraPos [playerid][2] = CameraPos [playerid][2] + 10.0;
- Altitude [playerid] ++;
- }
- }
- else
- {
- if (CameraPos [playerid][2] < 75.0)
- {
- boost = 2;
- }
- else if (CameraPos [playerid][2] < 150.0)
- {
- boost = 5;
- }
- else if (CameraPos [playerid][2] < 300.0)
- {
- boost = 10;
- }
- else if (CameraPos [playerid][2] >= 300.0)
- {
- boost = 30;
- }
- MapAndreas_FindZ_For2DCoord (CameraPos [playerid][0], CameraPos [playerid][1], maxZ);
- while (maxZ > CameraPos [playerid][2])
- {
- CameraPos [playerid][2] = CameraPos [playerid][2] + 10.0;
- Altitude [playerid]++;
- }
- if (VehFocus [playerid] > -1)
- {
- KillTimer (VehFocus [playerid]);
- VehFocus [playerid] = -1;
- }
- }
- CameraPos [playerid][0] = CameraPos [playerid][0] - (boost * floatsin (-Degrees [playerid], degrees));
- CameraPos [playerid][1] = CameraPos [playerid][1] - (boost * floatcos (-Degrees [playerid], degrees));
- MovePlayerCamera (playerid);
- }
- if (leftright == KEY_LEFT)
- {
- if (keys == KEY_WALK)
- {
- Degrees [playerid] = Degrees [playerid] + 5.0;
- if (Degrees [playerid] == 360)
- {
- Degrees [playerid] = 0;
- }
- }
- else
- {
- if (CameraPos [playerid][2] < 75.0)
- {
- boost = 2;
- }
- else if (CameraPos [playerid][2] < 150.0)
- {
- boost = 5;
- }
- else if (CameraPos [playerid][2] < 300.0)
- {
- boost = 10;
- }
- else if (CameraPos [playerid][2] >= 300.0)
- {
- boost = 30;
- }
- MapAndreas_FindZ_For2DCoord (CameraPos [playerid][0], CameraPos [playerid][1], maxZ);
- while (maxZ > CameraPos [playerid][2])
- {
- CameraPos [playerid][2] = CameraPos [playerid][2] + 10.0;
- Altitude [playerid]++;
- }
- if (VehFocus [playerid] > -1)
- {
- KillTimer (VehFocus [playerid]);
- VehFocus [playerid] = -1;
- }
- }
- CameraPos [playerid][0] = CameraPos [playerid][0] + (boost * floatsin (-Degrees [playerid] - 90.0, degrees));
- CameraPos [playerid][1] = CameraPos [playerid][1] + (boost * floatcos (-Degrees [playerid] - 90.0, degrees));
- MovePlayerCamera (playerid);
- }
- else if (leftright == KEY_RIGHT)
- {
- if (keys == KEY_WALK)
- {
- Degrees [playerid] = Degrees [playerid] - 5.0;
- if (Degrees [playerid] < 0)
- {
- Degrees [playerid] = 355;
- }
- }
- else
- {
- if (CameraPos [playerid][2] < 75.0)
- {
- boost = 2;
- }
- else if (CameraPos [playerid][2] < 150.0)
- {
- boost = 5;
- }
- else if (CameraPos [playerid][2] < 300.0)
- {
- boost = 10;
- }
- else if (CameraPos [playerid][2] >= 300.0)
- {
- boost = 30;
- }
- MapAndreas_FindZ_For2DCoord (CameraPos [playerid][0], CameraPos [playerid][1], maxZ);
- while (maxZ > CameraPos [playerid][2])
- {
- CameraPos [playerid][2] = CameraPos [playerid][2] + 10.0;
- Altitude [playerid]++;
- }
- if (VehFocus [playerid] > -1)
- {
- KillTimer (VehFocus [playerid]);
- VehFocus [playerid] = -1;
- }
- }
- CameraPos [playerid][0] = CameraPos [playerid][0] + (boost * floatsin (-Degrees [playerid] + 90.0, degrees));
- CameraPos [playerid][1] = CameraPos [playerid][1] + (boost * floatcos (-Degrees [playerid] + 90.0, degrees));
- MovePlayerCamera (playerid);
- }
- MovePlayerCamera (playerid);
- return 1;
- }
- MovePlayerCamera (playerid)
- {
- new str[128];
- format (str, sizeof (str), " Location: %s~n~Coordinates: x = %.2f y = %.2f", LocationName (CameraPos [playerid][0], CameraPos [playerid][1]), CameraPos [playerid][0], CameraPos [playerid][1]);
- TextDrawSetString (Coords [playerid], str);
- TextDrawShowForPlayer (playerid, Coords [playerid]);
- TextDrawSetString (MapsMainAltLine [playerid], AltimeterLine (Altitude [playerid]));
- TextDrawShowForPlayer (playerid, MapsMainAltLine [playerid]);
- SetPlayerCameraPos (playerid, CameraPos [playerid][0], CameraPos [playerid][1], CameraPos [playerid][2]);
- SetPlayerCameraLookAt (playerid, CameraPos [playerid][0] + (floatsin (-Degrees [playerid], degrees)), CameraPos [playerid][1] + (floatcos (-Degrees [playerid], degrees)), 0.0);
- }
- AltimeterLine (Alt)
- {
- new str[64], k;
- if (Alt > 43)
- {
- Alt = Alt - 5;
- k++;
- }
- while (Alt > 23)
- {
- Alt = Alt - 4;
- k++;
- }
- while (Alt > 2)
- {
- Alt = Alt - 3;
- k++;
- }
- for (new i = 0; i <= k; i++)
- {
- strcat (str, "~n~", sizeof (str));
- }
- strcat (str, "~r~-", sizeof (str));
- return str;
- }
- CheckMap (playerid)
- {
- TextDrawShowForPlayer (playerid, MapsTD);
- TextDrawShowForPlayer (playerid, Coords [playerid]);
- TextDrawShowForPlayer (playerid, MapsAltimeterPlus);
- TextDrawShowForPlayer (playerid, MapsAltimeterMinus);
- TextDrawShowForPlayer (playerid, MapsAltimeterLines);
- TextDrawShowForPlayer (playerid, MapsMainAltLine [playerid]);
- Altitude [playerid] = 8;
- SetPlayerInterior (playerid, 0);
- CameraPos [playerid][0] = 0.0;
- CameraPos [playerid][1] = 0.0;
- CameraPos [playerid][2] = 100.0;
- SetPlayerPos (playerid, 0.0, 0.0, -10.0);
- SetPlayerCameraPos (playerid, 0.0, 0.0, 100.0);
- SetPlayerCameraLookAt (playerid, 0.0, 0.1, 0.0);
- TogglePlayerControllable (playerid, 0);
- MovePlayerTimer [playerid] = SetTimerEx ("MovePlayer", 1000, 1, "d", playerid);
- }
- public MovePlayer (playerid)
- {
- SetPlayerPos (playerid, CameraPos [playerid][0], CameraPos [playerid][1], -50.0);
- return 1;
- }
- LocationName (Float: x, Float: y)
- {
- new str[28];
- for (new i = 0; i != sizeof (Location); i++)
- {
- if (x >= Location [i][ZoneCoords][0] && x <= Location [i][ZoneCoords][2] && y >= Location [i][ZoneCoords][1] && y <= Location [i][ZoneCoords][3])
- {
- format (str, sizeof (str), "%s", Location [i][ZoneName]);
- }
- }
- return str;
- }
- public OnPlayerDisconnect (playerid, reason)
- {
- OnPlayerCommandText (playerid, "/map off");
- return 1;
- }
- public FollowVehicle (playerid, vehid)
- {
- new Float: x, Float: y, Float: z;
- GetVehiclePos (vehid, x, y, z);
- new Float: maxZ;
- MapAndreas_FindZ_For2DCoord (x, y, maxZ);
- if (maxZ > z)
- {
- KillTimer (VehFocus [playerid]);
- }
- else
- {
- CameraPos [playerid][0] = x;
- CameraPos [playerid][1] = y;
- }
- while (maxZ > CameraPos [playerid][2])
- {
- CameraPos [playerid][2] = CameraPos [playerid][2] + 10.0;
- Altitude [playerid]++;
- }
- MovePlayerCamera (playerid);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement