Участник
Пользователь
- Сообщения
- 59
- Реакции
- 6
Обратите внимание, если вы хотите заключить сделку с этим пользователем, он заблокирован
- Ошибка
-
Ниже скринштот
- Компилятор
- Локальный
- Amx Mod X
- Исходный код
-
#include <amxmodx>
#include <reapi>
#pragma ctrlchar '\'
#pragma semicolon 1
#if !defined MAX_PLAYERS
#define MAX_PLAYERS 32
#endif
new const PLUGIN_NAME[] = "Knife DeathMatch: VIP Menu";
new const PLUGIN_VERSION[] = "1.0.3";
new const PLUGIN_AUTHOR[] = "Salvatore";
new const MESSAGE_PREFIX[] = "VIPMENU";
enum any: Items
{
ItemGravity,
ItemSpeed,
ItemExplosiveGrenade,
ItemMultijump,
ItemInvisiblity,
ItemMoney,
ItemHealthPoints
} new bool: gbPlayerAttachedItems[MAX_PLAYERS + 1][Items], giPlayerUsedItems[MAX_PLAYERS + 1][Items];
enum MethodType
{
MethodSteam,
MethodName,
MethodIP
};
enum Config
{
//main section
BitsAccess,
MethodType: SaveMethod,
//items_limit section
ItemsLimit[Items],
ItemsAmount[Items]
} new gConfig[Config];
new giMenuCallback;
new Trie: gpMapVector;
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
RegisterHookChain(RG_CBasePlayer_Spawn, "HC_CBasePlayer_Spawn_Post", 1);
RegisterHookChain(RG_CBasePlayer_ResetMaxSpeed, "HC_CBasePlayer_ResetMaxSpeed");
RegisterHookChain(RG_CBasePlayer_Jump, "HC_CBasePlayer_Jump_Post", 1);
giMenuCallback = menu_makecallback("VM_Callback");
register_dictionary("vipmenu.txt");
}
public client_putinserver(player)
{
arrayset(giPlayerUsedItems[player], 0, Items);
arrayset(gbPlayerAttachedItems[player], false, Items);
if (~get_user_flags(player) & gConfig[BitsAccess])
return PLUGIN_CONTINUE;
new szMethodInfo[32];
switch (gConfig[SaveMethod])
{
case MethodSteam: get_user_authid(player, szMethodInfo, charsmax(szMethodInfo));
case MethodName: get_user_name(player, szMethodInfo, charsmax(szMethodInfo));
case MethodIP: get_user_ip(player, szMethodInfo, charsmax(szMethodInfo), true);
}
TrieGetArray(gpMapVector, szMethodInfo, giPlayerUsedItems[player], Items) && TrieDeleteKey(gpMapVector, szMethodInfo);
return PLUGIN_CONTINUE;
}
public client_disconnected(player)
{
if (~get_user_flags(player) & gConfig[BitsAccess])
return PLUGIN_CONTINUE;
new szMethodInfo[32];
switch (gConfig[SaveMethod])
{
case MethodSteam: get_user_authid(player, szMethodInfo, charsmax(szMethodInfo));
case MethodName: get_user_name(player, szMethodInfo, charsmax(szMethodInfo));
case MethodIP: get_user_ip(player, szMethodInfo, charsmax(szMethodInfo), true);
}
TrieSetArray(gpMapVector, szMethodInfo, giPlayerUsedItems[player], Items);
return PLUGIN_CONTINUE;
}
public HC_CBasePlayer_Spawn_Post(const this)
{
if (is_user_alive(this))
{
new /*bool:*/ bOldMultiJumpState = gbPlayerAttachedItems[this][ItemMultijump];
arrayset(gbPlayerAttachedItems[this], 0, Items);
rg_reset_maxspeed(this);
rg_set_rendering(this);
if (bOldMultiJumpState && !gConfig[ItemsLimit][ItemMultijump])
gbPlayerAttachedItems[this][ItemMultijump] = true;
}
}
public HC_CBasePlayer_ResetMaxSpeed(const this)
{
if (gbPlayerAttachedItems[this][ItemSpeed])
{
SetHookChainReturn(ATYPE_INTEGER, 0);
return HC_SUPERCEDE;
}
return HC_CONTINUE;
}
public HC_CBasePlayer_Jump_Post(const this)
{
if (!gbPlayerAttachedItems[this][ItemMultijump])
return;
static iJumps;
if (get_entvar(this, var_flags) & FL_ONGROUND)
{
iJumps = 0;
return;
}
if (~get_entvar(this, var_flags) & FL_ONGROUND && ~get_entvar(this, var_oldbuttons) & IN_JUMP && ++iJumps < gConfig[ItemsAmount][ItemMultijump])
{
new Float: flVelocity[3];
get_entvar(this, var_velocity, flVelocity);
flVelocity[2] = random_float(250.0, 300.0);
set_entvar(this, var_velocity, flVelocity);
return;
}
}
public ClientCommand_VM(const this)
{
new iMenu = menu_create(fmt("\\w%L", this, get_user_flags(this) & gConfig[BitsAccess] ? "MENU_TITLE_ACCESS" : "MENU_TITLE_NOACCESS"), "VM_Handler");
menu_additem(iMenu, fmt("\\w%L", this, "MENU_ITEM_GRAVITY"), "1", .callback = giMenuCallback);
menu_additem(iMenu, fmt("\\w%L", this, "MENU_ITEM_SPEED"), "2", .callback = giMenuCallback);
menu_additem(iMenu, fmt("\\w%L", this, "MENU_ITEM_EXPLOSIVE"), "3", .callback = giMenuCallback);
menu_additem(iMenu, fmt("\\w%L", this, "MENU_ITEM_MULTIJUMP", gConfig[ItemsAmount][ItemMultijump]), "4", .callback = giMenuCallback);
menu_additem(iMenu, fmt("\\w%L", this, "MENU_ITEM_INVISIBLITY"), "5", .callback = giMenuCallback);
menu_additem(iMenu, fmt("\\w%L", this, "MENU_ITEM_MONEY", gConfig[ItemsAmount][ItemMoney]), "6", .callback = giMenuCallback);
menu_additem(iMenu, fmt("\\w%L", this, "MENU_ITEM_HP", gConfig[ItemsAmount][ItemHealthPoints]), "7", .callback = giMenuCallback);
menu_setprop(iMenu, MPROP_NEXTNAME, fmt("\\w%L", this, "MENU_NEXTNAME"));
menu_setprop(iMenu, MPROP_BACKNAME, fmt("\\w%L", this, "MENU_BACKNAME"));
menu_setprop(iMenu, MPROP_EXITNAME, fmt("\\w%L", this, "MENU_EXITNAME"));
menu_display(this, iMenu, 0);
return PLUGIN_HANDLED;
}
public VM_Handler(const this, const menu, const item)
{
if (item == MENU_EXIT)
return menu_destroy(menu);
giPlayerUsedItems[this][item]++;
switch (item)
{
case ItemGravity:
{
set_entvar(this, var_gravity, gConfig[ItemsAmount][ItemGravity]);
gbPlayerAttachedItems[this][item] = true;
client_print_color(this, print_team_default, "\4[%s]\1 %L", MESSAGE_PREFIX, this, "USE_ITEM_GRAVITY", gConfig[ItemsLimit][item] - giPlayerUsedItems[this][item], gConfig[ItemsLimit][item]);
}
case ItemSpeed:
{
set_entvar(this, var_maxspeed, gConfig[ItemsAmount][ItemSpeed]);
gbPlayerAttachedItems[this][item] = true;
client_print_color(this, print_team_default, "\4[%s]\1 %L", MESSAGE_PREFIX, this, "USE_ITEM_SPEED", gConfig[ItemsLimit][item] - giPlayerUsedItems[this][item], gConfig[ItemsLimit][item]);
}
case ItemExplosiveGrenade:
{
rg_has_item_by_name(this, "weapon_hegrenade") ? rg_set_user_bpammo(this, WEAPON_HEGRENADE, rg_get_user_bpammo(this, WEAPON_HEGRENADE) + 1) : rg_give_item(this, "weapon_hegrenade");
client_print_color(this, print_team_default, "\4[%s]\1 %L", MESSAGE_PREFIX, this, "USE_ITEM_EXPLOSIVE", gConfig[ItemsLimit][item] - giPlayerUsedItems[this][item], gConfig[ItemsLimit][item]);
}
case ItemMultijump:
{
gbPlayerAttachedItems[this][item] = gConfig[ItemsLimit][ItemMultijump] ? true : !gbPlayerAttachedItems[this][item];
if (gConfig[ItemsLimit][ItemMultijump])
client_print_color(this, print_team_default, "\4[%s]\1 %L", MESSAGE_PREFIX, this, "USE_ITEM_MULTIJUMP", gConfig[ItemsAmount][item], gConfig[ItemsLimit][item] - giPlayerUsedItems[this][item], gConfig[ItemsLimit][item]);
else
{
client_print_color(this, print_team_default, "\4[%s]\1 %L", MESSAGE_PREFIX, this, gbPlayerAttachedItems[this][item] ? "USE_ITEM_MULTIJUMP_ENABLED" : "USE_ITEM_MULTIJUMP_DISABLED");
ClientCommand_VM(this);
}
}
case ItemInvisiblity:
{
rg_set_rendering(this, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, gConfig[ItemsAmount][ItemInvisiblity]);
gbPlayerAttachedItems[this][item] = true;
client_print_color(this, print_team_default, "\4[%s]\1 %L", MESSAGE_PREFIX, this, "USE_ITEM_INVISIBLITY", gConfig[ItemsLimit][item] - giPlayerUsedItems[this][item], gConfig[ItemsLimit][item]);
}
case ItemMoney:
{
rg_add_account(this, gConfig[ItemsAmount][ItemMoney], AS_SET);
gbPlayerAttachedItems[this][item] = true;
client_print_color(this, print_team_default, "\4[%s]\1 %L", MESSAGE_PREFIX, this, "USE_ITEM_MONEY", gConfig[ItemsAmount][ItemMoney], gConfig[ItemsLimit][item] - giPlayerUsedItems[this][item], gConfig[ItemsLimit][item]);
}
case ItemHealthPoints:
{
set_entvar(this, var_health, float(gConfig[ItemsAmount][ItemHealthPoints]));
gbPlayerAttachedItems[this][item] = true;
client_print_color(this, print_team_default, "\4[%s]\1 %L", MESSAGE_PREFIX, this, "USE_ITEM_HP", gConfig[ItemsAmount][ItemHealthPoints], gConfig[ItemsLimit][item] - giPlayerUsedItems[this][item], gConfig[ItemsLimit][item]);
}
}
return menu_destroy(menu);
}
public VM_Callback(const this, const menu, const item)
{
new szItemName[64], iDummyInt;
menu_item_getinfo(menu, item, iDummyInt, szItemName, charsmax(szItemName), szItemName, charsmax(szItemName), iDummyInt);
if (~get_user_flags(this) & gConfig[BitsAccess])
{
remove_all_colors(szItemName, charsmax(szItemName));
menu_item_setname(menu, item, fmt("\\d%s %L", szItemName, this, "MENU_ITEM_NOACCESS"));
return ITEM_DISABLED;
}
if (!gConfig[ItemsLimit][item] && item == ItemMultijump)
{
menu_item_setname(menu, item, fmt("%s %L", szItemName, this, gbPlayerAttachedItems[this][ItemMultijump] ? "MENU_ITEM_STATE_DISABLE" : "MENU_ITEM_STATE_ENABLE"));
return ITEM_IGNORE;
}
if (gConfig[ItemsLimit][item] && giPlayerUsedItems[this][item])
{
new iItemState = giPlayerUsedItems[this][item] >= gConfig[ItemsLimit][item] ? ITEM_DISABLED : ITEM_IGNORE;
iItemState && remove_all_colors(szItemName, charsmax(szItemName));
menu_item_setname(menu, item, fmt("%s %L", szItemName, this, iItemState ? "MENU_ITEMS_LEFT_DISABLED" : "MENU_ITEMS_LEFT", giPlayerUsedItems[this][item], gConfig[ItemsLimit][item]));
return iItemState;
}
return ITEM_IGNORE;
}
public plugin_cfg()
{
new szFile[PLATFORM_MAX_PATH];
get_localinfo("amxx_configsdir", szFile, charsmax(szFile));
add(szFile, charsmax(szFile), "/vm_settings.ini");
new INIParser: pHandle = INI_CreateParser();
INI_SetReaders(pHandle, "ParserRead_KeyValue");
!INI_ParseFile(pHandle, szFile) && set_fail_state("Config %s not found", szFile);
gpMapVector = TrieCreate();
}
const TOKEN_NOTFOUND = -1;
public ParserRead_KeyValue(INIParser:handle, const key[], const value[], bool:invalid_tokens, bool:equal_token, bool:quotes, curtok, any:data)
{
if (equal(key, "access"))
gConfig[BitsAccess] = read_flags(value);
else if (equal(key, "save_method"))
gConfig[SaveMethod] = MethodType: str_to_num(value);
else if (equal(key, "cmd_open"))
{
new szBuffer[256], szCmd[32];
copy(szBuffer, charsmax(szBuffer), value);
while (strtok2(szBuffer, szCmd, charsmax(szCmd), szBuffer, charsmax(szBuffer), ',', true) != TOKEN_NOTFOUND)
{
register_clcmd(szCmd, "ClientCommand_VM");
szBuffer[0] != EOS && register_clcmd(szBuffer, "ClientCommand_VM");
}
}
else if (contain(key, "maxcount") != TOKEN_NOTFOUND)
{
switch (key[0])
{
case 'g': gConfig[ItemsLimit][ItemGravity] = str_to_num(value);
case 's': gConfig[ItemsLimit][ItemSpeed] = str_to_num(value);
case 'e': gConfig[ItemsLimit][ItemExplosiveGrenade] = str_to_num(value);
case 'j': gConfig[ItemsLimit][ItemMultijump] = str_to_num(value);
case 'i': gConfig[ItemsLimit][ItemInvisiblity] = str_to_num(value);
case 'm': gConfig[ItemsLimit][ItemMoney] = str_to_num(value);
case 'h': gConfig[ItemsLimit][ItemHealthPoints] = str_to_num(value);
}
}
else if (contain(key, "amount") != TOKEN_NOTFOUND)
{
switch (key[0])
{
case 'g': gConfig[ItemsAmount][ItemGravity] = any: str_to_float(value);
case 's': gConfig[ItemsAmount][ItemSpeed] = any: str_to_float(value);
case 'j': gConfig[ItemsAmount][ItemMultijump] = str_to_num(value);
case 'i': gConfig[ItemsAmount][ItemInvisiblity] = str_to_num(value);
case 'm': gConfig[ItemsAmount][ItemMoney] = str_to_num(value);
case 'h': gConfig[ItemsAmount][ItemHealthPoints] = str_to_num(value);
}
}
return true;
}
stock remove_all_colors(buffer[], const len)
{
replace_all(buffer, len, "\\r", NULL_STRING);
replace_all(buffer, len, "\\y", NULL_STRING);
replace_all(buffer, len, "\\d", NULL_STRING);
replace_all(buffer, len, "\\w", NULL_STRING);
}
stock rg_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
{
new Float:renderColor[3];
renderColor[0] = float(r);
renderColor[1] = float(g);
renderColor[2] = float(b);
set_entvar(entity, var_renderfx, fx);
set_entvar(entity, var_rendercolor, renderColor);
set_entvar(entity, var_rendermode, render);
set_entvar(entity, var_renderamt, float(amount));
}
Не компилируется плагин https://dev-cs.ru/resources/452/
Может чего не хватает ?
Может чего не хватает ?
В этой теме было размещено решение! Перейти к решению.
Вложения
-
64.1 KB Просмотры: 486
Последнее редактирование: