Created
October 21, 2021 14:14
-
-
Save HardstylesDev/3591dbfe46bf91fd67e3df2220e0ea43 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using CitizenFX.Core; | |
using static CitizenFX.Core.Native.API; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace MyResourceNameServer | |
{ | |
public class PenthouseTeleporter : BaseScript | |
{ | |
public PenthouseTeleporter() | |
{ | |
Tick += OnTick; | |
} | |
private async Task OnTick() | |
{ | |
Vector3 markerPosition = new Vector3(-288.15f, -731.0f, 124.81f); | |
Vector3 upstairsPosition = new Vector3(-265.87f, -737.5f, 34.42f); | |
float distanceToBottom = Game.PlayerPed.Position.DistanceToSquared(markerPosition); | |
float distanceToTop = Game.PlayerPed.Position.DistanceToSquared(upstairsPosition); | |
DateTime lastCheck = DateTime.Now; | |
double checkPositionDelay = 1000; | |
while (true) | |
{ | |
await Delay(0); | |
if (distanceToBottom > 1.5f && distanceToTop > 1.5f) | |
{ | |
World.DrawMarker(MarkerType.ThickChevronUp, markerPosition, new Vector3(), new Vector3(0, 180, 0), new Vector3(0.3f, 0.3f, 0.3f), System.Drawing.Color.FromArgb(220, 235, 216, 52), true, true); | |
World.DrawMarker(MarkerType.ThickChevronUp, upstairsPosition, new Vector3(), new Vector3(0, 0, 0), new Vector3(0.3f, 0.3f, 0.3f), System.Drawing.Color.FromArgb(220, 235, 216, 52), true, true); | |
} | |
else | |
{ | |
drawString("Druk op E", 0.45f, 0.5f); | |
if (Game.IsControlJustPressed(0, Control.Pickup)) | |
{ | |
if (distanceToBottom < 1.5f) { Game.PlayerPed.Position = upstairsPosition; } | |
else { Game.PlayerPed.Position = markerPosition; } | |
} | |
} | |
if (DateTime.Now.Subtract(lastCheck).TotalMilliseconds > checkPositionDelay) | |
{ | |
lastCheck = DateTime.Now; | |
distanceToBottom = Game.PlayerPed.Position.DistanceToSquared(markerPosition); | |
distanceToTop = Game.PlayerPed.Position.DistanceToSquared(upstairsPosition); | |
if (distanceToBottom > 20f && distanceToTop > 20f) | |
{ | |
checkPositionDelay = 2000; | |
} | |
else | |
{ | |
checkPositionDelay = 250; | |
} | |
} | |
} | |
} | |
private void drawString(string text, float x, float y) | |
{ | |
SetTextFont(0); | |
SetTextProportional(true); | |
SetTextScale(0.0f, 0.4f); | |
SetTextDropshadow(1, 1, 1, 1, 255); | |
SetTextEdge(1, 0, 0, 0, 255); | |
SetTextDropShadow(); | |
SetTextOutline(); | |
SetTextEntry("STRING"); | |
AddTextComponentString(text); | |
DrawText(x, y); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment