Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/15/19 in all areas

  1. Basically, this tutorial is for teleporting in x, y-axis by getting player heading angle (rotation). - Note: If our entity is a vehicle and the player is the driver or passanger, we can use player's heading due they are same. We can behave with heading angle just like a compass and its points, a compass with marked angles The angle of player heading is exactly behave like the angle of a compass in map. But how we can go front or rear in 10 units while we have x and y axis? We need to have the angles' ranges, the below table is calculated by me: N > NW = 0.0 - 22.5 NW = 22.5 - 67.5 W = 67.5 - 112.5 SW = 112.5 - 157.5 S = 157.5 - 202.5 SE = 202.5 - 247.5 E = 247.5 - 292.5 NE = 292.5 - 332.5 NW > N = 332.5 - 360.0 Then, we have to calculate X and Y axis from the angle, consider amount as the units we need to move in that axis N > NW = Y + Amount NW = X - Amount / 2 | Y + Amount / 2 W = X - Amount SW = X - Amount / 2 | Y - Amount / 2 S = Y - Amount SE = Y - Amount / 2 E = X + Amount NE = X + Amount / 2 NW > N = Y + Amount / 2 Based on conditions, we can use entity::position (vehicle / player or anything that we want to teleport in x, y axis) - Note: We need to create a Vector3 with changed amounts of x and y axis: player.position = new mp.Vector3(player.position.x + num, player.position.y + num, player.position.z); At the end; for your work convenience, you can use the snippet of this tutorial: let pa = player.heading; if(player.vehicle) { if(pa >= 0.0 && pa <= 22.5) player.vehicle.position = new mp.Vector3(player.vehicle.position.x, player.vehicle.position.y + num, player.vehicle.position.z); //n if(pa >= 22.5 && pa <= 67.5) player.vehicle.position = new mp.Vector3(player.vehicle.position.x - (num / 2), player.vehicle.position.y + (num / 2), player.vehicle.position.z); //nw if(pa >= 67.5 && pa <= 112.5) player.vehicle.position = new mp.Vector3(player.vehicle.position.x - num, player.vehicle.position.y, player.vehicle.position.z); //w if(pa >= 112.5 && pa <= 157.5) player.vehicle.position = new mp.Vector3(player.vehicle.position.x - (num / 2), player.vehicle.position.y - (num / 2), player.vehicle.position.z); //sw if(pa >= 157.5 && pa <= 202.5) player.vehicle.position = new mp.Vector3(player.vehicle.position.x, player.vehicle.position.y - num, player.vehicle.position.z); //s if(pa >= 202.5 && pa <= 247.5) player.vehicle.position = new mp.Vector3(player.vehicle.position.x, player.vehicle.position.y - (num / 2), player.vehicle.position.z); //se if(pa >= 247.5 && pa <= 292.5) player.vehicle.position = new mp.Vector3(player.vehicle.position.x + num, player.vehicle.position.y, player.vehicle.position.z); //e if(pa >= 292.5 && pa <= 332.5) player.vehicle.position = new mp.Vector3(player.vehicle.position.x + (num / 2), player.vehicle.position.y + (num / 2), player.vehicle.position.z); //ne if(pa >= 332.5 && pa < 360.0) player.vehicle.position = new mp.Vector3(player.vehicle.position.x, player.vehicle.position.y + (num / 2), player.vehicle.position.z); //n } else { if(pa >= 0.0 && pa <= 22.5) player.position = new mp.Vector3(player.position.x, player.position.y + num, player.position.z); //n if(pa >= 22.5 && pa <= 67.5) player.position = new mp.Vector3(player.position.x - (num / 2), player.position.y + (num / 2), player.position.z); //nw if(pa >= 67.5 && pa <= 112.5) player.position = new mp.Vector3(player.position.x - num, player.position.y, player.position.z); //w if(pa >= 112.5 && pa <= 157.5) player.position = new mp.Vector3(player.position.x - (num / 2), player.position.y - (num / 2), player.position.z); //sw if(pa >= 157.5 && pa <= 202.5) player.position = new mp.Vector3(player.position.x, player.position.y - num, player.position.z); //s if(pa >= 202.5 && pa <= 247.5) player.position = new mp.Vector3(player.position.x, player.position.y - (num / 2), player.position.z); //se if(pa >= 247.5 && pa <= 292.5) player.position = new mp.Vector3(player.position.x + num, player.position.y, player.position.z); //e if(pa >= 292.5 && pa <= 332.5) player.position = new mp.Vector3(player.position.x + (num / 2), player.position.y + (num / 2), player.position.z); //ne if(pa >= 332.5 && pa < 360.0) player.position = new mp.Vector3(player.position.x, player.position.y + (num / 2), player.position.z); //n } The output message of the action will be: ${player.name} went ${(num >= 0 ? "front" : "rear")} by ${(num >= 0 ? num : -num)}m - Note: We need to mirror the amount if we are teleporting rear in x, y axis in message.
    2 points
  2. Working on it. And it was called Deathmatch
    2 points
  3. mp.world.trafficLights.locked = true; mp.world.trafficLights.state = 0; setLights(); function setLights() { mp.world.trafficLights.state = 39; setTimeout(function(){ mp.world.trafficLights.state = 88; setTimeout(function(){ mp.world.trafficLights.state = 49; setTimeout(function(){ mp.world.trafficLights.state = 88; setTimeout(function(){ mp.world.trafficLights.state = 39; setTimeout(function(){ mp.world.trafficLights.state = 0; setTimeout(function(){ setLights(); }, 25000); // Grünphase West -> Ost }, 2000); // Grün werden West -> Ost }, 4000); // Gelbphase Nord -> Süd }, 15000); // Grünphase Nord -> Süd }, 2000); // Grün werden Nord -> Süd }, 4000); // Gelbphase West -> Ost } Diese Serverseitige Funktion wird beim Serverstart ausgeführt und startet sich danach immer wieder selbst. Die Zeiten (4000, 2000, 15000 und 25000) könnt ihr nach belieben anpassen.
    1 point
  4. Reallife. Like the good old Samp Servers but with new features of course. /edit And i really liked playing on MTA Server where you race against others and got a Helikopter at the end if you won. Dont know how the gamemode was called. I think that could also be very fun in rage.
    1 point
  5. 1 point
×
×
  • Create New...