Handle blips sent to client
This commit is contained in:
@@ -8,6 +8,9 @@
|
|||||||
// TYPE: Client (JavaScript)
|
// TYPE: Client (JavaScript)
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
|
let allServerBlips = [];
|
||||||
|
let currentServerBlips = [];
|
||||||
|
|
||||||
addNetworkHandler("ag.connectCamera", function(cameraPosition, cameraLookat) {
|
addNetworkHandler("ag.connectCamera", function(cameraPosition, cameraLookat) {
|
||||||
gta.fadeCamera(true);
|
gta.fadeCamera(true);
|
||||||
gta.setCameraLookAt(cameraPosition, cameraLookat, true);
|
gta.setCameraLookAt(cameraPosition, cameraLookat, true);
|
||||||
@@ -86,3 +89,56 @@ addEventHandler("onElementStreamIn", function(event, element) {
|
|||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
addNetworkHandler("ag.blips", function(blipData) {
|
||||||
|
for(let i in blipData) {
|
||||||
|
allServerBlips.push(blipData);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function showIslandBlips() {
|
||||||
|
for(let i in allServerBlips) {
|
||||||
|
let position = new Vec3(allServerBlips[i][1], allServerBlips[i][2], allServerBlips[i][3]);
|
||||||
|
if(getIslandFromPosition(position) == getIslandFromPosition(localPlayer.position)) {
|
||||||
|
let tempBlip = createBlip(position, allServerBlips[i][0], allServerBlips[i][4], allServerBlips[i][5]);
|
||||||
|
currentServerBlips.push(tempBlip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function getIslandFromPosition(position) {
|
||||||
|
switch(gta.game) {
|
||||||
|
case GAME_GTA_III:
|
||||||
|
if(position.x > 616) {
|
||||||
|
return 1;
|
||||||
|
} else if(position.x < -283) {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
return 2;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
addEventHandler("onPedSpawn", function(event, ped) {
|
||||||
|
console.log("localPlayer: " + localPlayer);
|
||||||
|
|
||||||
|
// Nasty workaround since localPlayer is null as the player spawns (reported as client bug #194)
|
||||||
|
setTimeout(attemptToShowBlipsOnSpawn, 500, ped);
|
||||||
|
});
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function attemptToShowBlipsOnSpawn(ped) {
|
||||||
|
if(ped == localPlayer) {
|
||||||
|
showIslandBlips();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
Reference in New Issue
Block a user