Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //na vrh moda
- #define MAX_NPCOVA 100
- enum NPC_ENUM
- {
- NPC_ID,
- NPC_AktivnaMeta,
- NPC_Heist,
- NPC_Misija,
- bool:NPC_Mrtav
- }
- new NPCInfo[MAX_NPCOVA][NPC_ENUM];
- new
- Iterator: NPCS<MAX_NPCOVA>;
- Stvori_NPC(Float:NPC_X, Float:NPC_Y, Float:NPC_Z, NPC_skin = 60, heistid = -1, misijaid = -1, meta = INVALID_PLAYER_ID, bool:npc_Vojnik = true) {
- new id = Iter_Free(NPCS), npcid;
- if(id == -1) return 1;
- new npcime[24];
- format(npcime, sizeof(npcime), "NPC_I%d", id);
- npcid = FCNPC_Create(npcime);
- FCNPC_Spawn(npcid, NPC_skin, NPC_X, NPC_Y, NPC_Z);
- NPCInfo[id][NPC_ID] = npcid;
- NPCInfo[id][NPC_AktivnaMeta] = meta;
- NPCInfo[id][NPC_Heist] = heistid;
- NPCInfo[id][NPC_Misija] = misijaid;
- NPCInfo[id][NPC_Mrtav] = false;
- if(npc_Vojnik) {
- switch(random(6)) {
- case 0: FCNPC_SetWeapon(npcid, 24);
- case 1: FCNPC_SetWeapon(npcid, 25);
- case 2: FCNPC_SetWeapon(npcid, 28);
- case 3: FCNPC_SetWeapon(npcid, 29);
- case 4: FCNPC_SetWeapon(npcid, 30);
- case 5: FCNPC_SetWeapon(npcid, 31);
- }
- FCNPC_SetAmmo(npcid, 300);
- FCNPC_ToggleReloading(npcid, true);
- FCNPC_SetInvulnerable(npcid, false);
- }
- Iter_Add(NPCS, id);
- return npcid;
- }
- Unisti_NPC(npcid) {
- for(new id; id < sizeof(NPCInfo); id++) {
- if(NPCInfo[id][NPC_ID] == npcid && FCNPC_IsValid(npcid)
- && Iter_Contains(NPCS, id)) {
- NPCInfo[id][NPC_ID] = -1;
- Iter_Remove(NPCS, id);
- break;
- }
- }
- FCNPC_Destroy(npcid);
- return true;
- }
- NPC_UzmiID(npcid) {
- new n_id;
- n_id = -1;
- for(new id; id < sizeof(NPCInfo); id++) {
- if(NPCInfo[id][NPC_ID] == npcid && FCNPC_IsValid(npcid)
- && Iter_Contains(NPCS, id)) {
- n_id = id;
- break;
- }
- }
- return n_id;
- }
- CMD:kreirajnpc(playerid,params[]) {
- new Float:x, Float:y, Float:z;
- GetPlayerPos(playerid,x,y,z);
- Stvori_NPC(x+1,y+2,z,105);
- return true;
- }
- CMD:pucajteme(playerid, params[]) {
- for(new id; id < sizeof(NPCInfo); id++) {
- if(FCNPC_IsValid(NPCInfo[id][NPC_ID]) && Iter_Contains(NPCS, id)) {
- NPC_PucajNa(NPCInfo[id][NPC_ID], playerid);
- }
- }
- return true;
- }
- forward NPC_PucajNa(npcid, target);
- public NPC_PucajNa(npcid, target)
- {
- if(FCNPC_IsValid(npcid)) {
- if(NPCInfo[NPC_UzmiID(npcid)][NPC_Mrtav]) {
- NPCInfo[NPC_UzmiID(npcid)][NPC_AktivnaMeta] = INVALID_PLAYER_ID;
- return 1;
- }
- NPCInfo[NPC_UzmiID(npcid)][NPC_AktivnaMeta] = target;
- new Float:x, Float:y, Float:z, Float: tempdist;
- FCNPC_GetPosition(npcid, x,y,z);
- new Float:PPX, PPY, PPZ;
- GetPlayerPos(target, PPX, PPY, PPZ);
- tempdist = GetPlayerDistanceFromPoint(target, x, y, z);
- if(tempdist < 20) {
- new time, chance;
- switch(FCNPC_GetWeapon(npcid)) {
- case 25, 26, 27: time = 400, chance = 35;
- case 33, 34: time = 500, chance = 50;
- case 24: time = 700, chance = 40;
- default: time = 200, chance = 40;
- }
- FCNPC_AimAtPlayer(npcid, target, false);
- SetTimerEx("NPC_PucajNa", time, false, "ii", playerid, target);
- if(random(100) < chance) {
- DamagePlayer(target, 5.0, INVALID_PLAYER_ID, FCNPC_GetWeapon(npcid));
- FCNPC_TriggerWeaponShot(npcid, FCNPC_GetWeapon(npcid), BULLET_HIT_TYPE_PLAYER, target, PPX,PPY,PPZ);
- }
- else {
- FCNPC_TriggerWeaponShot(npcid, FCNPC_GetWeapon(npcid), BULLET_HIT_TYPE_PLAYER, target, PPX+0.5,PPY+0.5,PPZ);
- }
- FCNPC_GiveAmmo(npcid, 1);
- }
- else {
- FCNPC_StopAim(npcid);
- NPCInfo[NPC_UzmiID(npcid)][NPC_AktivnaMeta] = INVALID_PLAYER_ID;
- }
- }
- return 1;
- }
- //u onplayerdeath
- for(new id; id < sizeof(NPCInfo); id++) {
- if(FCNPC_IsValid(NPCInfo[id][NPC_ID]) && Iter_Contains(NPCS, id) && PCInfo[id][NPC_AktivnaMeta] == playerid) {
- FCNPC_StopAim(NPCInfo[id][NPC_ID]);
- NPCInfo[id][NPC_AktivnaMeta] = INVALID_PLAYER_ID;
- }
- }
- //novi callback
- public FCNPC_OnDeath(npcid, killerid, reason)
- {
- NPCInfo[NPC_UzmiID(npcid)][NPC_Mrtav] = true;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement