Advertisement
Guest User

Atrox Wanted Labels

a guest
Jan 13th, 2013
604
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.96 KB | None | 0 0
  1. /**
  2.     *@project   Wanted labels
  3.     *@author:   Atrox <atrox-dev.de>
  4.     *@license:  CC BY-NC-SA 3.0 <http://creativecommons.org/licenses/by-nc-sa/3.0/>
  5.     *@date:     01/13/2013
  6.    
  7.     Don't remove any copyright message without my permission.
  8. **/
  9.  
  10. #include <a_samp>
  11. #include <streamer> //Incognitos Streamer Plugin
  12.  
  13. #define COLOR_LIGHTBLUE     0x00C2ECFF
  14.  
  15. enum PInfo
  16. {
  17.     Text3D: PPlayerLabel[MAX_PLAYERS],
  18.     WantedLevel,
  19.     Logged
  20. };
  21. new PlayerInfo[MAX_PLAYERS][PInfo];
  22.  
  23. //Use this DeletePlayerWantedLabelFP(playerid); for a cop if he is kicked out of the duty, game, job etc.
  24. stock DeletePlayerWantedLabelFP(playerid)
  25. {
  26.     for(new i = 0; i < MAX_PLAYERS; i++)
  27.     {
  28.         if(IsValidDynamic3DTextLabel(PlayerInfo[playerid][PPlayerLabel][i]))
  29.             DestroyDynamic3DTextLabel(PlayerInfo[playerid][PPlayerLabel][i]);
  30.     }
  31.     return 1;
  32. }
  33.  
  34. //Use this DeletePlayerWantedLabel(playerid); if you jail a player or if you completely remove his wanteds.
  35. stock DeletePlayerWantedLabel(playerid)
  36. {
  37.     //if(PlayerInfo[playerid][WantedLevel] == 0) return 1;
  38.     for(new i = 0; i < MAX_PLAYERS; i++)
  39.     {
  40.         if(IsValidDynamic3DTextLabel(PlayerInfo[i][PPlayerLabel][playerid]))
  41.             DestroyDynamic3DTextLabel(PlayerInfo[i][PPlayerLabel][playerid]);
  42.     }
  43.     return 1;
  44. }
  45. //Use this CreatePlayerWantedLabel(playerid); if you give a player wanteds. This function also updates the current wanted number.
  46. stock CreatePlayerWantedLabel(playerid)
  47. {
  48.     if(PlayerInfo[playerid][WantedLevel] == 0) return 1;
  49.     for(new i = 0; i < MAX_PLAYERS; i++)
  50.     {
  51.         if(IsPlayerConnected(i) && IsPlayerCopOrArmy(i))
  52.         {
  53.             if(PlayerInfo[i][Logged] == 0) continue;
  54.  
  55.             format(string, sizeof(string), "Wanteds: %d", PlayerInfo[playerid][WantedLevel]);
  56.             if(!IsValidDynamic3DTextLabel(PlayerInfo[i][PPlayerLabel][playerid]))
  57.                 PlayerInfo[i][PPlayerLabel][playerid] = CreateDynamic3DTextLabel(string, COLOR_LIGHTBLUE, 0.0, 0.0, 0.4, 30.0, playerid, INVALID_VEHICLE_ID, 1, -1, -1, i);
  58.             else
  59.                 UpdateDynamic3DTextLabelText(PlayerInfo[i][PPlayerLabel][playerid], COLOR_LIGHTBLUE, string);
  60.         }
  61.     }
  62.     return 1;
  63. }
  64. //use this CopCreatePlayerWanteds(playerid); for cops if they start their duty.
  65. //This function creates the Wanted Labels for cops etc.
  66. stock CopCreatePlayerWanteds(playerid)
  67. {
  68.     for(new i = 0; i < MAX_PLAYERS; i++)
  69.     {
  70.         if(!IsPlayerConnected(i) || PlayerInfo[i][Logged] == 0) continue;
  71.         if(PlayerInfo[i][WantedLevel] > 0)
  72.         {
  73.             format(string, sizeof(string), "Wanteds: %d", PlayerInfo[i][WantedLevel]);
  74.             if(!IsValidDynamic3DTextLabel(PlayerInfo[playerid][PPlayerLabel][i]))
  75.             {
  76.                 PlayerInfo[playerid][PPlayerLabel][i] = CreateDynamic3DTextLabel(string, COLOR_LIGHTBLUE, 0.0, 0.0, 0.4, 30.0, i, INVALID_VEHICLE_ID, 1, -1, -1, playerid);
  77.             }
  78.             else
  79.                 UpdateDynamic3DTextLabelText(PlayerInfo[playerid][PPlayerLabel][i], COLOR_LIGHTBLUE, string);
  80.         }
  81.     }
  82. }
  83.  
  84.  
  85. public OnPlayerDisconnect(playerid, reason)
  86. {
  87.     DeletePlayerWantedLabel(playerid);
  88.     DeletePlayerWantedLabelFP(playerid);
  89.     return 1;
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement