Advertisement
Guest User

Find The Hidden Briefcase

a guest
Apr 16th, 2013
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 12.30 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////////////////////////
  2. /////////////////////// Find The Hidden Briefcase v0.2 /////////////////////////
  3. ///                             By BlackID                                   ///
  4. ///                   Project started on April 15, 2013                      ///
  5. ///                  Project finished on April 16, 2013                      ///
  6. ///                                                                          ///
  7. ///                               Credits:                                   ///
  8. ///                    BlackID - Scripting and Testing                       ///
  9. ///                             Zeex - ZCMD                                  ///
  10. ////////////////////////////////////////////////////////////////////////////////
  11.  
  12. #define FILTERSCRIPT
  13.  
  14. #include <a_samp>
  15. #include <zcmd>
  16.  
  17. #define COLOR 0xD1BB00FF
  18.  
  19. new hiddencase;
  20. new maximumprize;
  21. new hided;
  22. new hiddencasereward;
  23. new minigamestarted;
  24. new thecreator[MAX_PLAYERS];
  25. new prizetimer;
  26. new prizeCP;
  27. new CPtimer;
  28. new Float:PickupPos[3];
  29.  
  30. public OnFilterScriptInit()
  31. {
  32.     print("\n--------------------------------------");
  33.     print(" Find the hidden briefcase minigame by BlackID");
  34.     print("--------------------------------------\n");
  35.     return 1;
  36. }
  37.  
  38. public OnFilterScriptExit()
  39. {
  40.     DestroyPickup(hiddencase);
  41.     DisablePlayerCheckpoint(prizeCP);
  42.     return 1;
  43. }
  44.  
  45. public OnPlayerPickUpPickup(playerid, pickupid)
  46. {
  47.     if(pickupid == hiddencase)
  48.     {
  49.         if(minigamestarted == 1)
  50.         {
  51.             if(thecreator[playerid] == 1)
  52.             {
  53.                 SendClientMessage(playerid, COLOR, "* You are the one who hid the briefcase, use your logic, you can't take it.");
  54.                 return 1;
  55.             }
  56.             GivePlayerMoney(playerid, hiddencasereward);
  57.             new string[128];
  58.             new name[MAX_PLAYER_NAME+1];
  59.             GetPlayerName(playerid, name, sizeof(name));
  60.             format(string,sizeof(string),"* Congratulations, you have found the hidden briefcase. You get $%d as the reward.",hiddencasereward);
  61.             SendClientMessage(playerid, COLOR, string);
  62.             format(string,sizeof(string),"* %s has found the hidden briefcase. As the reward he receives $%d.",name, hiddencasereward);
  63.             SendClientMessageToAll(COLOR, string);
  64.             SendClientMessageToAll(COLOR, "* Its location has been marked as a checkpoint.");
  65.             SendClientMessageToAll(COLOR, "* The minigame is now ended.");
  66.             DestroyPickup(hiddencase);
  67.             KillTimer(prizetimer);
  68.             new Float:Pos[3];
  69.             GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  70.             for(new i=0; i<MAX_PLAYERS; i++)
  71.             {
  72.                 if(IsPlayerConnected(i))
  73.                 {
  74.                     prizeCP = SetPlayerCheckpoint(i, PickupPos[0], PickupPos[1], PickupPos[2], 3.0);
  75.                     CPtimer = SetTimer("CPPtimer", 180000, false);
  76.                 }
  77.             }
  78.             return 1;
  79.         }
  80.         else if(minigamestarted == 0)
  81.         {
  82.             SendClientMessage(playerid, COLOR, "* You found the hidden briefcase but the search has not yet been started by an admin.");
  83.             return 1;
  84.         }
  85.     }
  86.     return 1;
  87. }
  88.  
  89. forward CPPtimer();
  90. public CPPtimer()
  91. {
  92.     for(new i=0; i<MAX_PLAYERS; i++)
  93.     {
  94.         if(IsPlayerConnected(i))
  95.         {
  96.             if(thecreator[i] == 1)
  97.             {
  98.                 RemovePlayerMapIcon(i, 1);
  99.             }
  100.             DisablePlayerCheckpoint(i);
  101.             KillTimer(CPtimer);
  102.         }
  103.     }
  104.     return 1;
  105. }
  106.  
  107. forward PrizeIncrease();
  108. public PrizeIncrease()
  109. {
  110.     new string[64];
  111.     if(hiddencasereward >= 185000 && hiddencasereward < 200000)
  112.     {
  113.         hiddencasereward += (maximumprize - hiddencasereward);
  114.         format(string,sizeof(string),"* The prize has reach the maximum prize: $%d.",hiddencasereward);
  115.         SendClientMessageToAll(COLOR, string);
  116.         KillTimer(prizetimer);
  117.         return 1;
  118.     }
  119.     hiddencasereward += 15000;
  120.     format(string,sizeof(string),"* The prize has been increased to: $%d.",hiddencasereward);
  121.     SendClientMessageToAll(COLOR, string);
  122.     return 1;
  123. }
  124.  
  125. CMD:hidecase(playerid, params[])
  126. {
  127.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR, "* Only Admins can start the Find The Hidden Briefcase minigame.");
  128.     if(hided == 1) return SendClientMessage(playerid, COLOR, "* A briefcase has already been hidden.");
  129.     new Float:X, Float:X2, Float: Y2, Float:Y, Float:Z;
  130.     GetPlayerPos(playerid, X2, Y2, Z);
  131.     GetXYInFrontOfPlayer(playerid, X, Y, 2);
  132.     hiddencase = CreatePickup(1210,2,X,Y,Z,0);
  133.     PickupPos[0] = X;
  134.     PickupPos[1] = Y;
  135.     PickupPos[2] = Z;
  136.     thecreator[playerid] = 1;
  137.     hided = 1;
  138.     SetPlayerMapIcon(playerid, 1, X, Y, Z, 9, 0);
  139.     SendClientMessage(playerid, COLOR, "* You have hid the briefcase. Use /startminigame to tell players to search for it.");
  140.     return 1;
  141. }
  142.  
  143. CMD:startminigame(playerid, params[])
  144. {
  145.     new name[MAX_PLAYER_NAME+1], string[128];
  146.     GetPlayerName(playerid, name, sizeof(name));
  147.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR, "* Only Admins can start the Find The Hidden Briefcase minigame.");
  148.     if(hided == 0) return SendClientMessage(playerid, COLOR, "* The briefcase has not yet been hidden.");
  149.     if(hiddencasereward < 1) return SendClientMessage(playerid, COLOR, "* Please set a prize before you start the minigame.");
  150.     if(minigamestarted == 1) return SendClientMessage(playerid, COLOR, "* The minigame has already been started.");
  151.     format(string,sizeof(string),"* Admin %s has started the Find The Hidden Briefcase minigame. Find the briefcase and you'll get $%d as the reward.",name, hiddencasereward);
  152.     minigamestarted = 1;
  153.     prizetimer = SetTimer("PrizeIncrease", 180000, true);
  154.     SendClientMessageToAll(COLOR, string);
  155.     return 1;
  156. }
  157.  
  158. CMD:stopminigame(playerid, params[])
  159. {
  160.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR, "* Only Admins can stop the Find The Hidden briefcase minigame.");
  161.     if(minigamestarted == 0) return SendClientMessage(playerid, COLOR, "* The minigame is not started.");
  162.     minigamestarted = 0;
  163.     DestroyPickup(hiddencase);
  164.     new string[128], name[MAX_PLAYER_NAME+1];
  165.     GetPlayerName(playerid, name, sizeof(name));
  166.     format(string,sizeof(string),"* Admin %s has stopped the Find The Hidden Briefcase minigame.",name);
  167.     SendClientMessageToAll(COLOR, string);
  168.     return 1;
  169. }
  170.  
  171. CMD:setprize(playerid, params[])
  172. {
  173.     new prize;
  174.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR, "* Only Admins can start the Find The Hidden Briefcase minigame.");
  175.     if(minigamestarted == 1) return SendClientMessage(playerid, COLOR, "* The minigame has already been started.");
  176.     if(sscanf(params, "d", prize)) return SendClientMessage(playerid, COLOR, "* Please put amount for the prize.");
  177.     new string[64];
  178.     if(prize > maximumprize) return format(string,sizeof(string),"* The maximum prize is currently set to $%d",maximumprize), SendClientMessage(playerid, COLOR, "* The maximum prize is currently set to $%d");
  179.     SendClientMessage(playerid, COLOR, "* You have set a new prize for the minigame.");
  180.     hiddencasereward = prize;
  181.     return 1;
  182. }
  183.  
  184. CMD:setmaximumprize(playerid, params[])
  185. {
  186.     new prize;
  187.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR, "* Only Admins can start the Find The Hidden Briefcase minigame.");
  188.     if(minigamestarted == 1) return SendClientMessage(playerid, COLOR, "* The minigame has already been started.");
  189.     if(sscanf(params, "d", prize)) return SendClientMessage(playerid, COLOR, "* Please put amount for the prize.");
  190.     if(prize > 999999999) return SendClientMessage(playerid, COLOR, "* The maximum prize is $999,999,999.");
  191.     maximumprize = prize;
  192.     return 1;
  193. }
  194.  
  195.  
  196. GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
  197. {
  198.     new Float:a;
  199.     GetPlayerPos(playerid, x, y, a);
  200.     GetPlayerFacingAngle(playerid, a);
  201.     if (GetPlayerVehicleID(playerid))
  202.     {
  203.       GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
  204.     }
  205.     x += (distance * floatsin(-a, degrees));
  206.     y += (distance * floatcos(-a, degrees));
  207. }
  208.  
  209. stock sscanf(string[], format[], {Float,_}:...)
  210. {
  211.     #if defined isnull
  212.         if (isnull(string))
  213.     #else
  214.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  215.     #endif
  216.         {
  217.             return format[0];
  218.         }
  219.     #pragma tabsize 4
  220.     new
  221.         formatPos = 0,
  222.         stringPos = 0,
  223.         paramPos = 2,
  224.         paramCount = numargs(),
  225.         delim = ' ';
  226.     while (string[stringPos] && string[stringPos] <= ' ')
  227.     {
  228.         stringPos++;
  229.     }
  230.     while (paramPos < paramCount && string[stringPos])
  231.     {
  232.         switch (format[formatPos++])
  233.         {
  234.             case '\0':
  235.             {
  236.                 return 0;
  237.             }
  238.             case 'i', 'd':
  239.             {
  240.                 new
  241.                     neg = 1,
  242.                     num = 0,
  243.                     ch = string[stringPos];
  244.                 if (ch == '-')
  245.                 {
  246.                     neg = -1;
  247.                     ch = string[++stringPos];
  248.                 }
  249.                 do
  250.                 {
  251.                     stringPos++;
  252.                     if ('0' <= ch <= '9')
  253.                     {
  254.                         num = (num * 10) + (ch - '0');
  255.                     }
  256.                     else
  257.                     {
  258.                         return -1;
  259.                     }
  260.                 }
  261.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  262.                 setarg(paramPos, 0, num * neg);
  263.             }
  264.             case 'h', 'x':
  265.             {
  266.                 new
  267.                     num = 0,
  268.                     ch = string[stringPos];
  269.                 do
  270.                 {
  271.                     stringPos++;
  272.                     switch (ch)
  273.                     {
  274.                         case 'x', 'X':
  275.                         {
  276.                             num = 0;
  277.                             continue;
  278.                         }
  279.                         case '0' .. '9':
  280.                         {
  281.                             num = (num << 4) | (ch - '0');
  282.                         }
  283.                         case 'a' .. 'f':
  284.                         {
  285.                             num = (num << 4) | (ch - ('a' - 10));
  286.                         }
  287.                         case 'A' .. 'F':
  288.                         {
  289.                             num = (num << 4) | (ch - ('A' - 10));
  290.                         }
  291.                         default:
  292.                         {
  293.                             return -1;
  294.                         }
  295.                     }
  296.                 }
  297.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  298.                 setarg(paramPos, 0, num);
  299.             }
  300.             case 'c':
  301.             {
  302.                 setarg(paramPos, 0, string[stringPos++]);
  303.             }
  304.             case 'f':
  305.             {
  306.  
  307.                 new changestr[16], changepos = 0, strpos = stringPos;
  308.                 while(changepos < 16 && string[strpos] && string[strpos] != delim)
  309.                 {
  310.                     changestr[changepos++] = string[strpos++];
  311.                     }
  312.                 changestr[changepos] = '\0';
  313.                 setarg(paramPos,0,_:floatstr(changestr));
  314.             }
  315.             case 'p':
  316.             {
  317.                 delim = format[formatPos++];
  318.                 continue;
  319.             }
  320.             case '\'':
  321.             {
  322.                 new
  323.                     end = formatPos - 1,
  324.                     ch;
  325.                 while ((ch = format[++end]) && ch != '\'') {}
  326.                 if (!ch)
  327.                 {
  328.                     return -1;
  329.                 }
  330.                 format[end] = '\0';
  331.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  332.                 {
  333.                     if (format[end + 1])
  334.                     {
  335.                         return -1;
  336.                     }
  337.                     return 0;
  338.                 }
  339.                 format[end] = '\'';
  340.                 stringPos = ch + (end - formatPos);
  341.                 formatPos = end + 1;
  342.             }
  343.             case 'u':
  344.             {
  345.                 new
  346.                     end = stringPos - 1,
  347.                     id = 0,
  348.                     bool:num = true,
  349.                     ch;
  350.                 while ((ch = string[++end]) && ch != delim)
  351.                 {
  352.                     if (num)
  353.                     {
  354.                         if ('0' <= ch <= '9')
  355.                         {
  356.                             id = (id * 10) + (ch - '0');
  357.                         }
  358.                         else
  359.                         {
  360.                             num = false;
  361.                         }
  362.                     }
  363.                 }
  364.                 if (num && IsPlayerConnected(id))
  365.                 {
  366.                     setarg(paramPos, 0, id);
  367.                 }
  368.                 else
  369.                 {
  370.                     #if !defined foreach
  371.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  372.                         #define __SSCANF_FOREACH__
  373.                     #endif
  374.                     string[end] = '\0';
  375.                     num = false;
  376.                     new
  377.                         name[MAX_PLAYER_NAME];
  378.                     id = end - stringPos;
  379.                     foreach (Player, playerid)
  380.                     {
  381.                         GetPlayerName(playerid, name, sizeof (name));
  382.                         if (!strcmp(name, string[stringPos], true, id))
  383.                         {
  384.                             setarg(paramPos, 0, playerid);
  385.                             num = true;
  386.                             break;
  387.                         }
  388.                     }
  389.                     if (!num)
  390.                     {
  391.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  392.                     }
  393.                     string[end] = ch;
  394.                     #if defined __SSCANF_FOREACH__
  395.                         #undef foreach
  396.                         #undef __SSCANF_FOREACH__
  397.                     #endif
  398.                 }
  399.                 stringPos = end;
  400.             }
  401.             case 's', 'z':
  402.             {
  403.                 new
  404.                     i = 0,
  405.                     ch;
  406.                 if (format[formatPos])
  407.                 {
  408.                     while ((ch = string[stringPos++]) && ch != delim)
  409.                     {
  410.                         setarg(paramPos, i++, ch);
  411.                     }
  412.                     if (!i)
  413.                     {
  414.                         return -1;
  415.                     }
  416.                 }
  417.                 else
  418.                 {
  419.                     while ((ch = string[stringPos++]))
  420.                     {
  421.                         setarg(paramPos, i++, ch);
  422.                     }
  423.                 }
  424.                 stringPos--;
  425.                 setarg(paramPos, i, '\0');
  426.             }
  427.             default:
  428.             {
  429.                 continue;
  430.             }
  431.         }
  432.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  433.         {
  434.             stringPos++;
  435.         }
  436.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  437.         {
  438.             stringPos++;
  439.         }
  440.         paramPos++;
  441.     }
  442.     do
  443.     {
  444.         if ((delim = format[formatPos++]) > ' ')
  445.         {
  446.             if (delim == '\'')
  447.             {
  448.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  449.             }
  450.             else if (delim != 'z')
  451.             {
  452.                 return delim;
  453.             }
  454.         }
  455.     }
  456.     while (delim > ' ');
  457.     return 0;
  458. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement