Guest User

iGetty's Mask System

a guest
Feb 2nd, 2013
838
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.98 KB | None | 0 0
  1. /* ----------------------------------------------------------
  2. This is a simple masking system created by iGetty. This system
  3. allows you to mask and hide your name from other players and will
  4. also hide your name and show a label of "Masked Player_%d", where
  5. the %d would be a random value that is assigned upon "/mask".
  6.  
  7. This will also automatically remove the mask when a player disconnects.
  8. If a player dies with a mask on, they will then have the mask forcefully removed
  9. and it will then show the players name tag again for all players.
  10.  
  11. There is also a name checking system that I implemented for people that may
  12. want to use this in a game mode. They can use the following:
  13.  
  14. pMaskName(playerid), to check if the player is masked or not, if they are it will
  15. return "Mask %d", if not it will return the actual player name.
  16.  
  17. Commands:
  18. /mask
  19. /unmask
  20. /removemask (RCON admin)
  21.  
  22. Credits:
  23. ZeeX for ZCMD.
  24. Incognito for Streamer.
  25. Y_Less for sscanf2
  26. SA-MP team for the ability to script for SA-MP and for the a_samp include.
  27. iGetty for creating this filterscript.
  28.  
  29. Please don't remove any credits for this script as it was created for the SA-MP
  30. community out of good will and I would appreciate it if you could at least be
  31. respectful enough to keep them there.
  32.  
  33. Thank you for using the script.
  34.  
  35. iGetty.
  36. ---------------------------------------------------------- */
  37.  
  38. #include <a_samp>
  39. #include <zcmd>
  40. #include <sscanf2>
  41. #include <streamer>
  42.  
  43. new Masked[MAX_PLAYERS], Text3D:MaskLabel[MAX_PLAYERS], MaskID[MAX_PLAYERS];
  44.  
  45. #undef MAX_PLAYERS
  46. #define MAX_PLAYERS GetMaxPlayers()
  47.  
  48. public OnFilterScriptInit()
  49. {
  50.     print("\n--------------------------------------");
  51.     print(" Simple Mask System by iGetty loaded!");
  52.     print("--------------------------------------\n");
  53.     return 1;
  54. }
  55.  
  56. public OnFilterScriptExit()
  57. {
  58.     print("\n--------------------------------------");
  59.     print(" Simple Mask System by iGetty unloaded!");
  60.     print("--------------------------------------\n");
  61.     return 1;
  62. }
  63.  
  64. public OnPlayerConnect(playerid)
  65. {
  66.     Masked[playerid] = 0;
  67.     MaskID[playerid] = 0;
  68.    
  69.     for(new i = 0; i < MAX_PLAYERS; i++)
  70.     {
  71.         if(Masked[i] == 1)
  72.         {
  73.             ShowPlayerNameTagForPlayer(i, playerid, false);
  74.         }
  75.         else
  76.         {
  77.             ShowPlayerNameTagForPlayer(i, playerid, true);
  78.         }
  79.     }
  80.     return 1;
  81. }
  82.  
  83. public OnPlayerDisconnect(playerid, reason)
  84. {
  85.     if(Masked[playerid] == 1)
  86.     {
  87.         Masked[playerid] = 0;
  88.         MaskID[playerid] = 0;
  89.         DestroyDynamic3DTextLabel(MaskLabel[playerid]);
  90.     }
  91.     return 1;
  92. }
  93.  
  94. public OnPlayerDeath(playerid, killerid, reason)
  95. {
  96.     if(Masked[playerid] == 1)
  97.     {
  98.         DestroyDynamic3DTextLabel(MaskLabel[playerid]);
  99.         for(new i = 0; i < MAX_PLAYERS; i++) ShowPlayerNameTagForPlayer(i, playerid, true);
  100.         Masked[playerid] = 0;
  101.         MaskID[playerid] = 0;
  102.         SendClientMessage(playerid, -1, "As you have died, the nurses took off your mask to reveal your identity.");
  103.     }
  104.     return 1;
  105. }
  106.  
  107. public OnPlayerText(playerid, text[])
  108. {
  109.     new string[128];
  110.     format(string, sizeof(string), "%s %s", pMaskName(playerid), text);
  111.     SendClientMessageToAll(-1, string);
  112.     return 0;
  113. }
  114.  
  115. command(mask, playerid, params[])
  116. {
  117.     if(Masked[playerid] == 0)
  118.     {
  119.         new rand = 1000 + random(8999), string[128];
  120.         MaskID[playerid] = rand;
  121.         for(new i = 0; i < MAX_PLAYERS; i++) ShowPlayerNameTagForPlayer(i, playerid, false);
  122.         Masked[playerid] = 1;
  123.         format(string, sizeof(string), "Masked Player_%d", MaskID[playerid]);
  124.         MaskLabel[playerid] = CreateDynamic3DTextLabel(string, -1, 0, 0, -20, 25, playerid);
  125.         Streamer_SetFloatData(STREAMER_TYPE_3D_TEXT_LABEL, MaskLabel[playerid] , E_STREAMER_ATTACH_OFFSET_Z, 0.30);
  126.         format(string, sizeof(string), "** %s has just put on a mask!", pName(playerid));
  127.         SendClientMessageToAll(-1, string);
  128.     }
  129.     else return SendClientMessage(playerid, -1, "You are already masked!");
  130.     return 1;
  131. }
  132.  
  133. command(removemask, playerid, params[])
  134. {
  135.     if(IsPlayerAdmin(playerid))
  136.     {
  137.         new id, string[128];
  138.         if(sscanf(params, "u", id))return SendClientMessage(playerid, -1, "Usage: /removemask [player id or name]");
  139.         {
  140.             if(IsPlayerConnected(id))
  141.             {
  142.                 if(Masked[id] == 1)
  143.                 {
  144.                     format(string, sizeof(string), "Admin %s has forced %s to take off their mask.", pName(playerid), pName(id));
  145.                     SendClientMessageToAll(-1, string);
  146.                     DestroyDynamic3DTextLabel(MaskLabel[id]);
  147.                     for(new i = 0; i < MAX_PLAYERS; i++) ShowPlayerNameTagForPlayer(i, id, true);
  148.                     Masked[id] = 0;
  149.                     MaskID[id] = 0;
  150.                 }
  151.                 else return SendClientMessage(playerid, -1, "That player isn't masked.");
  152.             }
  153.             else return SendClientMessage(playerid, -1, "That player isn't connected.");
  154.         }
  155.     }
  156.     else return SendClientMessage(playerid, -1, "You must be logged into RCON to use this.");
  157.     return 1;
  158. }
  159.  
  160. command(unmask, playerid, params[])
  161. {
  162.     if(Masked[playerid] == 1)
  163.     {
  164.         new string[128];
  165.         format(string, sizeof(string), "** %s has taken off their mask!", pName(playerid));
  166.         SendClientMessageToAll(-1, string);
  167.         DestroyDynamic3DTextLabel(MaskLabel[playerid]);
  168.         for(new i = 0; i < MAX_PLAYERS; i++) ShowPlayerNameTagForPlayer(i, playerid, true);
  169.         Masked[playerid] = 0;
  170.         MaskID[playerid] = 0;
  171.     }
  172.     else return SendClientMessage(playerid, -1, "You aren't masked!");
  173.     return 1;
  174. }
  175.  
  176. public OnPlayerUpdate(playerid)
  177. {
  178.     if(Masked[playerid] == 0)
  179.     {
  180.         for(new i = 0; i < MAX_PLAYERS; i++)
  181.         {
  182.             ShowPlayerNameTagForPlayer(i, playerid, true);
  183.         }
  184.     }
  185.  
  186.     if(Masked[playerid] == 1)
  187.     {
  188.         for(new i = 0; i < MAX_PLAYERS; i++)
  189.         {
  190.             ShowPlayerNameTagForPlayer(i, playerid, false);
  191.         }
  192.     }
  193.     return 1;
  194. }
  195.  
  196. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  197. {
  198.     return 1;
  199. }
  200.  
  201. stock pMaskName(playerid)
  202. {
  203.     new string[25];
  204.     if(Masked[playerid] == 1) format(string, sizeof(string), "Mask %d", MaskID[playerid]);
  205.     else format(string, sizeof(string), "%s", pName(playerid));
  206.     return string;
  207. }
  208.  
  209. stock pName(playerid)
  210. {
  211.     new name[24];
  212.     GetPlayerName(playerid, name, sizeof(name));
  213.     return name;
  214. }
Advertisement
Add Comment
Please, Sign In to add comment