Skip to content

Instantly share code, notes, and snippets.

@R3DIANCE
Created December 8, 2020 21:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save R3DIANCE/17f572f8370f59a3a0322fd0151207b3 to your computer and use it in GitHub Desktop.
Save R3DIANCE/17f572f8370f59a3a0322fd0151207b3 to your computer and use it in GitHub Desktop.
import * as alt from 'alt';
import * as native from 'natives';
let NPCS = [
{ "model": "-1022961931", "x": 147.86373901367188, "y": -1041.9560546875, "z": 28.5, "rot": 340 }, //fleeca
{ "model": "1767447799", "x": 149.3274688720703, "y": -1042.4176025390625, "z": 28.5, "rot": 340 }, //fleeca
{ "model": "1767447799", "x": 313.74066162109375, "y": -280.8527526855469, "z": 53.20, "rot": 340 }, //fleeca
{ "model": "-1022961931", "x": 312.052734375, "y": -280.4439697265625, "z": 53.20, "rot": 340 }, //fleeca
{ "model": "1055701597", "x": 127.43736267089844, "y": -224.3340606689453, "z": 54.5545654296875, "rot": 90 }, //urban clothes shop
];
let SpawnedNPCS = [];
alt.on("resourceStart",() => {
NPCS.forEach(npc => {
if(!native.hasModelLoaded(npc.model)){
native.requestModel(npc.model);
}
var Ped = native.createPed(1, npc.model, npc.x, npc.y, npc.z, false, false);
SpawnedNPCS = [Ped];
native.freezeEntityPosition(Ped, false);
native.setEntityHeading(Ped, npc.rot);
native.taskSetBlockingOfNonTemporaryEvents(Ped, true);
native.setBlockingOfNonTemporaryEvents(Ped, true);
native.setPedFleeAttributes(Ped, 0, true);
native.setPedCombatAttributes(Ped, 17, true);
native.setPedAsEnemy(Ped, false);
native.setEntityInvincible(Ped, true);
alt.setTimeout(() => {
native.freezeEntityPosition(Ped, true);
}, 2000);
});
});
alt.on("resourceStop",() => {
SpawnedNPCS.forEach(npc => {
native.freezeEntityPosition(npc, false);
native.deletePed(npc);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment