vnpc.inc 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /****************************************************************************************************
  2. * *
  3. * )( Visible NPC HP Bar )( *
  4. * *
  5. * Copyright © 2017 Abyss Morgan. All rights reserved. *
  6. * *
  7. * Download: https://github.com/AbyssMorgan/SA-MP/tree/master/include/SAM *
  8. * Publication: http://forum.sa-mp.com/showthread.php?t=632664 *
  9. * Website: http://8.ct8.pl *
  10. * *
  11. * Plugins: YSF *
  12. * Modules: None *
  13. * *
  14. * File Version: 1.0.0 *
  15. * SA:MP Version: 0.3.7 (REQUIRE) *
  16. * *
  17. * Functions: *
  18. * ShowNPCInTabList(npcid); *
  19. * HideNPCInTabList(npcid); *
  20. * *
  21. ****************************************************************************************************/
  22. #if defined _visible_npc_inc
  23. #endinput
  24. #endif
  25. #define _visible_npc_inc
  26. #if (!defined GetPlayerPoolSize || !defined GetSVarInt)
  27. #error [ADM] This include requires SA:MP version 0.3.7 (github.com/AbyssMorgan/SA-MP/blob/master/samp/include)
  28. #endif
  29. #if ((!defined _YSF_included) || (!defined RemovePlayerForPlayer))
  30. #error [ADM] You need YSF R19 (github.com/kurta999/YSF/releases)
  31. #endif
  32. #define VNPC:: VNPC_
  33. new bool:VNPC::IsNPCVisible[MAX_PLAYERS],
  34. bool:VNPC::FirstSpawn[MAX_PLAYERS];
  35. stock VNPC::ShowNPCInTabListForPlayer(playerid,npcid){
  36. if(!IsPlayerNPC(npcid)) return 0;
  37. TogglePlayerFakePing(npcid,true);
  38. SetPlayerFakePing(npcid,0);
  39. RemovePlayerForPlayer(playerid,npcid);
  40. AddPlayerForPlayer(playerid,npcid,0);
  41. return 1;
  42. }
  43. stock VNPC::HideNPCInTabListForPlayer(playerid,npcid){
  44. if(!IsPlayerNPC(npcid)) return 0;
  45. TogglePlayerFakePing(npcid,true);
  46. SetPlayerFakePing(npcid,0);
  47. RemovePlayerForPlayer(playerid,npcid);
  48. AddPlayerForPlayer(playerid,npcid,1);
  49. return 1;
  50. }
  51. stock ShowNPCInTabList(npcid){
  52. if(!IsPlayerNPC(npcid)) return 0;
  53. VNPC::IsNPCVisible[npcid] = true;
  54. for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++){
  55. if(IsPlayerConnected(i) && !IsPlayerNPC(i)){
  56. VNPC::ShowNPCInTabListForPlayer(i,npcid);
  57. }
  58. }
  59. return 1;
  60. }
  61. stock HideNPCInTabList(npcid){
  62. if(!IsPlayerNPC(npcid)) return 0;
  63. VNPC::IsNPCVisible[npcid] = false;
  64. for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++){
  65. if(IsPlayerConnected(i) && !IsPlayerNPC(i)){
  66. VNPC::HideNPCInTabListForPlayer(i,npcid);
  67. }
  68. }
  69. return 1;
  70. }
  71. //Hook: OnPlayerConnect
  72. public OnPlayerConnect(playerid){
  73. if(IsPlayerNPC(playerid)){
  74. VNPC::IsNPCVisible[playerid] = false;
  75. }
  76. VNPC::FirstSpawn[playerid] = false;
  77. #if defined VNPC_OnPlayerConnect
  78. VNPC_OnPlayerConnect(playerid);
  79. #endif
  80. return 1;
  81. }
  82. #if defined _ALS_OnPlayerConnect
  83. #undef OnPlayerConnect
  84. #else
  85. #define _ALS_OnPlayerConnect
  86. #endif
  87. #define OnPlayerConnect VNPC_OnPlayerConnect
  88. #if defined VNPC_OnPlayerConnect
  89. forward VNPC_OnPlayerConnect(playerid);
  90. #endif
  91. //Hook: OnPlayerSpawn
  92. public OnPlayerSpawn(playerid){
  93. if(!VNPC::FirstSpawn[playerid]){
  94. VNPC::FirstSpawn[playerid] = true;
  95. for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++){
  96. if(IsPlayerConnected(i) && IsPlayerNPC(i)){
  97. if(VNPC::IsNPCVisible[i]){
  98. VNPC::ShowNPCInTabListForPlayer(playerid,i);
  99. }
  100. }
  101. }
  102. }
  103. #if defined VNPC_OnPlayerSpawn
  104. VNPC_OnPlayerSpawn(playerid);
  105. #endif
  106. return 1;
  107. }
  108. #if defined _ALS_OnPlayerSpawn
  109. #undef OnPlayerSpawn
  110. #else
  111. #define _ALS_OnPlayerSpawn
  112. #endif
  113. #define OnPlayerSpawn VNPC_OnPlayerSpawn
  114. #if defined VNPC_OnPlayerSpawn
  115. forward VNPC_OnPlayerSpawn(playerid);
  116. #endif
  117. //EOF