Advertisement
Guest User

VIP Protection

a guest
Mar 31st, 2016
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 18.37 KB | None | 0 0
  1. #define     FILTERSCRIPT
  2. #include    <a_samp>
  3. #include    <streamer>
  4. #include    <izcmd>
  5.  
  6. // VIP Settings
  7. #define     VIP_REQUIRED        (1000000)   // money required for becoming VIP (default: 1000000)
  8. #define     VIP_RANGE           (10.0)      // range of VIP area (default: 10.0)
  9. #define     BODYGUARD_LIMIT     (5)         // a VIP can hire up to x bodyguards (default: 5)
  10.  
  11. // Bodyguard Settings
  12. #define     STARTING_SALARY     (5000)      // how much money a bodyguard gets paid for being near their VIP for a certain amount of time (default: 5000)
  13. #define     MIN_SALARY          (500)       // min. amount of bodyguard salary (default: 500)
  14. #define     SALARY_PENALTY      (250)       // how much money will be taken from the salary if the VIP dies (default: 250)
  15. #define     SALARY_TIME         (300)       // a bodyguard must be near their VIP for x seconds to get his payment (default: 300)
  16.  
  17. // Dialog IDs
  18. enum
  19. {
  20.     DIALOG_HIRE_BODYGUARD = 16200,
  21.     DIALOG_FIRE_BODYGUARD,
  22.     DIALOG_LABEL_COLOR
  23. }
  24.  
  25. // Variables for the VIP
  26. new
  27.     bool: IsVIP[MAX_PLAYERS],
  28.     VIPArea[MAX_PLAYERS] = {-1, ...},
  29.     VIPVicinityTimer[MAX_PLAYERS] = {-1, ...},
  30.     VIPColor[MAX_PLAYERS] = {0xD78E10FF, ...},
  31.     Text3D: VIPLabel[MAX_PLAYERS] = {Text3D: INVALID_3DTEXT_ID, ...};
  32.    
  33. // Variables for the bodyguard
  34. new
  35.     bool: LookingForJob[MAX_PLAYERS],
  36.     ProtectingID[MAX_PLAYERS] = {INVALID_PLAYER_ID, ...},
  37.     Salary[MAX_PLAYERS] = {STARTING_SALARY, ...},
  38.     SecondsNearVIP[MAX_PLAYERS];
  39.    
  40. new
  41.     LabelColors[256] = {
  42.         0x000000FF, 0xF5F5F5FF, 0x2A77A1FF, 0x840410FF, 0x263739FF, 0x86446EFF, 0xD78E10FF, 0x4C75B7FF, 0xBDBEC6FF, 0x5E7072FF,
  43.         0x46597AFF, 0x656A79FF, 0x5D7E8DFF, 0x58595AFF, 0xD6DAD6FF, 0x9CA1A3FF, 0x335F3FFF, 0x730E1AFF, 0x7B0A2AFF, 0x9F9D94FF,
  44.         0x3B4E78FF, 0x732E3EFF, 0x691E3BFF, 0x96918CFF, 0x515459FF, 0x3F3E45FF, 0xA5A9A7FF, 0x635C5AFF, 0x3D4A68FF, 0x979592FF,
  45.         0x421F21FF, 0x5F272BFF, 0x8494ABFF, 0x767B7CFF, 0x646464FF, 0x5A5752FF, 0x252527FF, 0x2D3A35FF, 0x93A396FF, 0x6D7A88FF,
  46.         0x221918FF, 0x6F675FFF, 0x7C1C2AFF, 0x5F0A15FF, 0x193826FF, 0x5D1B20FF, 0x9D9872FF, 0x7A7560FF, 0x989586FF, 0xADB0B0FF,
  47.         0x848988FF, 0x304F45FF, 0x4D6268FF, 0x162248FF, 0x272F4BFF, 0x7D6256FF, 0x9EA4ABFF, 0x9C8D71FF, 0x6D1822FF, 0x4E6881FF,
  48.         0x9C9C98FF, 0x917347FF, 0x661C26FF, 0x949D9FFF, 0xA4A7A5FF, 0x8E8C46FF, 0x341A1EFF, 0x6A7A8CFF, 0xAAAD8EFF, 0xAB988FFF,
  49.         0x851F2EFF, 0x6F8297FF, 0x585853FF, 0x9AA790FF, 0x601A23FF, 0x20202CFF, 0xA4A096FF, 0xAA9D84FF, 0x78222BFF, 0x0E316DFF,
  50.         0x722A3FFF, 0x7B715EFF, 0x741D28FF, 0x1E2E32FF, 0x4D322FFF, 0x7C1B44FF, 0x2E5B20FF, 0x395A83FF, 0x6D2837FF, 0xA7A28FFF,
  51.         0xAFB1B1FF, 0x364155FF, 0x6D6C6EFF, 0x0F6A89FF, 0x204B6BFF, 0x2B3E57FF, 0x9B9F9DFF, 0x6C8495FF, 0x4D8495FF, 0xAE9B7FFF,
  52.         0x406C8FFF, 0x1F253BFF, 0xAB9276FF, 0x134573FF, 0x96816CFF, 0x64686AFF, 0x105082FF, 0xA19983FF, 0x385694FF, 0x525661FF,
  53.         0x7F6956FF, 0x8C929AFF, 0x596E87FF, 0x473532FF, 0x44624FFF, 0x730A27FF, 0x223457FF, 0x640D1BFF, 0xA3ADC6FF, 0x695853FF,
  54.         0x9B8B80FF, 0x620B1CFF, 0x5B5D5EFF, 0x624428FF, 0x731827FF, 0x1B376DFF, 0xEC6AAEFF, 0x000000FF, 0x177517FF, 0x210606FF,
  55.         0x125478FF, 0x452A0DFF, 0x571E1EFF, 0x010701FF, 0x25225AFF, 0x2C89AAFF, 0x8A4DBDFF, 0x35963AFF, 0xB7B7B7FF, 0x464C8DFF,
  56.         0x84888CFF, 0x817867FF, 0x817A26FF, 0x6A506FFF, 0x583E6FFF, 0x8CB972FF, 0x824F78FF, 0x6D276AFF, 0x1E1D13FF, 0x1E1306FF,
  57.         0x1F2518FF, 0x2C4531FF, 0x1E4C99FF, 0x2E5F43FF, 0x1E9948FF, 0x1E9999FF, 0x999976FF, 0x7C8499FF, 0x992E1EFF, 0x2C1E08FF,
  58.         0x142407FF, 0x993E4DFF, 0x1E4C99FF, 0x198181FF, 0x1A292AFF, 0x16616FFF, 0x1B6687FF, 0x6C3F99FF, 0x481A0EFF, 0x7A7399FF,
  59.         0x746D99FF, 0x53387EFF, 0x222407FF, 0x3E190CFF, 0x46210EFF, 0x991E1EFF, 0x8D4C8DFF, 0x805B80FF, 0x7B3E7EFF, 0x3C1737FF,
  60.         0x733517FF, 0x781818FF, 0x83341AFF, 0x8E2F1CFF, 0x7E3E53FF, 0x7C6D7CFF, 0x020C02FF, 0x072407FF, 0x163012FF, 0x16301BFF,
  61.         0x642B4FFF, 0x368452FF, 0x999590FF, 0x818D96FF, 0x99991EFF, 0x7F994CFF, 0x839292FF, 0x788222FF, 0x2B3C99FF, 0x3A3A0BFF,
  62.         0x8A794EFF, 0x0E1F49FF, 0x15371CFF, 0x15273AFF, 0x375775FF, 0x060820FF, 0x071326FF, 0x20394BFF, 0x2C5089FF, 0x15426CFF,
  63.         0x103250FF, 0x241663FF, 0x692015FF, 0x8C8D94FF, 0x516013FF, 0x090F02FF, 0x8C573AFF, 0x52888EFF, 0x995C52FF, 0x99581EFF,
  64.         0x993A63FF, 0x998F4EFF, 0x99311EFF, 0x0D1842FF, 0x521E1EFF, 0x42420DFF, 0x4C991EFF, 0x082A1DFF, 0x96821DFF, 0x197F19FF,
  65.         0x3B141FFF, 0x745217FF, 0x893F8DFF, 0x7E1A6CFF, 0x0B370BFF, 0x27450DFF, 0x071F24FF, 0x784573FF, 0x8A653AFF, 0x732617FF,
  66.         0x319490FF, 0x56941DFF, 0x59163DFF, 0x1B8A2FFF, 0x38160BFF, 0x041804FF, 0x355D8EFF, 0x2E3F5BFF, 0x561A28FF, 0x4E0E27FF,
  67.         0x706C67FF, 0x3B3E42FF, 0x2E2D33FF, 0x7B7E7DFF, 0x4A4442FF, 0x28344EFF
  68.     };
  69.  
  70. // Functions
  71. VIP_Activate(playerid)
  72. {
  73.     IsVIP[playerid] = true;
  74.    
  75.     VIPArea[playerid] = CreateDynamicSphere(0.0, 0.0, 0.0, VIP_RANGE);
  76.     AttachDynamicAreaToPlayer(VIPArea[playerid], playerid);
  77.    
  78.     VIPVicinityTimer[playerid] = SetTimerEx("BodyguardSecondUpdate", 1000, true, "i", playerid);
  79.     VIPLabel[playerid] = CreateDynamic3DTextLabel("VIP", VIPColor[playerid], 0.0, 0.0, 0.0, VIP_RANGE, playerid, _, 1);
  80.     return 1;
  81. }
  82.  
  83. VIP_SendMessage(playerid, msg[])
  84. {
  85.     SendClientMessage(playerid, 0x3498DBFF, msg);
  86.    
  87.     for(new i, p = GetPlayerPoolSize(); i <= p; i++)
  88.     {
  89.         if(!IsPlayerConnected(i)) continue;
  90.         if(ProtectingID[i] == playerid) SendClientMessage(i, 0x3498DBFF, msg);
  91.     }
  92.    
  93.     return 1;
  94. }
  95.  
  96. VIP_BodyguardCount(playerid)
  97. {
  98.     new count = 0;
  99.     for(new i, p = GetPlayerPoolSize(); i <= p; i++)
  100.     {
  101.         if(!IsPlayerConnected(i)) continue;
  102.         if(ProtectingID[i] == playerid) count++;
  103.     }
  104.    
  105.     return count;
  106. }
  107.  
  108. VIP_CleanUp(playerid, resignguards = 0)
  109. {
  110.     if(IsValidDynamicArea(VIPArea[playerid])) DestroyDynamicArea(VIPArea[playerid]);
  111.     if(IsValidDynamic3DTextLabel(VIPLabel[playerid])) DestroyDynamic3DTextLabel(VIPLabel[playerid]);
  112.     if(VIPVicinityTimer[playerid] != -1) VIPVicinityTimer[playerid] = -1;
  113.     IsVIP[playerid] = false;
  114.     VIPArea[playerid] = -1;
  115.     VIPVicinityTimer[playerid] = -1;
  116.     VIPColor[playerid] = 0xD78E10FF;
  117.     VIPLabel[playerid] = Text3D: INVALID_3DTEXT_ID;
  118.    
  119.     if(resignguards)
  120.     {
  121.         for(new i, p = GetPlayerPoolSize(); i <= p; i++)
  122.         {
  123.             if(!IsPlayerConnected(i)) continue;
  124.             if(ProtectingID[i] == playerid)
  125.             {
  126.                 SendClientMessage(i, 0x3498DBFF, "BODYGUARD: {FFFFFF}The VIP you were assigned to left the game.");
  127.                 SendClientMessage(i, 0x3498DBFF, "BODYGUARD: {FFFFFF}You can look for an another job if you want to.");
  128.                 Bodyguard_CleanUp(i);
  129.             }
  130.         }
  131.     }
  132.    
  133.     return 1;
  134. }
  135.  
  136. Bodyguard_CleanUp(playerid)
  137. {
  138.     if(IsValidDynamic3DTextLabel(VIPLabel[playerid])) DestroyDynamic3DTextLabel(VIPLabel[playerid]);
  139.     LookingForJob[playerid] = false;
  140.     ProtectingID[playerid] = INVALID_PLAYER_ID;
  141.     Salary[playerid] = STARTING_SALARY;
  142.     SecondsNearVIP[playerid] = 0;
  143.     VIPLabel[playerid] = Text3D: INVALID_3DTEXT_ID;
  144.     return 1;
  145. }
  146.  
  147. GetIDFromName(name[])
  148. {
  149.     new p_name[MAX_PLAYER_NAME];
  150.     for(new i, p = GetPlayerPoolSize(); i <= p; i++)
  151.     {
  152.         if(!IsPlayerConnected(i)) continue;
  153.         GetPlayerName(i, p_name, MAX_PLAYER_NAME);
  154.         if(!strcmp(p_name, name)) return i;
  155.     }
  156.  
  157.     return INVALID_PLAYER_ID;
  158. }
  159.  
  160. // Callbacks
  161. public OnFilterScriptInit()
  162. {
  163.     for(new i, p = GetPlayerPoolSize(); i <= p; i++)
  164.     {
  165.         if(!IsPlayerConnected(i)) continue;
  166.         Bodyguard_CleanUp(i);
  167.         VIP_CleanUp(i);
  168.     }
  169.    
  170.     return 1;
  171. }
  172.  
  173. public OnPlayerConnect(playerid)
  174. {
  175.     Bodyguard_CleanUp(playerid);
  176.     VIP_CleanUp(playerid);
  177.     return 1;
  178. }
  179.  
  180. public OnPlayerDisconnect(playerid, reason)
  181. {
  182.     Bodyguard_CleanUp(playerid);
  183.     VIP_CleanUp(playerid, 1);
  184.     return 1;
  185. }
  186.  
  187. public OnPlayerDeath(playerid, killerid, reason)
  188. {
  189.     if(IsPlayerConnected(killerid) && IsVIP[playerid])
  190.     {
  191.         new string[96];
  192.         format(string, sizeof(string), "BODYGUARD: {FFFFFF}Your VIP died. {2ECC71}$%d {FFFFFF}has been cut from your salary.", SALARY_PENALTY);
  193.        
  194.         for(new i, p = GetPlayerPoolSize(); i <= p; i++)
  195.         {
  196.             if(!IsPlayerConnected(i)) continue;
  197.             if(ProtectingID[i] != playerid) continue;
  198.             SendClientMessage(i, 0x3498DBFF, string);
  199.            
  200.             Salary[i] -= SALARY_PENALTY;
  201.             if(Salary[i] < MIN_SALARY) Salary[i] = MIN_SALARY;
  202.            
  203.             format(string, sizeof(string), "BODYGUARD: {FFFFFF}New salary: {2ECC71}$%d.", Salary[i]);
  204.             SendClientMessage(i, 0x3498DBFF, string);
  205.         }
  206.     }
  207.    
  208.     return 1;
  209. }
  210.  
  211. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  212. {
  213.     switch(dialogid)
  214.     {
  215.         case DIALOG_HIRE_BODYGUARD:
  216.         {
  217.             if(response)
  218.             {
  219.                 if(!IsVIP[playerid]) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You're not a VIP.");
  220.                 new id = GetIDFromName(inputtext);
  221.                 if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Player is offline.");
  222.                 if(!LookingForJob[id]) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Player isn't looking for a job.");
  223.                 if(IsVIP[id] || IsPlayerConnected(ProtectingID[id])) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Player isn't available.");
  224.                 Bodyguard_CleanUp(id);
  225.                 ProtectingID[id] = playerid;
  226.                
  227.                 new string[128], name[MAX_PLAYER_NAME];
  228.                 GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  229.                 format(string, sizeof(string), "BODYGUARD: {FFFFFF}You got hired by %s(%d).", name, playerid);
  230.                 SendClientMessage(id, 0x3498DBFF, string);
  231.                 SendClientMessage(id, 0x3498DBFF, "BODYGUARD: {FFFFFF}You can use /resign to resign.");
  232.                
  233.                 format(string, sizeof(string), "%s's Bodyguard", name);
  234.                 VIPLabel[id] = CreateDynamic3DTextLabel(string, VIPColor[playerid], 0.0, 0.0, 0.0, VIP_RANGE, id, _, 1);
  235.                
  236.                 GetPlayerName(id, name, MAX_PLAYER_NAME);
  237.                 format(string, sizeof(string), "VIP: {FFFFFF}You hired %s(%d).", name, id);
  238.                 SendClientMessage(playerid, 0x3498DBFF, string);
  239.             }
  240.            
  241.             return 1;
  242.         }
  243.        
  244.         case DIALOG_FIRE_BODYGUARD:
  245.         {
  246.             if(response)
  247.             {
  248.                 if(!IsVIP[playerid]) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You're not a VIP.");
  249.                 new id = GetIDFromName(inputtext);
  250.                 if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Player is offline.");
  251.                 if(ProtectingID[id] != playerid) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Player isn't your bodyguard.");
  252.                 Bodyguard_CleanUp(id);
  253.  
  254.                 new string[128], name[MAX_PLAYER_NAME];
  255.                 GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  256.                 format(string, sizeof(string), "BODYGUARD: {FFFFFF}You got fired by %s(%d).", name, playerid);
  257.                 SendClientMessage(id, 0x3498DBFF, string);
  258.                 SendClientMessage(id, 0x3498DBFF, "BODYGUARD: {FFFFFF}You can use /lookforjob to become available again.");
  259.                
  260.                 GetPlayerName(id, name, MAX_PLAYER_NAME);
  261.                 format(string, sizeof(string), "VIP: {FFFFFF}You fired %s(%d).", name, id);
  262.                 SendClientMessage(playerid, 0x3498DBFF, string);
  263.             }
  264.  
  265.             return 1;
  266.         }
  267.        
  268.         case DIALOG_LABEL_COLOR:
  269.         {
  270.             if(response)
  271.             {
  272.                 if(!IsVIP[playerid]) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You're not a VIP.");
  273.                 if(!strlen(inputtext)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Choose a color ID.");
  274.                 new color = strval(inputtext);
  275.                 if(!(0 <= color <= sizeof(LabelColors)-1)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Invalid color ID.");
  276.                 VIPColor[playerid] = LabelColors[color];
  277.                 Streamer_SetIntData(STREAMER_TYPE_3D_TEXT_LABEL, VIPLabel[playerid], E_STREAMER_COLOR, VIPColor[playerid]);
  278.                
  279.                 for(new i, p = GetPlayerPoolSize(); i <= p; i++)
  280.                 {
  281.                     if(!IsPlayerConnected(i)) continue;
  282.                     if(ProtectingID[i] != playerid) continue;
  283.                     Streamer_SetIntData(STREAMER_TYPE_3D_TEXT_LABEL, VIPLabel[i], E_STREAMER_COLOR, VIPColor[playerid]);
  284.                 }
  285.             }
  286.            
  287.             return 1;
  288.         }
  289.     }
  290.    
  291.     return 0;
  292. }
  293.  
  294. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  295. {
  296.     if(hittype == BULLET_HIT_TYPE_PLAYER && IsPlayerConnected(hitid))
  297.     {
  298.         // a VIP can't shoot their bodyguard
  299.         if(IsVIP[playerid] && ProtectingID[hitid] == playerid) return 0;
  300.        
  301.         // a bodyguard can't shoot their VIP
  302.         if(IsVIP[hitid] && ProtectingID[playerid] == hitid) return 0;
  303.     }
  304.    
  305.     return 1;
  306. }
  307.  
  308. forward BodyguardSecondUpdate(playerid);
  309. public BodyguardSecondUpdate(playerid)
  310. {
  311.     new string[64];
  312.     for(new i, p = GetPlayerPoolSize(); i <= p; i++)
  313.     {
  314.         if(!IsPlayerConnected(i)) continue;
  315.         if(ProtectingID[i] != playerid) continue;
  316.         if(!IsPlayerInDynamicArea(i, VIPArea[playerid])) continue;
  317.         SecondsNearVIP[i]++;
  318.        
  319.         if(SecondsNearVIP[i] >= SALARY_TIME)
  320.         {
  321.             format(string, sizeof(string), "BODYGUARD: {FFFFFF}VIP protection payment: {2ECC71}$%d.", Salary[i]);
  322.             SendClientMessage(i, 0x3498DBFF, string);
  323.            
  324.             GivePlayerMoney(i, Salary[i]);
  325.             SecondsNearVIP[i] = 0;
  326.         }
  327.     }
  328.    
  329.     return 1;
  330. }
  331.  
  332. // VIP Commands
  333. CMD:becomevip(playerid, params[])
  334. {
  335.     if(IsVIP[playerid]) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You're already a VIP.");
  336.     if(LookingForJob[playerid]) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You can't be a VIP while looking for a job.");
  337.     if(IsPlayerConnected(ProtectingID[playerid])) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You can't become a VIP while protecting someone.");
  338.     if(VIP_REQUIRED > GetPlayerMoney(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You don't have enough money to be a VIP.");
  339.     SendClientMessage(playerid, 0x3498DBFF, "VIP: {FFFFFF}You're a VIP now.");
  340.     SendClientMessage(playerid, 0x3498DBFF, "VIP: {FFFFFF}You can hire bodyguards using /hire.");
  341.     SendClientMessage(playerid, 0x3498DBFF, "VIP: {FFFFFF}You can fire your bodyguards using /bodyguards.");
  342.     SendClientMessage(playerid, 0x3498DBFF, "VIP: {FFFFFF}You can use /vmsg to send a message to your bodyguards.");
  343.     SendClientMessage(playerid, 0x3498DBFF, "VIP: {FFFFFF}You can use /vcol to change the label color of your bodyguards and yourself.");
  344.     SendClientMessage(playerid, 0x3498DBFF, "VIP: {FFFFFF}You can cancel your VIP by using /cancelvip.");
  345.     VIP_Activate(playerid);
  346.     return 1;
  347. }
  348.  
  349. CMD:hire(playerid, params[])
  350. {
  351.     if(!IsVIP[playerid]) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You're not a VIP.");
  352.     if(VIP_BodyguardCount(playerid) >= BODYGUARD_LIMIT) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You can't hire any more bodyguards.");
  353.     new string[1024], name[MAX_PLAYER_NAME], count;
  354.     for(new i, p = GetPlayerPoolSize(); i <= p; i++)
  355.     {
  356.         if(!IsPlayerConnected(i)) continue;
  357.         if(!LookingForJob[i]) continue;
  358.         count++;
  359.         GetPlayerName(i, name, MAX_PLAYER_NAME);
  360.         format(string, sizeof(string), "%s%s\n", string, name);
  361.     }
  362.    
  363.     if(count > 0) {
  364.         ShowPlayerDialog(playerid, DIALOG_HIRE_BODYGUARD, DIALOG_STYLE_LIST, "Available Bodyguards", string, "Hire", "Cancel");
  365.     }else{
  366.         SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}No bodyguards available.");
  367.     }
  368.    
  369.     return 1;
  370. }
  371.  
  372. CMD:bodyguards(playerid, params[])
  373. {
  374.     if(!IsVIP[playerid]) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You're not a VIP.");
  375.     new string[256], name[MAX_PLAYER_NAME], count;
  376.     for(new i, p = GetPlayerPoolSize(); i <= p; i++)
  377.     {
  378.         if(!IsPlayerConnected(i)) continue;
  379.         if(ProtectingID[i] != playerid) continue;
  380.         count++;
  381.         GetPlayerName(i, name, MAX_PLAYER_NAME);
  382.         format(string, sizeof(string), "%s%s\n", string, name);
  383.     }
  384.  
  385.     if(count > 0) {
  386.         ShowPlayerDialog(playerid, DIALOG_FIRE_BODYGUARD, DIALOG_STYLE_LIST, "My Bodyguards", string, "Fire", "Cancel");
  387.     }else{
  388.         SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You haven't hired any bodyguards.");
  389.     }
  390.    
  391.     return 1;
  392. }
  393.  
  394. CMD:vmsg(playerid, params[])
  395. {
  396.     if(!IsVIP[playerid] && !IsPlayerConnected(ProtectingID[playerid])) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You can't use this command.");
  397.     new string[144], name[MAX_PLAYER_NAME];
  398.     GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  399.     format(string, sizeof(string), "[VIP MESSAGE] %s(%d): {FFFFFF}%s", name, playerid, params[0]);
  400.     VIP_SendMessage((IsVIP[playerid]) ? playerid : ProtectingID[playerid], string);
  401.     return 1;
  402. }
  403.  
  404. CMD:vcol(playerid, params[])
  405. {
  406.     if(!IsVIP[playerid]) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You're not a VIP.");
  407.     new color_string[3128];
  408.     for(new i; i < sizeof(LabelColors); i++) format(color_string, sizeof(color_string), "%s{%06x}%03d %s", color_string, LabelColors[i] >>> 8, i, ((i+1) % 10 == 0) ? ("\n") : (""));
  409.     ShowPlayerDialog(playerid, DIALOG_LABEL_COLOR, DIALOG_STYLE_INPUT, "Label Color", color_string, "Set", "Cancel");
  410.     return 1;
  411. }
  412.  
  413. CMD:cancelvip(playerid, params[])
  414. {
  415.     if(!IsVIP[playerid]) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You're not a VIP.");
  416.     SendClientMessage(playerid, 0x3498DBFF, "VIP: {FFFFFF}You're no longer VIP.");
  417.     VIP_CleanUp(playerid, 1);
  418.     return 1;
  419. }
  420.  
  421. // Bodyguard Commands
  422. CMD:lookforjob(playerid, params[])
  423. {
  424.     if(IsVIP[playerid]) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}VIP players can't look for a job.");
  425.     if(IsPlayerConnected(ProtectingID[playerid])) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You're already hired.");
  426.     LookingForJob[playerid] = !LookingForJob[playerid];
  427.    
  428.     if(LookingForJob[playerid]) {
  429.         SendClientMessage(playerid, 0x3498DBFF, "BODYGUARD: {FFFFFF}You're looking for a job now, wait until a VIP hires you.");
  430.     }else{
  431.         SendClientMessage(playerid, 0x3498DBFF, "BODYGUARD: {FFFFFF}You're no longer looking for a job.");
  432.     }
  433.    
  434.     return 1;
  435. }
  436.  
  437. CMD:resign(playerid, params[])
  438. {
  439.     if(IsVIP[playerid]) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}VIP players can't resign from being a bodyguard.");
  440.     if(!IsPlayerConnected(ProtectingID[playerid])) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You're not protecting any VIP.");
  441.     new string[64], name[MAX_PLAYER_NAME];
  442.     GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  443.     format(string, sizeof(string), "VIP: {FFFFFF}Bodyguard %s(%d) resigned.", name, playerid);
  444.     VIP_SendMessage(ProtectingID[playerid], string);
  445.     Bodyguard_CleanUp(playerid);
  446.     return 1;
  447. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement