13.07.2017, 12:24
Hey!
I have been trying to make them respawn but not success yet.
How should code look like? To respawn dead zombie every 5 min?
Here is the code!
I have been trying to make them respawn but not success yet.
How should code look like? To respawn dead zombie every 5 min?
Here is the code!
Code:
#include <a_samp> #include <FCNPC> #define MAX_ZOMBIES 5 new Float:ZPos[MAX_ZOMBIES][4] = { {379.8811,-1699.6576,7.5203,135.8003}, {489.1599,-1792.9203,6.6491,66.5531}, {192.8038,-1844.9354,3.5631,256.3835}, {631.2430,-1711.2626,14.2986,177.0387}, {907.7244,-1771.8442,13.3828,264.2476} }; new Attack[MAX_PLAYERS]; new ZombieEnd; new ZombieFirst; public OnFilterScriptInit() { CriarZOMBIES(); SetTimer("ZombieTimer", 400, true); return 1; } forward ZombieTimer(); public ZombieTimer() { for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i) && !IsPlayerNPC(i)) { new Float:zP[3], Float:dist; for(new npcid = ZombieFirst; npcid > ZombieEnd-1; npcid--) { FCNPC_GetPosition(npcid, zP[0], zP[1], zP[2]); dist = GetPlayerDistanceFromPoint(i, zP[0], zP[1], zP[2]); if(dist <= 0.5) { if(Attack[npcid] == 0) { FCNPC_MeleeAttack(npcid, -1); if(dist >= 0.1) FCNPC_SetAngleToPlayer(npcid, i); Attack[npcid] = 1; } } else if(dist <= 20.0) { new Float:pP[3]; if(Attack[npcid] == 1) { Attack[npcid] = 0; FCNPC_StopAttack(npcid); } GetPlayerPos(i, pP[0], pP[1], pP[2]); FCNPC_GoTo(npcid, pP[0], pP[1], pP[2], MOVE_TYPE_RUN, 0.5, true, 0.0, true); } else FCNPC_Stop(npcid); } } } return 1; } stock CriarZOMBIES() { new str[30]; for(new i = 0; i < MAX_ZOMBIES; i++) { format(str, sizeof(str), "Zombie_%i", i); new npcid = FCNPC_Create(str); if(ZombieFirst == 0) ZombieFirst = npcid; ZombieEnd = npcid; FCNPC_Spawn(npcid, 162, ZPos[i][0], ZPos[i][1], ZPos[i][2]); FCNPC_SetAngle(npcid, ZPos[i][3]); FCNPC_SetInterior(npcid, 0); FCNPC_SetArmour(npcid, 80); FCNPC_SetWeapon(npcid, 4); FCNPC_SetAmmo(npcid, 1); printf("Zombie %d created", i); } return 1; } forward RespawnZombies(); public RespawnZombies() { for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerNPC(i)) { if(FCNPC_IsDead(i)) { FCNPC_Respawn(i); } } } return 1; } public FCNPC_OnDeath(npcid, killerid, weaponid) { if(killerid != INVALID_PLAYER_ID) { } //FCNPC_Respawn(npcid); return 1; } public FCNPC_OnTakeDamage(npcid, damagerid, weaponid, bodypart, Float:health_loss) { if(bodypart == 9) { FCNPC_SetHealth(npcid, -15); } return 1; }