Advertisement
EnzoMetlc

[Include] RNPC Extended functions.

Jun 1st, 2014
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.17 KB | None | 0 0
  1. /* @ RNPC Extended Functions - (EF_RNPC).
  2.     - Fake-natives.
  3.             native RNPC_ConnectGroup(array[][], itter);
  4.             native RNPC_Kick(npcid);
  5.                    
  6.                     native RNPC_IsDeath(npcid);
  7.                     native SetHealth_RNPC(npcid, Float:Health);
  8.                     native GetHealth_RNPC(npcid);
  9.                     native RNPC_StopMove(npcid);
  10. */
  11.  
  12. #include <YSI\y_hooks>
  13.  
  14.  
  15. #if defined RNPC_FOLLOWING_TIME
  16. #error RNPC Fixes not will work with A_RNPC incorporated
  17. #endif
  18.  
  19.  
  20. #define MAX_RNPC 5
  21.  
  22. enum RNPC_Enum
  23. {
  24.     Float:HealthRNPC,
  25.     bool:IsDeathRNPC,
  26.     TimeRespawnRNPC,
  27. };
  28. new RNPC_Info[MAX_RNPC][RNPC_Enum];
  29.  
  30. #define RNPC_IsDeath(%1) RNPC_Info[%1][IsDeathRNPC]
  31. #define SetHealth_RNPC(%1,%2) RNPC_Info[%1][HealthRNPC] = %2; if(%2 <= 0) RNPC_Info[%1][HealthRNPC] = 0.00000, CallLocalFunction("RNPC_OnDeath", "ddi", 0xFFFF, %1, 53)
  32. #define GetHealth_RNPC(%1) RNPC_Info[%1][HealthRNPC]
  33. #define RNPC_Sleep@() for(new i@ = 0; i@ <= 1500; i@++) { new File:INI = fopen("asd", io_write); fclose(INI); }
  34.  
  35.  
  36. public OnPlayerConnect(playerid)
  37. {
  38.     if(IsPlayerRNPC(playerid)) return RespawnRNPC(playerid);
  39.     return 1;
  40. }
  41.  
  42. hook OnPlayerSpawn(playerid)
  43. {
  44.     if(IsPlayerRNPC(playerid)) ApplyAnimation(playerid, "PED", "FLOOR_hit_f", 4.0, 0, 1, 1, 1, 1), ClearAnimations(playerid);
  45.     else GivePlayerWeapon(playerid, 31, 50000);
  46.    
  47.     SetPlayerPos(playerid, random(10), random(10), 3.0);
  48.     return 1;
  49. }
  50.  
  51. hook OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart)
  52. {
  53.     if(IsPlayerRNPC(damagedid))
  54.     {
  55.         if(RNPC_IsDeath(damagedid)) return ApplyAnimation(damagedid, "PED", "FLOOR_hit_f", 4.0, 0, 1, 1, 1, 1);
  56.         if((GetHealth_RNPC(damagedid)-amount) > 0.00001)
  57.         {
  58.             SetHealth_RNPC(damagedid, GetHealth_RNPC(damagedid)-amount);
  59.             CallLocalFunction("RNPC_OnGiveDamage", "ddfii", damagedid, playerid, amount, weaponid, bodypart);
  60.         }
  61.         else
  62.         {
  63.             SetHealth_RNPC(damagedid, 0.0);
  64.             RNPC_Info[damagedid][IsDeathRNPC] = true;
  65.             RNPC_Info[damagedid][TimeRespawnRNPC] = SetTimerEx("RespawnRNPC", 4000, false, "d", damagedid);
  66.             RNPC_StopMove(damagedid);
  67.             ApplyAnimation(damagedid, "PED", "FLOOR_hit_f", 4.0, 0, 1, 1, 1, 1);
  68.         }
  69.     }
  70.     return 1;
  71. }
  72.  
  73.  
  74. forward RespawnRNPC(npcid);
  75. public RespawnRNPC(npcid)
  76. {
  77.     SpawnPlayer(npcid);
  78.     RNPC_Info[npcid][IsDeathRNPC] = false;
  79.     SetHealth_RNPC(npcid, 100.0);
  80.     return 1;
  81. }
  82.  
  83.  
  84. stock RNPC_ConnectGroup(array[][], itter)
  85. {
  86.     for(new i = 0; i < itter; i++)
  87.     {
  88.         ConnectRNPC(array[i]);
  89.         RNPC_Sleep@()
  90.     }
  91. }
  92.  
  93. stock RNPC_Kick(npcid)
  94. {
  95.     if(IsPlayerRNPC(npcid)) SetTimerEx("RNPC_OnDisconnect", 500, false, "d", npcid);
  96.     Kick(npcid);
  97. }
  98.  
  99. stock RNPC_StopMove(npcid)
  100. {
  101.     if(IsPlayerRNPC(npcid))
  102.     {
  103.         new Float:Pos[3];
  104.         GetPlayerPos(npcid, Pos[0], Pos[1], Pos[2]);
  105.        
  106.         RNPC_CreateBuild(npcid, PLAYER_RECORDING_TYPE_ONFOOT);
  107.         RNPC_AddMovement(Pos[0], Pos[1], Pos[2], Pos[0], Pos[1], Pos[2]);
  108.         RNPC_FinishBuild();
  109.         RNPC_StartBuildPlayback(npcid);
  110.     }
  111. }
  112.  
  113. #if defined _ALS_Kick
  114.     #undef Kick
  115. #else
  116.     #define _ALS_Kick
  117. #endif
  118. #define Kick RNPC_Kick
  119.  
  120.  
  121. forward RNPC_OnGiveDamage(npcid, playerid, Float:amount, weaponid, bodypart);
  122. forward RNPC_OnDeath(npcid, playerid, weaponid);
  123. forward RNPC_OnDisconnect(npcid);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement