Código:
#include <mapandreas>
#include <colandreas>
#include <fcnpc>
new Guardas[6], AnimNpcForPlayer[MAX_PLAYERS]; // FCNPC
forward RespawnGuardas();
forward AplicarAnimacao();
public OnGameModeInit()
{
FCNPC_UseCrashLog(false);
MapAndreas_Init(MAP_ANDREAS_MODE_FULL); // FCNPC
Guardas[0] = FCNPC_Create("Mario");
Guardas[1] = FCNPC_Create("Moises");
Guardas[2] = FCNPC_Create("Marlon");
Guardas[3] = FCNPC_Create("Alan");
Guardas[4] = FCNPC_Create("Adriel");
FCNPC_Spawn(Guardas[0], 163, 1479.6072, -1659.0735, 14.0469);
FCNPC_SetAngle(Guardas[0], 358.7808);
FCNPC_SetWeapon(Guardas[0], 31);
FCNPC_UseInfiniteAmmo(Guardas[0], true);
FCNPC_SetInvulnerable(Guardas[0], true);
FCNPC_SetAnimation(Guardas[0], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_ApplyAnimation(Guardas[0], "dealer", "DEALER_IDLE", 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[1], 163, 1515.0442, -1717.6755, 14.0469);
FCNPC_SetAngle(Guardas[1], 43.6107);
FCNPC_SetWeapon(Guardas[1], 31);
FCNPC_UseInfiniteAmmo(Guardas[1], true);
FCNPC_SetInvulnerable(Guardas[1], true);
FCNPC_SetAnimation(Guardas[1], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_ApplyAnimation(Guardas[1], "dealer", "DEALER_IDLE", 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[2], 163, 1444.3602, -1717.5654, 14.0469);
FCNPC_SetAngle(Guardas[2], 312.4927);
FCNPC_SetWeapon(Guardas[2], 31);
FCNPC_UseInfiniteAmmo(Guardas[2], true);
FCNPC_SetInvulnerable(Guardas[2], true);
FCNPC_SetAnimation(Guardas[2], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_ApplyAnimation(Guardas[2], "dealer", "DEALER_IDLE", 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[3], 163, 1444.5616, -1607.2711, 14.0469);
FCNPC_SetAngle(Guardas[3], 226.0121);
FCNPC_SetWeapon(Guardas[3], 31);
FCNPC_UseInfiniteAmmo(Guardas[3], true);
FCNPC_SetInvulnerable(Guardas[3], true);
FCNPC_SetAnimation(Guardas[3], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_ApplyAnimation(Guardas[3], "dealer", "DEALER_IDLE", 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[4], 163, 1514.5153, -1607.2125, 14.0469);
FCNPC_SetAngle(Guardas[4], 133.0138);
FCNPC_SetWeapon(Guardas[4], 31);
FCNPC_UseInfiniteAmmo(Guardas[4], true);
FCNPC_SetInvulnerable(Guardas[4], true);
FCNPC_SetAnimation(Guardas[4], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_ApplyAnimation(Guardas[4], "dealer", "DEALER_IDLE", 4.1, 1, 0, 0, 0, 0);
SetTimer("AplicarAnimacao",3000,false);
return 1;
}
// Como esse plugin tem algum problema para animar os npcs to tentando várias formas de aplicar a animação antes do jogador entrar.
public AplicarAnimacao()
{
FCNPC_SetAnimation(Guardas[0], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_ApplyAnimation(Guardas[0], "dealer", "DEALER_IDLE", 4.1, 0, 0, 0, 0, 0);
FCNPC_SetAnimation(Guardas[1], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_ApplyAnimation(Guardas[1], "dealer", "DEALER_IDLE", 4.1, 0, 0, 0, 0, 0);
FCNPC_SetAnimation(Guardas[2], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_ApplyAnimation(Guardas[2], "dealer", "DEALER_IDLE", 4.1, 0, 0, 0, 0, 0);
FCNPC_SetAnimation(Guardas[3], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_ApplyAnimation(Guardas[3], "dealer", "DEALER_IDLE", 4.1, 0, 0, 0, 0, 0);
FCNPC_SetAnimation(Guardas[4], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_ApplyAnimation(Guardas[4], "dealer", "DEALER_IDLE", 4.1, 0, 0, 0, 0, 0);
print("Aplicando animação nos Guardas!");
return 1;
}
public OnPlayerConnect(playerid)
{
AnimNpcForPlayer[playerid] = 0;
return 1;
}
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
if(IsPlayerInRangeOfPoint(playerid,100.0,1479.4541,-1656.3832,14.0469) || IsPlayerInRangeOfPoint(playerid,100.0,1515.0442, -1717.6755, 14.0469) || IsPlayerInRangeOfPoint(playerid,100.0,1444.3602, -1717.5654, 14.0469) || IsPlayerInRangeOfPoint(playerid,100.0,1444.5616, -1607.2711, 14.0469) || IsPlayerInRangeOfPoint(playerid,100.0,1514.5153, -1607.2125, 14.0469))
{
if(AnimNpcForPlayer[playerid] == 0)
{
SendClientMessage(playerid, -1, "Um guarda viu você atirando aqui!");
FCNPC_ClearAnimations(Guardas[0]);
FCNPC_AimAtPlayer(Guardas[0], playerid, true);
//FCNPC_GoToPlayer(Guardas[0], playerid); // Segue o player depois que ele morre
FCNPC_ClearAnimations(Guardas[1]);
FCNPC_AimAtPlayer(Guardas[1], playerid, true);
//FCNPC_GoToPlayer(Guardas[1], playerid);
FCNPC_ClearAnimations(Guardas[2]);
FCNPC_AimAtPlayer(Guardas[2], playerid, true);
//FCNPC_GoToPlayer(Guardas[2], playerid);
FCNPC_ClearAnimations(Guardas[3]);
FCNPC_AimAtPlayer(Guardas[3], playerid, true);
//FCNPC_GoToPlayer(Guardas[3], playerid);
FCNPC_ClearAnimations(Guardas[4]);
FCNPC_AimAtPlayer(Guardas[4], playerid, true);
//FCNPC_GoToPlayer(Guardas[4], playerid);
AnimNpcForPlayer[playerid] = 1;
}
}
return 1;
}
public RespawnGuardas()
{
FCNPC_Respawn(Guardas[0]);
FCNPC_Respawn(Guardas[1]);
FCNPC_Respawn(Guardas[2]);
FCNPC_Respawn(Guardas[3]);
FCNPC_Respawn(Guardas[4]);
print("O Guarda foi respawnado!");
return 1;
}
public FCNPC_OnSpawn(npcid)
{
FCNPC_Spawn(Guardas[0], 163, 1479.6072, -1659.0735, 14.0469);
FCNPC_SetAngle(Guardas[0], 358.7808);
FCNPC_SetAnimation(Guardas[0], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[1], 163, 1515.0442, -1717.6755, 14.0469);
FCNPC_SetAngle(Guardas[1], 43.6107);
FCNPC_SetAnimation(Guardas[1], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[2], 163, 1444.3602, -1717.5654, 14.0469);
FCNPC_SetAngle(Guardas[2], 312.4927);
FCNPC_SetAnimation(Guardas[2], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[3], 163, 1444.5616, -1607.2711, 14.0469);
FCNPC_SetAngle(Guardas[3], 226.0121);
FCNPC_SetAnimation(Guardas[3], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[4], 163, 1514.5153, -1607.2125, 14.0469);
FCNPC_SetAngle(Guardas[4], 133.0138);
FCNPC_SetAnimation(Guardas[4], 417, 4.1, 1, 0, 0, 0, 0);
return 1;
}
public FCNPC_OnRespawn(npcid)
{
FCNPC_Spawn(Guardas[0], 163, 1479.6072, -1659.0735, 14.0469);
FCNPC_SetAngle(Guardas[0], 358.7808);
FCNPC_SetAnimation(Guardas[0], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[1], 163, 1515.0442, -1717.6755, 14.0469);
FCNPC_SetAngle(Guardas[1], 43.6107);
FCNPC_SetAnimation(Guardas[1], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[2], 163, 1444.3602, -1717.5654, 14.0469);
FCNPC_SetAngle(Guardas[2], 312.4927);
FCNPC_SetAnimation(Guardas[2], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[3], 163, 1444.5616, -1607.2711, 14.0469);
FCNPC_SetAngle(Guardas[3], 226.0121);
FCNPC_SetAnimation(Guardas[3], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_Spawn(Guardas[4], 163, 1514.5153, -1607.2125, 14.0469);
FCNPC_SetAngle(Guardas[4], 133.0138);
FCNPC_SetAnimation(Guardas[4], 417, 4.1, 1, 0, 0, 0, 0);
return 1;
}
public OnPlayerSpawn(playerid)
{
FCNPC_SetAnimation(Guardas[0], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_SetAngle(Guardas[0], 358.7808);
FCNPC_SetAnimation(Guardas[1], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_SetAngle(Guardas[1], 43.6107);
FCNPC_SetAnimation(Guardas[2], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_SetAngle(Guardas[2], 312.4927);
FCNPC_SetAnimation(Guardas[3], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_SetAngle(Guardas[3], 226.0121);
FCNPC_SetAnimation(Guardas[4], 417, 4.1, 1, 0, 0, 0, 0);
FCNPC_SetAngle(Guardas[4], 133.0138);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
FCNPC_StopAim(Guardas[0]);
//FCNPC_GoTo(Guardas[0], 1479.6072, -1659.0735, 14.0469);
FCNPC_StopAim(Guardas[1]);
//FCNPC_GoTo(Guardas[1], 1515.0442, -1717.6755, 14.0469);
FCNPC_StopAim(Guardas[2]);
//FCNPC_GoTo(Guardas[2], 1444.3602, -1717.5654, 14.0469);
FCNPC_StopAim(Guardas[3]);
//FCNPC_GoTo(Guardas[3], 1444.5616, -1607.2711, 14.0469);
FCNPC_StopAim(Guardas[4]);
//FCNPC_GoTo(Guardas[4], 1514.5153, -1607.2125, 14.0469);
SetTimer("RespawnGuardas", 10000, false);
AnimNpcForPlayer[playerid] = 0;
return 1;
}