Guest User

Code

a guest
Mar 16th, 2014
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.54 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  4.  
  5.  
  6. #define Author      "kaZax"
  7. #define Homepage    "www.SAMP-RU.org"
  8. #define FsName      "Hitman's System"
  9.  
  10. #define invalid     (-1)
  11.  
  12. #define MAX_ORDERS  50
  13.  
  14. #define msgcolor    0xFF7F50FF
  15.  
  16. enum KillList
  17. {
  18.     Price,
  19.     Orderid,
  20.     Zakazal
  21. };
  22.  
  23. new struct[MAX_ORDERS][KillList];
  24.  
  25. new bool:Hitman[MAX_PLAYERS];
  26. new MAX_HITMANS = 10;
  27.  
  28. public OnFilterScriptInit()
  29. {
  30.     print("» Filterscript: "FsName"");
  31.     print("» Author: "Author"");
  32.     print("» Homepage: "Homepage"");
  33.     return 1;
  34. }
  35. public OnFilterScriptExit()
  36. {
  37.     print(""FsName" unloaded.");
  38.     return 1;
  39. }
  40. public OnPlayerConnect(playerid)
  41. {
  42.     ClearPlayerStruct(playerid);
  43.     return 1;
  44. }
  45. public OnPlayerDisconnect(playerid, reason)
  46. {
  47.     ClearPlayerStruct(playerid);
  48.     return 1;
  49. }
  50. public OnPlayerCommandText(playerid, cmdtext[])
  51. {
  52.     dcmd(order, 5, cmdtext);
  53.     dcmd(maxhitmans, 10, cmdtext);
  54.     return 0;
  55. }
  56.  
  57. IsPlayerOrdered(orderid)
  58. {
  59.     for (new i; i < MAX_ORDERS; i++)
  60.     {
  61.         if (struct[i][Orderid] == orderid)return 1;
  62.     }
  63.     return 0;
  64. }
  65. WriteToKillList(playerid, orderid, price)
  66. {
  67.     for (new i; i < MAX_ORDERS; i++)
  68.     {
  69.         if (!struct[i][Price] && (struct[i][Orderid] == INVALID_PLAYER_ID) && (struct[i][Zakazal] == INVALID_PLAYER_ID))
  70.         {
  71.             struct[i][Price] = price;
  72.             struct[i][Orderid] = orderid;
  73.             struct[i][Zakazal] = playerid;
  74.             return 1;
  75.         }
  76.     }
  77.     return 0;
  78. }
  79. CheckOnlineHitmans()
  80. {
  81.     for (new i; i < GetMaxPlayers(); i++)
  82.     {
  83.         if (IsPlayerConnected(i) && Hitman[i])return 1;
  84.     }
  85.     return 0;
  86. }
  87. ClearPlayerStruct(playerid)
  88. {
  89.     Hitman[playerid] = false;
  90. }
  91. name(playerid)
  92. {
  93.     new PlayerName[24];
  94.     GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
  95.     return PlayerName;
  96. }
  97. SendFormattedMessage(playerid, color, fstring[], { Float, _ }:...)
  98. {
  99.     // This is the number of parameters which are not variable that are passed
  100.     // to this function (i.e. the number of named parameters).
  101.     static const
  102.         STATIC_ARGS = 3,
  103.         BYTES_PER_CELL = cellbits / 8;
  104.     // Get the number of variable arguments.
  105.     new
  106.         n = (numargs() - STATIC_ARGS) * BYTES_PER_CELL;
  107.     if (n)
  108.     {
  109.         new
  110.             message[128],
  111.             arg_start,
  112.             arg_end;
  113.  
  114.         // Load the real address of the last static parameter.  Do this by
  115.         // loading the address of the last known static parameter and then
  116.         // adding the value of [FRM].
  117. #emit CONST.alt                fstring
  118. #emit LCTRL                    5
  119. #emit ADD
  120. #emit STOR.S.pri               arg_start
  121.  
  122.         // Load the address of the last variable parameter.  Do this by adding
  123.         // the number of variable parameters on the value just loaded.
  124. #emit LOAD.S.alt               n
  125. #emit ADD
  126. #emit STOR.S.pri               arg_end
  127.  
  128.         // Push the variable arguments.  This is done by loading the value of
  129.         // each one in reverse order and pushing them.  I'd love to be able to
  130.         // rewrite this to use the values of pri and alt for comparison,
  131.         // instead of having to constantly load and reload two variables.
  132.         do
  133.         {
  134. #emit LOAD.I
  135. #emit PUSH.pri
  136.             arg_end -= BYTES_PER_CELL;
  137. #emit LOAD.S.pri           arg_end
  138.         } while (arg_end > arg_start);
  139.  
  140.         // Push the static format parameters.
  141. #emit PUSH.S                   fstring
  142. #emit PUSH.C                   128
  143. #emit PUSH.ADR                 message
  144.  
  145.         // Now push the number of arguments passed to format, including both
  146.         // static and variable ones and call the function.
  147.         n += BYTES_PER_CELL * 3;
  148. #emit PUSH.S                   n
  149. #emit SYSREQ.C                 format
  150.  
  151.         // Remove all data, including the return value, from the stack.
  152.         n += BYTES_PER_CELL;
  153. #emit LCTRL                    4
  154. #emit LOAD.S.alt               n
  155. #emit ADD
  156. #emit SCTRL                    4
  157.  
  158.         return SendClientMessage(playerid, color, message);
  159.     }
  160.     else
  161.     {
  162.         return SendClientMessage(playerid, color, fstring);
  163.     }
  164. }
  165.  
  166. dcmd_maxhitmans(playerid, params[])
  167. {
  168.     if (!IsPlayerAdmin(playerid))return SendClientMessage(playerid, msgcolor, "Команда для ркон администраторов!");
  169.     if (!strlen(params[0]))return SendClientMessage(playerid, msgcolor, "Используйте: /maxhitmans [количество хитманов]");
  170.     MAX_HITMANS = params[0];
  171.     SendFormattedMessage(playerid, msgcolor, "Мax количество хитманов изменено на: %d", MAX_HITMANS);
  172.     return 1;
  173. }
  174. dcmd_order(playerid, params[])
  175. {
  176.     if (!CheckOnlineHitmans())return SendClientMessage(playerid, msgcolor, "На сервере пока нету хитманов. (/imhitman)");
  177.     if (!strlen(params[0]) || !strlen(params[1]))return SendClientMessage(playerid, msgcolor, "Используйте: /order [playerid] [награда]");
  178.     if (!IsPlayerConnected(params[0]))return SendClientMessage(playerid, msgcolor, "Этот игрок не подключен!");
  179.     if (IsPlayerOrdered(params[0]))return SendClientMessage(playerid, msgcolor, "Этот игрок уже добавлен в килл лист хитманов");
  180.     if (GetPlayerMoney(playerid) < params[1])return SendClientMessage(playerid, msgcolor, "У вас нету таких денег!");
  181.     if (!WriteToKillList(playerid, params[0], params[1]))return SendClientMessage(playerid, msgcolor, "Подождите пока хитманы выполнят заказ.");
  182.     SendFormattedMessage(playerid, msgcolor, "Игрок %s[%d] был добавлен в килл лист хитманов. Ждите результатов.", name(params[0]), params[0]);
  183.     return 1;
  184. }
Advertisement
Add Comment
Please, Sign In to add comment