Advertisement
SSYT

Actors

Nov 15th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.75 KB | None | 0 0
  1. // For Actors
  2. /* -------------------------- Actors Function -------------------------- */
  3. #define DEMAGE_ACTOR_HEAL 3
  4. #define functionEx%0(%1) forward %0(%1); public %0(%1)
  5. new ActorMission[3];
  6. new Timer[sizeof(ActorMission)];
  7. new TimerShot[MAX_PLAYERS];
  8. /* -------------------------- Actors Function -------------------------- */
  9.  
  10. public OnGameModeInit()
  11. {
  12.     // For Actors
  13.     /* -------------------------- Actors Function -------------------------- */
  14.     ActorMission[0] = CreateActor(71, 1916.0565, 1284.3304, 10.8203, 270.5099);
  15.     ActorMission[1] = CreateActor(71, 1861.8883, 1262.3375, 10.8203, 350.6823);
  16.     ActorMission[2] = CreateActor(71, 1852.6799, 1285.5439, 10.8203, 268.8857);
  17.    
  18.     SetActorInvulnerable(ActorMission[0], false);
  19.     SetActorHealth(ActorMission[0], 100);
  20.     ActorMissionWeapon[0] = CreateObject(353, 1861.8883, 1262.3375, 10.8203, 0.0, 0.0, 0.0);
  21.     AttachObjectToObject(ActorMissionWeapon[0], ActorMission[0], 1861.8883, 1262.3375, 10.8203, 0.0, 0.0, 0.0, 1);
  22.    
  23.     SetActorInvulnerable(ActorMission[1], false);
  24.     SetActorHealth(ActorMission[1], 100);
  25.     ActorMissionWeapon[1] = CreateObject(353, 1861.8883, 1262.3375, 10.8203, 0.0, 0.0, 0.0);
  26.     AttachObjectToObject(ActorMissionWeapon[0], ActorMission[1], 1861.8883, 1262.3375, 10.8203, 0.0, 0.0, 0.0, 1);
  27.  
  28.     SetActorInvulnerable(ActorMission[2], false);
  29.     SetActorHealth(ActorMission[2], 100);
  30.     ActorMissionWeapon[2] = CreateObject(357, 1852.6799, 1285.5439, 10.8203, 0.0, 0.0, 0.0);
  31.     AttachObjectToObject(ActorMissionWeapon[0], ActorMission[2], 1852.6799, 1285.5439, 10.8203, 0.0, 0.0, 0.0, 1);
  32.     /* -------------------------- Actors Function -------------------------- */
  33.     return 1;
  34. }
  35.  
  36. public OnPlayerSpawn(playerid)
  37. {
  38.     for(new i = 0; i < 3; i++) {
  39.         Timer[i] = SetTimerEx("OnActorStreamInEx", 1000, true, "dd", ActorMission[i], playerid);
  40.     }
  41.     return 1;
  42. }
  43.  
  44. public OnPlayerDeath(playerid, killerid, reason)
  45. {
  46.     KillTimer(TimerShot[playerid]);
  47.     return 1;
  48. }
  49.  
  50. public OnPlayerDisconnect(playerid, reason)
  51. {
  52.     KillTimer(TimerShot[playerid]);
  53.     return 1;
  54. }
  55.  
  56. // For Actors
  57. /* -------------------------- Actors Function -------------------------- */
  58. function OnActorGiveDamagePlayer(actorid, forplayerid) {
  59.     if(IsValidActor(ActorMission[actorid])) {
  60.         new Float:x, Float:y, Float:z;
  61.         GetActorPos(ActorMission[actorid], x, y, z);
  62.         if(IsActorStreamedIn(ActorMission[actorid], forplayerid) && IsPlayerInRangeOfPoint(forplayerid, 10.0, x, y, z))
  63.         {
  64.             new Float: heal;
  65.             GetPlayerHealth(forplayerid, heal);
  66.             SetPlayerHealth(forplayerid, heal-DEMAGE_ACTOR_HEAL);
  67.         }
  68.     }
  69.     return 1;
  70. }
  71.  
  72. function OnActorStreamInEx(actorid, forplayerid) {
  73.     if(IsValidActor(ActorMission[actorid])) {
  74.         new Float:x, Float:y, Float:z;
  75.         GetActorPos(ActorMission[actorid], x, y, z);
  76.         if(IsActorStreamedIn(ActorMission[actorid], forplayerid) && IsPlayerInRangeOfPoint(forplayerid, 10.0, x, y, z))
  77.         {
  78.             ApplyActorAnimation(ActorMission[actorid], "SHOP", "ROB_Loop_Threat", 4.0, 1, 0, 0, 200, 5000);
  79.             TimerShot[forplayerid] = SetTimerEx("OnActorGiveDamagePlayer", 3000, true, "dd", actorid, forplayerid);
  80.             KillTimer(Timer[actorid]);
  81.         } else {
  82.             ClearActorAnimations(ActorMission[actorid]);
  83.             Timer[actorid] = SetTimerEx("OnActorStreamOutEx", 1000, true, "dd", actorid, forplayerid);
  84.         }
  85.     }
  86.     return 1;
  87. }
  88.  
  89. function OnActorStreamOutEx(actorid, forplayerid) {
  90.     if(IsValidActor(ActorMission[actorid])) {
  91.         new Float:x, Float:y, Float:z;
  92.         GetActorPos(ActorMission[actorid], x, y, z);
  93.         if(!IsActorStreamedIn(ActorMission[actorid], forplayerid) && !IsPlayerInRangeOfPoint(forplayerid, 10.0, x, y, z))
  94.         {
  95.             ClearActorAnimations(ActorMission[actorid]);
  96.             DestroyObject(ActorMissionWeapon[actorid]);
  97.             KillTimer(TimerShot[forplayerid]);
  98.             Timer[actorid] = SetTimerEx("OnActorStreamInEx", 1000, true, "dd", actorid, forplayerid);
  99.         }
  100.     }
  101.     return 1;
  102. }
  103.  
  104. public OnPlayerGiveDamageActor(playerid, damaged_actorid, Float: amount, weaponid, bodypart)
  105. {
  106.     new string[128], attacker[MAX_PLAYER_NAME];
  107.     new weaponname[24];
  108.     GetPlayerName(playerid, attacker, sizeof (attacker));
  109.     GetWeaponName(weaponid, weaponname, sizeof (weaponname));
  110.  
  111.     format(string, sizeof(string), "%s has made %.0f damage to actor id %d, weapon: %s", attacker, amount, damaged_actorid, weaponname);
  112.     SendClientMessage(playerid, 0xFFFFFFFF, string);
  113.     new Float: Health;
  114.     GetActorHealth(damaged_actorid, Health);
  115.     SetActorHealth(damaged_actorid, Health-amount);
  116.     printf("Actor ID %d has %.2f health.", damaged_actorid, Health);
  117.    
  118.     new Float: actheal;
  119.     GetActorHealth(damaged_actorid, actheal);
  120.     if(actheal <= 0) {
  121.         ClearActorAnimations(ActorMission[damaged_actorid]);
  122.         SetActorHealth(damaged_actorid, 0);
  123.         KillTimer(TimerShot[playerid]);
  124.     }
  125.     return 1;
  126. }
  127. /* -------------------------- Actors Function -------------------------- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement