Advertisement
Guest User

AE - Actors Everywhere by Roger Costa 'NikO'

a guest
Oct 11th, 2015
947
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 26.15 KB | None | 0 0
  1. /*
  2.         Actors Everywhere
  3.  
  4.         # Version: 0.1
  5.         # Author: Roger Costa "NikO"
  6.  
  7.         This filterscript add actors in San Andreas, according current
  8.         time of you server, or add statics actors, staying setted in
  9.         same positions everytime. 1 actor can be created during the day,
  10.         afternoon, night and dawn. You define the positions and animations
  11.         for each time, and when the server time is passing the actors
  12.         are deleted automaticaly and created automaticaly too.
  13.        
  14.         ------------------------------------------------------------------
  15.         Types to Create Actor in AE_ACTORS_CREATE_TYPE define:
  16.  
  17.         0 - Actors they are created and remain the same position;
  18.         1 -   ''    ''  ''    ''  and change positions according time
  19.             Ex:
  20.             Time 09:00 - Actor in Beach
  21.             Time 15:00 - Actor in House
  22.         ------------------------------------------------------------------
  23.  
  24. */
  25.  
  26. // Includes
  27. #include <a_samp>
  28.  
  29. // Defines
  30. #define AE_MAX_ACTORS                           7
  31. #define AE_MAX_OBJECTS                          12
  32. #define AE_ACTORS_CREATE_TYPE                   0        // Standard is 0
  33.  
  34. #define AE_USE_GIVE_ACTOR_DMG                   1        // if 1 call OnGiveDamageActor if actor not invulnerable
  35. #define AE_USE_RESPAWN_ACTOR                    1        // if 1, after shoot, actor execute anims and respawn to early position in TIME that you choose below
  36. #define AE_TIME_RESPAWN_ACTOR                   5000     // Time to respawn actor after shooted, if actor not invulnerable (in ms)
  37.  
  38. // Dont change, but not specially effect, more for script organization
  39. #define AE_TIME_DAY                             1
  40. #define AE_TIME_AFTERNOON                       2
  41. #define AE_TIME_NIGHT                           3
  42. #define AE_TIME_DAWN                            4
  43.  
  44. // You change according your server
  45. #define AE_HOURS_DAY                            7 .. 13
  46. #define AE_HOURS_AFTERNOON                      14 .. 18
  47. #define AE_HOURS_NIGHT                          19 .. 23
  48. #define AE_HOURS_DAWN                           0 .. 6
  49.  
  50. #define AE_DEBUG                                1       // 1 actived, 0 disabled
  51.  
  52. #define AE_USE_STREAMER                         1
  53.  
  54. #if AE_USE_STREAMER == 1
  55.     #tryinclude <streamer>
  56. #endif
  57.  
  58.  
  59. enum ACTORS_INFOS_ENUM
  60. {
  61.     // Name of Actor, useless in the moment
  62.     NAME[24],
  63.  
  64.     // Positions
  65.     Float:POSITIONS_STANDARD[4],
  66.     Float:POSITIONS_DAY[4],
  67.     Float:POSITIONS_AFTERNOON[4],
  68.     Float:POSITIONS_NIGHT[4],
  69.     Float:POSITIONS_DAWN[4],
  70.  
  71.     // Skins - If set skin -1 = random skin
  72.     SKIN_STANDARD,
  73.     SKIN_DAY,
  74.     SKIN_AFTERNOON,
  75.     SKIN_NIGHT,
  76.     SKIN_DAWN,
  77.  
  78.     // Animations
  79.     ANIM_LIB_STANDARD[32], ANIM_NAME_STANDARD[32], ANIM_LOOP_STANDARD,
  80.     ANIM_LIB_DAY[32], ANIM_NAME_DAY[32], ANIM_LOOP_DAY,
  81.     ANIM_LIB_AFTERNOON[32], ANIM_NAME_AFTERNOON[32], ANIM_LOOP_AFTERNOON,
  82.     ANIM_LIB_NIGHT[32], ANIM_NAME_NIGHT[32], ANIM_LOOP_NIGHT,
  83.     ANIM_LIB_DAWN[32], ANIM_NAME_DAWN[32], ANIM_LOOP_DAWN,
  84.  
  85.     bool:INVULNERABLE,
  86. }
  87.  
  88. enum AE_OBJECTS_ENUM
  89. {
  90.     OBJECT_ID,
  91.     Float:OBJECT_POS[3],
  92.     Float:OBJECT_ROT[3],
  93. }
  94.  
  95. new ACTORS_INFO[AE_MAX_ACTORS][ACTORS_INFOS_ENUM] =
  96. {
  97.     // LOS SANTOS ACTORS
  98.  
  99.     // CEMITERY ACTORS (AE_ACTORS_CREATE_TYPE == 1, ARE CREATED ONLY "DAY" OR STANDARD POSITION IF AE_ACTORS_CREATE_TYPE == 0)
  100.     // # ACTOR 1
  101.     {
  102.         "CJ",
  103.         {852.2451,-1085.1626,24.2969,285.3400},
  104.         {852.2451,-1085.1626,24.2969,285.3400},
  105.         {0.0, 0.0, 0.0, 0.0},
  106.         {0.0, 0.0, 0.0, 0.0},
  107.         {0.0, 0.0, 0.0, 0.0},
  108.         0,      0,      0,      0,      0,
  109.         "PED",      "endchat_03", 1,
  110.         "PED",      "endchat_03", 1,
  111.         "NONE",     "NONE", 0,
  112.         "NONE",     "NONE", 0,
  113.         "NONE",     "NONE", 0,
  114.         false
  115.     },
  116.     // # ACTOR 2
  117.     {
  118.         "Sweet",
  119.         {886.0898,-1075.6869,24.2969,181.4619},
  120.         {886.0898,-1075.6869,24.2969,181.4619},
  121.         {0.0, 0.0, 0.0, 0.0},
  122.         {0.0, 0.0, 0.0, 0.0},
  123.         {0.0, 0.0, 0.0, 0.0},
  124.         270,        270,     0,      0,      0,
  125.         "OTB",      "wtchrace_cmon", 1,
  126.         "OTB",      "wtchrace_cmon", 1,
  127.         "NONE",     "NONE", 0,
  128.         "NONE",     "NONE", 0,
  129.         "NONE",     "NONE", 0,
  130.         true
  131.     },
  132.     // # ACTOR 3
  133.     {
  134.         "Kendl",
  135.         {887.1324,-1075.7382,24.2969,165.9121},
  136.         {887.1324,-1075.7382,24.2969,165.9121},
  137.         {0.0, 0.0, 0.0, 0.0},
  138.         {0.0, 0.0, 0.0, 0.0},
  139.         {0.0, 0.0, 0.0, 0.0},
  140.         65,     65,     0,      0,      0,
  141.         "PED",      "IDLE_tired", 1,
  142.         "PED",      "IDLE_tired", 1,
  143.         "NONE",     "NONE", 0,
  144.         "NONE",     "NONE", 0,
  145.         "NONE",     "NONE", 0,
  146.         true
  147.     },
  148.     // # ACTOR 4
  149.     {
  150.         "Ryder",
  151.         {884.8588,-1075.8167,24.2969,183.9686},
  152.         {884.8588,-1075.8167,24.2969,183.9686},
  153.         {0.0, 0.0, 0.0, 0.0},
  154.         {0.0, 0.0, 0.0, 0.0},
  155.         {0.0, 0.0, 0.0, 0.0},
  156.         271,        271,    0,      0,      0,
  157.         "OTB",      "wtchrace_lose", 1,
  158.         "OTB",      "wtchrace_lose", 1,
  159.         "NONE",     "NONE", 0,
  160.         "NONE",     "NONE", 0,
  161.         "NONE",     "NONE", 0,
  162.         true
  163.     },
  164.  
  165.     // HOMELESS (AE_ACTORS_CREATE_TYPE == 1, ARE CREATED ONLY "DAWN" OR STANDARD POSITION IF AE_ACTORS_CREATE_TYPE == 0)
  166.     // # ACTOR 5
  167.     {
  168.         "Mendigo 1",
  169.         {1610.3655,-1525.3424,13.6156,59.6464},
  170.         {0.0, 0.0, 0.0, 0.0},
  171.         {0.0, 0.0, 0.0, 0.0},
  172.         {0.0, 0.0, 0.0, 0.0},
  173.         {1610.3655,-1525.3424,13.6156,59.6464},
  174.         78,     271,    55,     56,     78,
  175.         "CRACK",            "crckidle1", 1,
  176.         "NONE",             "NONE", 0,
  177.         "NONE",             "NONE", 0,
  178.         "NONE",             "NONE", 0,
  179.         "CRACK",            "crckidle1", 1,
  180.         true
  181.     },
  182.     // # ACTOR 6
  183.     {
  184.         "Mendigo 2",
  185.         {1611.0665,-1525.5786,14.0651,51.3551},
  186.         {0.0, 0.0, 0.0, 0.0},
  187.         {0.0, 0.0, 0.0, 0.0},
  188.         {0.0, 0.0, 0.0, 0.0},
  189.         {1611.0665,-1525.5786,14.0651,51.3551},
  190.         77,     271,    55,     56,     77,
  191.         "CRACK",            "crckidle2", 1,
  192.         "NONE",             "NONE", 0,
  193.         "NONE",             "NONE", 0,
  194.         "NONE",             "NONE", 0,
  195.         "CRACK",            "crckidle2", 1,
  196.         true
  197.     },
  198.     // # ACTOR 7
  199.     {
  200.         "Mendigo 3",
  201.         {1607.0974,-1523.8680,14.0648,240.6115},
  202.         {0.0, 0.0, 0.0, 0.0},
  203.         {0.0, 0.0, 0.0, 0.0},
  204.         {0.0, 0.0, 0.0, 0.0},
  205.         {1607.0974,-1523.8680,14.0648,240.6115},
  206.         134,        271,    55,     56,     134,
  207.         "CRACK",            "crckdeth2", 1,
  208.         "NONE",             "NONE", 0,
  209.         "NONE",             "NONE", 0,
  210.         "NONE",             "NONE", 0,
  211.         "CRACK",            "crckdeth2", 1,
  212.         true
  213.     }
  214. };
  215.  
  216. new OBJECTS_INFO[AE_MAX_OBJECTS][AE_OBJECTS_ENUM] =
  217. {
  218.     // Objects used in example "Cemitery Actors'
  219.     {   19339,  {885.963928, -1077.381713, 23.673976}, {0.000000, 0.000000, 0.000000}   },
  220.     {   869,    {885.875915, -1077.318115, 23.620748}, {0.400000, -0.400000, -24.300003}   },
  221.     // Objects used in example 'Homeless Actors'
  222.     {   19632,  {1609.0063470,-1524.8005370,12.6506800}, {0.0000000,0.0000000,0.0000000}    },
  223.     {   1728,   {1611.4613030,-1525.0843500,12.5722550}, {0.0000000,0.0000000,-116.3000180} },
  224.     {   1728,   {1606.6767570,-1524.3824460,12.5722550}, {0.0000000,0.0000000,63.4999270}   },
  225.     {   19632,  {1609.0968010,-1524.9692380,12.6506800}, {0.0000000,0.0000000,48.7999800}   },
  226.     {   19632,  {1609.2636710,-1524.7806390,12.6506800}, {0.0000000,0.0000000,113.5999600}  },
  227.     {   19836,  {1610.6063230,-1526.8380120,13.0760900}, {0.0000000,0.0000000,0.0000000}    },
  228.     {   910,    {1608.3912350,-1527.8549800,13.8544120}, {0.0000000,0.0000000,-170.5999750} },
  229.     {   2670,   {1608.4865720,-1526.6530760,12.7041530}, {0.0000000,0.0000000,0.0000000}    },
  230.     {   2677,   {1610.2906490,-1523.6174310,12.8823190}, {0.0000000,0.0000000,0.0000000}    },
  231.     {   1349,   {1611.9851070,-1523.2956540,13.1444040}, {1.1999990,0.0000000,179.6999510}  }
  232. };
  233.  
  234. new AE_ACTOR_CREATE[AE_MAX_ACTORS] = {-1, ...};     // Used to create actors
  235. new bool:AE_ACTOR_SHOOTED[AE_MAX_ACTORS];
  236. new AE_OBJECT_CREATE[AE_MAX_OBJECTS] = {-1, ...};   // Used to create objects
  237. new AE_TIME_STATE;                                  // Used to check hour
  238. new AE_HOUR;                                        // Used to get server time (in gamemode, or other script) with CallRemoteFunction
  239. new AE_LOOP;                                        // Used in create actors loop
  240.  
  241.  
  242. // Callbacks
  243.  
  244. public OnFilterScriptInit()
  245. {
  246.    
  247.     // Creating objects, if used..
  248.     for(new i = 0; i < sizeof(OBJECTS_INFO); i++)
  249.     {
  250.         #if AE_USE_STREAMER == 1
  251.             AE_OBJECT_CREATE[i] = CreateDynamicObject(OBJECTS_INFO[i][OBJECT_ID],
  252.                                                       OBJECTS_INFO[i][OBJECT_POS][0],
  253.                                                       OBJECTS_INFO[i][OBJECT_POS][1],
  254.                                                       OBJECTS_INFO[i][OBJECT_POS][2],
  255.                                                       OBJECTS_INFO[i][OBJECT_ROT][0],
  256.                                                       OBJECTS_INFO[i][OBJECT_ROT][1],
  257.                                                       OBJECTS_INFO[i][OBJECT_ROT][2],
  258.                                                       -1, -1, -1,
  259.                                                       STREAMER_OBJECT_SD,
  260.                                                       STREAMER_OBJECT_DD);
  261.         #elseif AE_USE_STREAMER == 0
  262.             AE_OBJECT_CREATE[i] = CreateObject(OBJECTS_INFO[i][OBJECT_ID],
  263.                                                OBJECTS_INFO[i][OBJECT_POS][0],
  264.                                                OBJECTS_INFO[i][OBJECT_POS][1],
  265.                                                OBJECTS_INFO[i][OBJECT_POS][2],
  266.                                                OBJECTS_INFO[i][OBJECT_ROT][0],
  267.                                                OBJECTS_INFO[i][OBJECT_ROT][1],
  268.                                                OBJECTS_INFO[i][OBJECT_ROT][2],
  269.                                                25);
  270.         #endif
  271.     }
  272.  
  273.     // Creating actors
  274.     #if AE_ACTORS_CREATE_TYPE == 0
  275.         SetTimer("AE_CreateStaticActors", 1000*5, false);
  276.     #elseif AE_ACTORS_CREATE_TYPE == 1
  277.         SetTimer("AE_CheckTimeForActors", 1000*5, true);
  278.     #else
  279.         #error "Define AE_ACTORS_CREATE_TYPE between 0 and 1. Read top of Script."
  280.     #endif
  281.    
  282.     print("\nActors Everywhere Loaded.\nAuthor: Roger Costa ''NikO''");
  283.     return 1;
  284. }
  285.  
  286. public OnFilterScriptExit()
  287. {
  288.     for(new i = 0; i < AE_LOOP; i++)
  289.     {
  290.         if(IsValidActor(AE_ACTOR_CREATE[i]) && AE_ACTOR_CREATE[i] != -1)
  291.         {
  292.             #if AE_DEBUG == 1
  293.                 printf("<AE_DEBUG> Actors Deleted: AE_ACTOR_CREATE[%d] / ID in-game: %d", i, AE_ACTOR_CREATE[i]);
  294.             #endif
  295.             DestroyActor(AE_ACTOR_CREATE[i]);
  296.             AE_ACTOR_CREATE[i] = -1;
  297.         }
  298.     }
  299.    
  300.     for(new i = 0; i < sizeof(OBJECTS_INFO); i++)
  301.     {
  302.         #if AE_USE_STREAMER == 1
  303.             if(IsValidDynamicObject(AE_OBJECT_CREATE[i]))
  304.                 DestroyDynamicObject(AE_OBJECT_CREATE[i]);
  305.         #elseif AE_USE_STREAMER == 0
  306.             if(IsValidObject(AE_OBJECT_CREATE[i]))
  307.                 DestroyObject(AE_OBJECT_CREATE[i]);
  308.         #endif
  309.     }
  310.    
  311.     print("\nActors Everywhere Unloaded - There all actors\ncreated with FS are deleted.");
  312.     return 1;
  313. }
  314.  
  315. forward AE_CreateStaticActors();
  316. public AE_CreateStaticActors()
  317. {
  318.     if(sizeof(ACTORS_INFO) <= (MAX_ACTORS - GetActorPoolSize())) AE_LOOP = sizeof(ACTORS_INFO);
  319.     else AE_LOOP = MAX_ACTORS - GetActorPoolSize();
  320.    
  321.     for(new i = 0; i < AE_LOOP; i++)
  322.     {
  323.         if(ACTORS_INFO[i][SKIN_STANDARD] == -1) ACTORS_INFO[i][SKIN_STANDARD] = random(311);
  324.         AE_ACTOR_CREATE[i] =  CreateActor(ACTORS_INFO[i][SKIN_STANDARD],
  325.                                         ACTORS_INFO[i][POSITIONS_STANDARD][0],  // Position X
  326.                                         ACTORS_INFO[i][POSITIONS_STANDARD][1],  // Position Y
  327.                                         ACTORS_INFO[i][POSITIONS_STANDARD][2],  // Position Z
  328.                                         ACTORS_INFO[i][POSITIONS_STANDARD][3]); // Facing Angle (Rotation)
  329.         ApplyActorAnimation(AE_ACTOR_CREATE[i], ACTORS_INFO[i][ANIM_LIB_STANDARD], ACTORS_INFO[i][ANIM_NAME_STANDARD], ACTORS_INFO[i][ANIM_LOOP_STANDARD], 1, 0, 0, 0, 0);
  330.         SetActorInvulnerable(AE_ACTOR_CREATE[i], ACTORS_INFO[i][INVULNERABLE]);   // Invulnerabity
  331.         #if AE_DEBUG == 1
  332.           printf("<AE_DEBUG> Actor Created: AE_ACTOR_CREATE[%d] / Actor ID in-game: %d", i, AE_ACTOR_CREATE[i]);
  333.         #endif
  334.     }
  335. }
  336.  
  337. forward AE_CheckTimeForActors();
  338. public AE_CheckTimeForActors()
  339. {
  340.     AE_HOUR = CallRemoteFunction("ReturnTime", "d", 1); // This "PUBLIC_NAME_RETUNING_HOUR" has to return HOUR
  341.     switch(AE_HOUR)
  342.     {
  343.         case AE_HOURS_DAWN:     // Dawn
  344.         {
  345.             if(AE_TIME_STATE != AE_TIME_DAWN)
  346.             {
  347.                 AE_TIME_STATE = AE_TIME_DAWN;
  348.  
  349.                 for(new i = 0; i < AE_LOOP; i++)
  350.                 {
  351.                     if(IsValidActor(AE_ACTOR_CREATE[i]) && AE_ACTOR_CREATE[i] != -1)
  352.                     {
  353.                         #if AE_DEBUG == 1
  354.                           printf("<AE_DEBUG> Actors Deleted: AE_ACTOR_CREATE[%d] / ID in-game: %d", i, AE_ACTOR_CREATE[i]);
  355.                         #endif
  356.                         DestroyActor(AE_ACTOR_CREATE[i]);
  357.                         AE_ACTOR_CREATE[i] = -1;
  358.                     }
  359.                 }
  360.  
  361.                 if(sizeof(ACTORS_INFO) <= (MAX_ACTORS - GetActorPoolSize())) AE_LOOP = sizeof(ACTORS_INFO);
  362.                 else AE_LOOP = MAX_ACTORS - GetActorPoolSize();
  363.  
  364.                 for(new i = 0; i < AE_LOOP; i++)
  365.                 {
  366.                     if(ACTORS_INFO[i][POSITIONS_DAWN][0] != 0.0)
  367.                     {
  368.                         if(ACTORS_INFO[i][SKIN_DAWN] == -1)     ACTORS_INFO[i][SKIN_DAWN] = random(311);
  369.                         AE_ACTOR_CREATE[i] =  CreateActor(ACTORS_INFO[i][SKIN_DAWN],
  370.                                                           ACTORS_INFO[i][POSITIONS_DAWN][0],    // Position X
  371.                                                           ACTORS_INFO[i][POSITIONS_DAWN][1],  // Position Y
  372.                                                           ACTORS_INFO[i][POSITIONS_DAWN][2],  // Position Z
  373.                                                           ACTORS_INFO[i][POSITIONS_DAWN][3]); // Facing Angle (Rotation)
  374.  
  375.                         ApplyActorAnimation(AE_ACTOR_CREATE[i], ACTORS_INFO[i][ANIM_LIB_DAWN], ACTORS_INFO[i][ANIM_NAME_DAWN], 4.1, ACTORS_INFO[i][ANIM_LOOP_DAWN], 0, 0, 0, 0);
  376.                         SetActorInvulnerable(AE_ACTOR_CREATE[i], ACTORS_INFO[i][INVULNERABLE]);
  377.                        
  378.                         #if AE_DEBUG == 1
  379.                           printf("<AE_DEBUG> Actor Created: AE_ACTOR_CREATE[%d] / Actor ID in-game: %d", i, AE_ACTOR_CREATE[i]);
  380.                         #endif
  381.                     }
  382.                 }
  383.                 print("\n- AE: Actors Dawn Created!\n");
  384.             }
  385.         }
  386.         case AE_HOURS_DAY:  // Day
  387.         {
  388.             if(AE_TIME_STATE != AE_TIME_DAY)
  389.             {
  390.                 AE_TIME_STATE = AE_TIME_DAY;
  391.                 for(new i = 0; i < AE_LOOP; i++)
  392.                 {
  393.                     if(IsValidActor(AE_ACTOR_CREATE[i]) && AE_ACTOR_CREATE[i] != -1)
  394.                     {
  395.                         #if AE_DEBUG == 1
  396.                           printf("<AE_DEBUG> Actors Deleted: AE_ACTOR_CREATE[%d] / ID in-game: %d", i, AE_ACTOR_CREATE[i]);
  397.                         #endif
  398.                         DestroyActor(AE_ACTOR_CREATE[i]);
  399.                         AE_ACTOR_CREATE[i] = -1;
  400.                     }
  401.                 }
  402.  
  403.                 if(sizeof(ACTORS_INFO) <= (MAX_ACTORS - GetActorPoolSize())) AE_LOOP = sizeof(ACTORS_INFO);
  404.                 else AE_LOOP = MAX_ACTORS - GetActorPoolSize();
  405.  
  406.                 for(new i = 0; i < AE_LOOP; i++)
  407.                 {
  408.                     if(ACTORS_INFO[i][POSITIONS_DAY][0] != 0.0)
  409.                     {
  410.                         if(ACTORS_INFO[i][SKIN_DAY] == -1) ACTORS_INFO[i][SKIN_DAY] = random(311);
  411.                         AE_ACTOR_CREATE[i] =  CreateActor(ACTORS_INFO[i][SKIN_DAY],
  412.                                                           ACTORS_INFO[i][POSITIONS_DAY][0],     // Position X
  413.                                                           ACTORS_INFO[i][POSITIONS_DAY][1],  // Position Y
  414.                                                           ACTORS_INFO[i][POSITIONS_DAY][2],  // Position Z
  415.                                                           ACTORS_INFO[i][POSITIONS_DAY][3]); // Facing Angle (Rotation)
  416.  
  417.                         ApplyActorAnimation(AE_ACTOR_CREATE[i], ACTORS_INFO[i][ANIM_LIB_DAY], ACTORS_INFO[i][ANIM_NAME_DAY], 4.1, ACTORS_INFO[i][ANIM_LOOP_DAY], 0, 0, 0, 0);
  418.                         SetActorInvulnerable(AE_ACTOR_CREATE[i], ACTORS_INFO[i][INVULNERABLE]);
  419.                        
  420.                         #if AE_DEBUG == 1
  421.                           printf("<AE_DEBUG> Actor Created: AE_ACTOR_CREATE[%d] / Actor ID in-game: %d", i, AE_ACTOR_CREATE[i]);
  422.                         #endif
  423.                     }
  424.                 }
  425.                 print("\n- AE: Actors Day Created!\n");
  426.             }
  427.         }
  428.         case AE_HOURS_AFTERNOON:    // Afternoon
  429.         {
  430.             if(AE_TIME_STATE != AE_TIME_AFTERNOON)
  431.             {
  432.                 AE_TIME_STATE = AE_TIME_AFTERNOON;
  433.                 for(new i = 0; i < AE_LOOP; i++)
  434.                 {
  435.                     if(IsValidActor(AE_ACTOR_CREATE[i]) && AE_ACTOR_CREATE[i] != -1)
  436.                     {
  437.                         #if AE_DEBUG == 1
  438.                           printf("<AE_DEBUG> Actors Deleted: AE_ACTOR_CREATE[%d] / ID in-game: %d", i, AE_ACTOR_CREATE[i]);
  439.                         #endif
  440.                         DestroyActor(AE_ACTOR_CREATE[i]);
  441.                         AE_ACTOR_CREATE[i] = -1;
  442.                     }
  443.                 }
  444.  
  445.                 if(sizeof(ACTORS_INFO) <= (MAX_ACTORS - GetActorPoolSize())) AE_LOOP = sizeof(ACTORS_INFO);
  446.                 else AE_LOOP = MAX_ACTORS - GetActorPoolSize();
  447.  
  448.                 for(new i = 0; i < AE_LOOP; i++)
  449.                 {
  450.                     if(ACTORS_INFO[i][POSITIONS_AFTERNOON][0] != 0.0)
  451.                     {
  452.                         if(ACTORS_INFO[i][SKIN_AFTERNOON] == -1) ACTORS_INFO[i][SKIN_AFTERNOON] = random(311);
  453.                         AE_ACTOR_CREATE[i] =  CreateActor(ACTORS_INFO[i][SKIN_AFTERNOON],
  454.                                                           ACTORS_INFO[i][POSITIONS_AFTERNOON][0],   // Position X
  455.                                                           ACTORS_INFO[i][POSITIONS_AFTERNOON][1],  // Position Y
  456.                                                           ACTORS_INFO[i][POSITIONS_AFTERNOON][2],  // Position Z
  457.                                                           ACTORS_INFO[i][POSITIONS_AFTERNOON][3]); // Facing Angle (Rotation)
  458.  
  459.                         ApplyActorAnimation(AE_ACTOR_CREATE[i], ACTORS_INFO[i][ANIM_LIB_AFTERNOON], ACTORS_INFO[i][ANIM_NAME_AFTERNOON], 4.1, ACTORS_INFO[i][ANIM_LOOP_AFTERNOON], 0, 0, 0, 0);
  460.                         SetActorInvulnerable(AE_ACTOR_CREATE[i], ACTORS_INFO[i][INVULNERABLE]);
  461.                        
  462.                         #if AE_DEBUG == 1
  463.                           printf("<AE_DEBUG> Actor Created: AE_ACTOR_CREATE[%d] / Actor ID in-game: %d", i, AE_ACTOR_CREATE[i]);
  464.                         #endif
  465.                     }
  466.                 }
  467.                 print("\n- AE: Actors Afternoon Created!\n");
  468.             }
  469.         }
  470.         case AE_HOURS_NIGHT:  // Night
  471.         {
  472.             if(AE_TIME_STATE != AE_TIME_NIGHT)
  473.             {
  474.                 AE_TIME_STATE = AE_TIME_NIGHT;
  475.                 for(new i = 0; i < AE_LOOP; i++)
  476.                 {
  477.                     if(IsValidActor(AE_ACTOR_CREATE[i]) && AE_ACTOR_CREATE[i] != -1)
  478.                     {
  479.                         #if AE_DEBUG == 1
  480.                           printf("<AE_DEBUG> Actors Deleted: AE_ACTOR_CREATE[%d] / ID in-game: %d", i, AE_ACTOR_CREATE[i]);
  481.                         #endif
  482.                         DestroyActor(AE_ACTOR_CREATE[i]);
  483.                         AE_ACTOR_CREATE[i] = -1;
  484.                     }
  485.                 }
  486.  
  487.                 if(sizeof(ACTORS_INFO) <= (MAX_ACTORS - GetActorPoolSize())) AE_LOOP = sizeof(ACTORS_INFO);
  488.                 else AE_LOOP = MAX_ACTORS - GetActorPoolSize();
  489.  
  490.                 for(new i = 0; i < AE_LOOP; i++)
  491.                 {
  492.                     if(ACTORS_INFO[i][POSITIONS_NIGHT][0] != 0.0)
  493.                     {
  494.                         if(ACTORS_INFO[i][SKIN_NIGHT] == -1) ACTORS_INFO[i][SKIN_NIGHT] = random(311);
  495.                         AE_ACTOR_CREATE[i] =  CreateActor(ACTORS_INFO[i][SKIN_NIGHT],
  496.                                                           ACTORS_INFO[i][POSITIONS_NIGHT][0],   // Position X
  497.                                                           ACTORS_INFO[i][POSITIONS_NIGHT][1],  // Position Y
  498.                                                           ACTORS_INFO[i][POSITIONS_NIGHT][2],  // Position Z
  499.                                                           ACTORS_INFO[i][POSITIONS_NIGHT][3]); // Facing Angle (Rotation)
  500.  
  501.                         ApplyActorAnimation(AE_ACTOR_CREATE[i], ACTORS_INFO[i][ANIM_LIB_NIGHT], ACTORS_INFO[i][ANIM_NAME_NIGHT], 4.1, ACTORS_INFO[i][ANIM_LOOP_NIGHT], 0, 0, 0, 0);
  502.                         SetActorInvulnerable(AE_ACTOR_CREATE[i], ACTORS_INFO[i][INVULNERABLE]);
  503.                        
  504.                         #if AE_DEBUG == 1
  505.                            printf("<AE_DEBUG> Actor Created: AE_ACTOR_CREATE[%d] / Actor ID in-game: %d", i, AE_ACTOR_CREATE[i]);
  506.                         #endif
  507.                     }
  508.                 }
  509.                 print("\n- AE: Actors Night Created!\n");
  510.             }
  511.         }
  512.     }
  513. }
  514.  
  515. public OnActorStreamIn(actorid, forplayerid)
  516. {
  517.     for(new i = 0; i < AE_LOOP; i++)
  518.     {
  519.         if(actorid == AE_ACTOR_CREATE[i])
  520.         {
  521.             #if AE_ACTORS_CREATE_TYPE == 0
  522.                 SetActorPos(actorid, ACTORS_INFO[i][POSITIONS_STANDARD][0], ACTORS_INFO[i][POSITIONS_STANDARD][1], ACTORS_INFO[i][POSITIONS_STANDARD][2]);
  523.                 SetActorFacingAngle(actorid, ACTORS_INFO[i][POSITIONS_STANDARD][3]);
  524.                 ApplyActorAnimation(actorid, ACTORS_INFO[i][ANIM_LIB_STANDARD], ACTORS_INFO[i][ANIM_NAME_STANDARD], 4.1, ACTORS_INFO[i][ANIM_LOOP_STANDARD], 0, 0, 0, 0);
  525.                
  526.             #elseif AE_ACTORS_CREATE_TYPE == 1
  527.                 switch(AE_HOUR)
  528.                 {
  529.                     case AE_HOURS_DAWN:     // Dawn
  530.                     {
  531.                         SetActorPos(actorid, ACTORS_INFO[i][POSITIONS_DAWN][0], ACTORS_INFO[i][POSITIONS_DAWN][1], ACTORS_INFO[i][POSITIONS_DAWN][2]);
  532.                         SetActorFacingAngle(actorid, ACTORS_INFO[i][POSITIONS_DAWN][3]);
  533.                         ApplyActorAnimation(actorid, ACTORS_INFO[i][ANIM_LIB_DAWN], ACTORS_INFO[i][ANIM_NAME_DAWN], 4.1, ACTORS_INFO[i][ANIM_LOOP_DAWN], 0, 0, 0, 0);
  534.                     }
  535.                     case AE_HOURS_DAY:  // Day
  536.                     {
  537.                         SetActorPos(actorid, ACTORS_INFO[i][POSITIONS_DAY][0], ACTORS_INFO[i][POSITIONS_DAY][1], ACTORS_INFO[i][POSITIONS_DAY][2]);
  538.                         SetActorFacingAngle(actorid, ACTORS_INFO[i][POSITIONS_DAY][3]);
  539.                         ApplyActorAnimation(actorid, ACTORS_INFO[i][ANIM_LIB_DAY], ACTORS_INFO[i][ANIM_NAME_DAY], 4.1, ACTORS_INFO[i][ANIM_LOOP_DAY], 0, 0, 0, 0);
  540.                     }
  541.                     case AE_HOURS_AFTERNOON:    // Afternoon
  542.                     {
  543.                         SetActorPos(actorid, ACTORS_INFO[i][POSITIONS_AFTERNOON][0], ACTORS_INFO[i][POSITIONS_AFTERNOON][1], ACTORS_INFO[i][POSITIONS_AFTERNOON][2]);
  544.                         SetActorFacingAngle(actorid, ACTORS_INFO[i][POSITIONS_AFTERNOON][3]);
  545.                         ApplyActorAnimation(actorid, ACTORS_INFO[i][ANIM_LIB_AFTERNOON], ACTORS_INFO[i][ANIM_NAME_AFTERNOON], 4.1, ACTORS_INFO[i][ANIM_LOOP_AFTERNOON], 0, 0, 0, 0);
  546.                     }
  547.                     case AE_HOURS_NIGHT:    // Night
  548.                     {
  549.                         SetActorPos(actorid, ACTORS_INFO[i][POSITIONS_NIGHT][0], ACTORS_INFO[i][POSITIONS_NIGHT][1], ACTORS_INFO[i][POSITIONS_NIGHT][2]);
  550.                         SetActorFacingAngle(actorid, ACTORS_INFO[i][POSITIONS_NIGHT][3]);
  551.                         ApplyActorAnimation(actorid, ACTORS_INFO[i][ANIM_LIB_NIGHT], ACTORS_INFO[i][ANIM_NAME_NIGHT], 4.1, ACTORS_INFO[i][ANIM_LOOP_NIGHT], 0, 0, 0, 0);
  552.                     }
  553.                 }
  554.             #endif
  555.  
  556.             AE_ACTOR_SHOOTED[i] = false;
  557.  
  558.             #if AE_DEBUG == 1
  559.                 new str[80];
  560.                 format(str, sizeof str, "<AE_DEBUG> Actor %s (id-game:%d) is now streamed in for you.", ACTORS_INFO[i][NAME], actorid);
  561.                 SendClientMessage(forplayerid, 0xFFFFFFFF, str);
  562.             #endif
  563.            
  564.             break;
  565.         }
  566.     }
  567.     return 1;
  568. }
  569.  
  570. public OnPlayerGiveDamageActor(playerid, damaged_actorid, Float:amount, weaponid, bodypart)
  571. {
  572.     if(damaged_actorid != INVALID_ACTOR_ID && IsValidActor(damaged_actorid))
  573.     {
  574.         #if AE_USE_GIVE_ACTOR_DMG == 1
  575.             for(new i = 0; i < AE_LOOP; i++)
  576.             {
  577.                 if(damaged_actorid == AE_ACTOR_CREATE[i] && !AE_ACTOR_SHOOTED[i])
  578.                 {
  579.                     static Float:ACTOR_ANGLE, Float:PLAYERID_ANGLE,
  580.                            RESULT;
  581.  
  582.                     AE_ACTOR_SHOOTED[i] = true;
  583.  
  584.                     GetPlayerFacingAngle(playerid, PLAYERID_ANGLE);
  585.                     GetActorFacingAngle(damaged_actorid, ACTOR_ANGLE);
  586.                     ClearActorAnimations(damaged_actorid);
  587.  
  588.                     // Small script for detect shoot in face, chest and torso, from the front
  589.                     // or from behind. I using playerid & actor angles and compared
  590.                     // if boths they are looking
  591.                     RESULT = floatround(ACTOR_ANGLE) - floatround(PLAYERID_ANGLE);
  592.                     if(RESULT >= 135 && RESULT <= 225 || RESULT >= -135 && RESULT <= -225)
  593.                     {
  594.                         if(bodypart == 4) // Shoot in chest
  595.                             ApplyActorAnimation(damaged_actorid, "PED", "KO_shot_stom", 4.1, 0, 1, 1, 1, 0);
  596.                         else if(bodypart == 9) // Shoot in Head
  597.                             ApplyActorAnimation(damaged_actorid, "PED", "KO_shot_face", 4.1, 0, 1, 1, 1, 0);
  598.                         else if(bodypart == 3) // Shoot in Torso
  599.                             ApplyActorAnimation(damaged_actorid, "PED", "KO_shot_front", 4.1, 0, 1, 1, 1, 0);
  600.                     }
  601.                     else if(RESULT >= -45 && RESULT <= 45)
  602.                     {
  603.                         if(bodypart == 9) // Shoot in head (back)
  604.                             ApplyActorAnimation(damaged_actorid, "FINALE", "FIN_Land_Die", 4.1, 0, 1, 1, 1, 0);
  605.                         else if(bodypart == 3) // Shoot in torso (back)
  606.                             ApplyActorAnimation(damaged_actorid, "PED", "KO_skid_back", 4.1, 0, 1, 1, 1, 0);
  607.                     }
  608.                     else ApplyActorAnimation(damaged_actorid, "PED", "KO_skid_back", 4.1, 0, 1, 1, 1, 0);
  609.                     #if AE_USE_RESPAWN_ACTOR == 0
  610.                         SetTimerEx("AE_RespawnActor", AE_TIME_RESPAWN_ACTOR, false, "dd", AE_ACTOR_CREATE[i], i);
  611.                     #endif
  612.                     break;
  613.                 }
  614.             }
  615.         #endif
  616.     }
  617.     return 1;
  618. }
  619.  
  620. forward AE_RespawnActor(actorid, var_id);
  621. public AE_RespawnActor(actorid, var_id)
  622. {
  623.     #if AE_ACTORS_CREATE_TYPE == 0
  624.     SetActorPos(actorid, ACTORS_INFO[var_id][POSITIONS_STANDARD][0], ACTORS_INFO[var_id][POSITIONS_STANDARD][1], ACTORS_INFO[var_id][POSITIONS_STANDARD][2]);
  625.     SetActorFacingAngle(actorid, ACTORS_INFO[var_id][POSITIONS_STANDARD][3]);
  626.     ApplyActorAnimation(actorid, ACTORS_INFO[var_id][ANIM_LIB_STANDARD], ACTORS_INFO[var_id][ANIM_NAME_STANDARD], 4.1, 1, 0, 0, 0, 0);
  627.  
  628.     #elseif AE_ACTORS_CREATE_TYPE == 1
  629.     switch(AE_HOUR)
  630.     {
  631.         case AE_HOURS_DAWN: // Dawn
  632.         {
  633.             SetActorPos(actorid, ACTORS_INFO[var_id][POSITIONS_DAWN][0], ACTORS_INFO[var_id][POSITIONS_DAWN][1], ACTORS_INFO[var_id][POSITIONS_DAWN][2]);
  634.             SetActorFacingAngle(actorid, ACTORS_INFO[var_id][POSITIONS_DAWN][3]);
  635.             ApplyActorAnimation(actorid, ACTORS_INFO[var_id][ANIM_LIB_DAWN], ACTORS_INFO[var_id][ANIM_NAME_DAWN], 4.1, 1, 0, 0, 0, 0);
  636.         }
  637.         case AE_HOURS_DAY:  // Day
  638.         {
  639.             SetActorPos(actorid, ACTORS_INFO[var_id][POSITIONS_DAY][0], ACTORS_INFO[var_id][POSITIONS_DAY][1], ACTORS_INFO[var_id][POSITIONS_DAY][2]);
  640.             SetActorFacingAngle(actorid, ACTORS_INFO[var_id][POSITIONS_DAY][3]);
  641.             ApplyActorAnimation(actorid, ACTORS_INFO[var_id][ANIM_LIB_DAY], ACTORS_INFO[var_id][ANIM_NAME_DAY], 4.1, 1, 0, 0, 0, 0);
  642.         }
  643.         case AE_HOURS_AFTERNOON: // Afternoon
  644.         {
  645.             SetActorPos(actorid, ACTORS_INFO[var_id][POSITIONS_AFTERNOON][0], ACTORS_INFO[var_id][POSITIONS_AFTERNOON][1], ACTORS_INFO[var_id][POSITIONS_AFTERNOON][2]);
  646.             SetActorFacingAngle(actorid, ACTORS_INFO[var_id][POSITIONS_AFTERNOON][3]);
  647.             ApplyActorAnimation(actorid, ACTORS_INFO[var_id][ANIM_LIB_AFTERNOON], ACTORS_INFO[var_id][ANIM_NAME_AFTERNOON], 4.1, 1, 0, 0, 0, 0);
  648.         }
  649.         case AE_HOURS_NIGHT: // Night
  650.         {
  651.             SetActorPos(actorid, ACTORS_INFO[var_id][POSITIONS_NIGHT][0], ACTORS_INFO[var_id][POSITIONS_NIGHT][1], ACTORS_INFO[var_id][POSITIONS_NIGHT][2]);
  652.             SetActorFacingAngle(actorid, ACTORS_INFO[var_id][POSITIONS_NIGHT][3]);
  653.             ApplyActorAnimation(actorid, ACTORS_INFO[var_id][ANIM_LIB_NIGHT], ACTORS_INFO[var_id][ANIM_NAME_NIGHT], 4.1, 1, 0, 0, 0, 0);
  654.         }
  655.     }
  656.     AE_ACTOR_SHOOTED[var_id] = false;
  657.     #endif
  658. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement