Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #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
- #define Author "kaZax"
- #define Homepage "www.SAMP-RU.org"
- #define FsName "Hitman's System"
- #define invalid (-1)
- #define MAX_ORDERS 50
- #define msgcolor 0xFF7F50FF
- enum KillList
- {
- Price,
- Orderid,
- Zakazal
- };
- new struct[MAX_ORDERS][KillList];
- new bool:Hitman[MAX_PLAYERS];
- new MAX_HITMANS = 10;
- public OnFilterScriptInit()
- {
- print("» Filterscript: "FsName"");
- print("» Author: "Author"");
- print("» Homepage: "Homepage"");
- return 1;
- }
- public OnFilterScriptExit()
- {
- print(""FsName" unloaded.");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- ClearPlayerStruct(playerid);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- ClearPlayerStruct(playerid);
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- dcmd(order, 5, cmdtext);
- dcmd(maxhitmans, 10, cmdtext);
- return 0;
- }
- IsPlayerOrdered(orderid)
- {
- for (new i; i < MAX_ORDERS; i++)
- {
- if (struct[i][Orderid] == orderid)return 1;
- }
- return 0;
- }
- WriteToKillList(playerid, orderid, price)
- {
- for (new i; i < MAX_ORDERS; i++)
- {
- if (!struct[i][Price] && (struct[i][Orderid] == INVALID_PLAYER_ID) && (struct[i][Zakazal] == INVALID_PLAYER_ID))
- {
- struct[i][Price] = price;
- struct[i][Orderid] = orderid;
- struct[i][Zakazal] = playerid;
- return 1;
- }
- }
- return 0;
- }
- CheckOnlineHitmans()
- {
- for (new i; i < GetMaxPlayers(); i++)
- {
- if (IsPlayerConnected(i) && Hitman[i])return 1;
- }
- return 0;
- }
- ClearPlayerStruct(playerid)
- {
- Hitman[playerid] = false;
- }
- name(playerid)
- {
- new PlayerName[24];
- GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
- return PlayerName;
- }
- SendFormattedMessage(playerid, color, fstring[], { Float, _ }:...)
- {
- // This is the number of parameters which are not variable that are passed
- // to this function (i.e. the number of named parameters).
- static const
- STATIC_ARGS = 3,
- BYTES_PER_CELL = cellbits / 8;
- // Get the number of variable arguments.
- new
- n = (numargs() - STATIC_ARGS) * BYTES_PER_CELL;
- if (n)
- {
- new
- message[128],
- arg_start,
- arg_end;
- // Load the real address of the last static parameter. Do this by
- // loading the address of the last known static parameter and then
- // adding the value of [FRM].
- #emit CONST.alt fstring
- #emit LCTRL 5
- #emit ADD
- #emit STOR.S.pri arg_start
- // Load the address of the last variable parameter. Do this by adding
- // the number of variable parameters on the value just loaded.
- #emit LOAD.S.alt n
- #emit ADD
- #emit STOR.S.pri arg_end
- // Push the variable arguments. This is done by loading the value of
- // each one in reverse order and pushing them. I'd love to be able to
- // rewrite this to use the values of pri and alt for comparison,
- // instead of having to constantly load and reload two variables.
- do
- {
- #emit LOAD.I
- #emit PUSH.pri
- arg_end -= BYTES_PER_CELL;
- #emit LOAD.S.pri arg_end
- } while (arg_end > arg_start);
- // Push the static format parameters.
- #emit PUSH.S fstring
- #emit PUSH.C 128
- #emit PUSH.ADR message
- // Now push the number of arguments passed to format, including both
- // static and variable ones and call the function.
- n += BYTES_PER_CELL * 3;
- #emit PUSH.S n
- #emit SYSREQ.C format
- // Remove all data, including the return value, from the stack.
- n += BYTES_PER_CELL;
- #emit LCTRL 4
- #emit LOAD.S.alt n
- #emit ADD
- #emit SCTRL 4
- return SendClientMessage(playerid, color, message);
- }
- else
- {
- return SendClientMessage(playerid, color, fstring);
- }
- }
- dcmd_maxhitmans(playerid, params[])
- {
- if (!IsPlayerAdmin(playerid))return SendClientMessage(playerid, msgcolor, "Команда для ркон администраторов!");
- if (!strlen(params[0]))return SendClientMessage(playerid, msgcolor, "Используйте: /maxhitmans [количество хитманов]");
- MAX_HITMANS = params[0];
- SendFormattedMessage(playerid, msgcolor, "Мax количество хитманов изменено на: %d", MAX_HITMANS);
- return 1;
- }
- dcmd_order(playerid, params[])
- {
- if (!CheckOnlineHitmans())return SendClientMessage(playerid, msgcolor, "На сервере пока нету хитманов. (/imhitman)");
- if (!strlen(params[0]) || !strlen(params[1]))return SendClientMessage(playerid, msgcolor, "Используйте: /order [playerid] [награда]");
- if (!IsPlayerConnected(params[0]))return SendClientMessage(playerid, msgcolor, "Этот игрок не подключен!");
- if (IsPlayerOrdered(params[0]))return SendClientMessage(playerid, msgcolor, "Этот игрок уже добавлен в килл лист хитманов");
- if (GetPlayerMoney(playerid) < params[1])return SendClientMessage(playerid, msgcolor, "У вас нету таких денег!");
- if (!WriteToKillList(playerid, params[0], params[1]))return SendClientMessage(playerid, msgcolor, "Подождите пока хитманы выполнят заказ.");
- SendFormattedMessage(playerid, msgcolor, "Игрок %s[%d] был добавлен в килл лист хитманов. Ждите результатов.", name(params[0]), params[0]);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment