Skip to content

Commit

Permalink
Update client.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
voxty authored Oct 19, 2024
1 parent c16b7b8 commit ef25baf
Showing 1 changed file with 0 additions and 58 deletions.
58 changes: 0 additions & 58 deletions integrations/call911/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,62 +66,4 @@ onNet(Events.Send911ToAll, async ({ name, description, position }: { name: strin
"^7" + name + " | Call Description: " + description + " | Postal: " + postal + " | Street: " + lastStreetName
]
});
})


onNet(Events.Send911, ({ source, description }: EventData) => {
console.log(`911 Call Received from Player ID: ${source}. Description: ${description}`);

const playerPed: number = GetPlayerPed(-1);
const [x, y, z]: number[] = GetEntityCoords(playerPed, true);
const [lastStreet]: number[] = GetStreetNameAtCoord(x!, y!, z!);
const lastStreetName: string = GetStreetNameFromHashKey(lastStreet);

let proximity: number = 500;
let foundPlayers: boolean = false;

while (!foundPlayers && proximity <= 2000) {
const playersInProximity: number[] = [];

const players: number[] = GetActivePlayers();

for (const playerId of players) {
if (playerId !== source) {
const targetPed: number = GetPlayerPed(playerId);
const [targetX, targetY, targetZ]: number[] = GetEntityCoords(targetPed, true);

const distance: number = Vdist(x!, y!, z!, targetX ?? 0, targetY ?? 0, targetZ ?? 0);

if (distance <= proximity) {
playersInProximity.push(playerId);
}
}
}

if (playersInProximity.length > 0) {
foundPlayers = true;
TriggerEvent('chat:addMessage', playersInProximity, {
color: [255, 255, 255],
multiline: true,
args: [
"^1 [Emergency Services]",
"^7 A 911 call has been received | " + description + " | Located At: " + lastStreetName
]
});
} else {
proximity += 100;
}

if (playersInProximity.length >= 4) {
foundPlayers = true;
}
}

if (!foundPlayers) {
TriggerEvent('chat:addMessage', -1, {
color: [255, 255, 255],
multiline: true,
args: ["^1 [Emergency Services]", "^7 A 911 call has been received | " + description + " | Located At: " + lastStreetName]
});
}
});

0 comments on commit ef25baf

Please sign in to comment.