| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- /****************************************************************************************************
- * *
- * )( Visible NPC HP Bar )( *
- * *
- * Copyright © 2017 Abyss Morgan. All rights reserved. *
- * *
- * Download: https://github.com/AbyssMorgan/SA-MP/tree/master/include/SAM *
- * Publication: http://forum.sa-mp.com/showthread.php?t=632664 *
- * Website: http://8.ct8.pl *
- * *
- * Plugins: YSF *
- * Modules: None *
- * *
- * File Version: 1.0.0 *
- * SA:MP Version: 0.3.7 (REQUIRE) *
- * *
- * Functions: *
- * ShowNPCInTabList(npcid); *
- * HideNPCInTabList(npcid); *
- * *
- ****************************************************************************************************/
- #if defined _visible_npc_inc
- #endinput
- #endif
- #define _visible_npc_inc
- #if (!defined GetPlayerPoolSize || !defined GetSVarInt)
- #error [ADM] This include requires SA:MP version 0.3.7 (github.com/AbyssMorgan/SA-MP/blob/master/samp/include)
- #endif
- #if ((!defined _YSF_included) || (!defined RemovePlayerForPlayer))
- #error [ADM] You need YSF R19 (github.com/kurta999/YSF/releases)
- #endif
- #define VNPC:: VNPC_
- new bool:VNPC::IsNPCVisible[MAX_PLAYERS],
- bool:VNPC::FirstSpawn[MAX_PLAYERS];
-
- stock VNPC::ShowNPCInTabListForPlayer(playerid,npcid){
- if(!IsPlayerNPC(npcid)) return 0;
- TogglePlayerFakePing(npcid,true);
- SetPlayerFakePing(npcid,0);
- RemovePlayerForPlayer(playerid,npcid);
- AddPlayerForPlayer(playerid,npcid,0);
- return 1;
- }
- stock VNPC::HideNPCInTabListForPlayer(playerid,npcid){
- if(!IsPlayerNPC(npcid)) return 0;
- TogglePlayerFakePing(npcid,true);
- SetPlayerFakePing(npcid,0);
- RemovePlayerForPlayer(playerid,npcid);
- AddPlayerForPlayer(playerid,npcid,1);
- return 1;
- }
- stock ShowNPCInTabList(npcid){
- if(!IsPlayerNPC(npcid)) return 0;
- VNPC::IsNPCVisible[npcid] = true;
- for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++){
- if(IsPlayerConnected(i) && !IsPlayerNPC(i)){
- VNPC::ShowNPCInTabListForPlayer(i,npcid);
- }
- }
- return 1;
- }
- stock HideNPCInTabList(npcid){
- if(!IsPlayerNPC(npcid)) return 0;
- VNPC::IsNPCVisible[npcid] = false;
- for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++){
- if(IsPlayerConnected(i) && !IsPlayerNPC(i)){
- VNPC::HideNPCInTabListForPlayer(i,npcid);
- }
- }
- return 1;
- }
- //Hook: OnPlayerConnect
- public OnPlayerConnect(playerid){
- if(IsPlayerNPC(playerid)){
- VNPC::IsNPCVisible[playerid] = false;
- }
- VNPC::FirstSpawn[playerid] = false;
- #if defined VNPC_OnPlayerConnect
- VNPC_OnPlayerConnect(playerid);
- #endif
- return 1;
- }
- #if defined _ALS_OnPlayerConnect
- #undef OnPlayerConnect
- #else
- #define _ALS_OnPlayerConnect
- #endif
- #define OnPlayerConnect VNPC_OnPlayerConnect
- #if defined VNPC_OnPlayerConnect
- forward VNPC_OnPlayerConnect(playerid);
- #endif
- //Hook: OnPlayerSpawn
- public OnPlayerSpawn(playerid){
- if(!VNPC::FirstSpawn[playerid]){
- VNPC::FirstSpawn[playerid] = true;
- for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++){
- if(IsPlayerConnected(i) && IsPlayerNPC(i)){
- if(VNPC::IsNPCVisible[i]){
- VNPC::ShowNPCInTabListForPlayer(playerid,i);
- }
- }
- }
- }
- #if defined VNPC_OnPlayerSpawn
- VNPC_OnPlayerSpawn(playerid);
- #endif
- return 1;
- }
- #if defined _ALS_OnPlayerSpawn
- #undef OnPlayerSpawn
- #else
- #define _ALS_OnPlayerSpawn
- #endif
- #define OnPlayerSpawn VNPC_OnPlayerSpawn
- #if defined VNPC_OnPlayerSpawn
- forward VNPC_OnPlayerSpawn(playerid);
- #endif
- //EOF
|