Hey, can anybody please help me make my code more efficient?
I don’t know if this is good or bad but 31% doesn’t seem too good for a fairly basic script.
My Code
const playerId = PlayerId();
on("playerSpawned", (spawnInfo) => {
SetRelationshipBetweenGroups(
1,
GetHashKey("AMBIENT_GANG_HILLBILLY"),
GetHashKey("PLAYER")
);
SetRelationshipBetweenGroups(
1,
GetHashKey("AMBIENT_GANG_BALLAS"),
GetHashKey("PLAYER")
);
SetRelationshipBetweenGroups(
1,
GetHashKey("AMBIENT_GANG_MEXICAN"),
GetHashKey("PLAYER")
);
SetRelationshipBetweenGroups(
1,
GetHashKey("AMBIENT_GANG_FAMILY"),
GetHashKey("PLAYER")
);
SetRelationshipBetweenGroups(
1,
GetHashKey("AMBIENT_GANG_MARABUNTE"),
GetHashKey("PLAYER")
);
SetRelationshipBetweenGroups(
1,
GetHashKey("AMBIENT_GANG_SALVA"),
GetHashKey("PLAYER")
);
SetRelationshipBetweenGroups(1, GetHashKey("GANG_1"), GetHashKey("PLAYER"));
SetRelationshipBetweenGroups(1, GetHashKey("GANG_2"), GetHashKey("PLAYER"));
SetRelationshipBetweenGroups(1, GetHashKey("GANG_9"), GetHashKey("PLAYER"));
SetRelationshipBetweenGroups(1, GetHashKey("GANG_10"), GetHashKey("PLAYER"));
SetRelationshipBetweenGroups(1, GetHashKey("FIREMAN"), GetHashKey("PLAYER"));
SetRelationshipBetweenGroups(1, GetHashKey("MEDIC"), GetHashKey("PLAYER"));
SetRelationshipBetweenGroups(1, GetHashKey("COP"), GetHashKey("PLAYER"));
for (i = 1; i <= 15; i++) {
EnableDispatchService(i, false);
}
SetAudioFlag("PoliceScannerDisabled", true);
});
setTick(async () => {
const playerPed = GetPlayerPed(-1);
const playerCoords = GetEntityCoords(playerPed);
if (GetPlayerWantedLevel(playerId) != 0) {
SetPlayerWantedLevel(playerId, 0, false);
SetPlayerWantedLevelNow(PlayerId());
}
ClearAreaOfCops(playerCoords.x, playerCoords.y, playerCoords.z, 420);
});