alexey_gamov
Участник
- Сообщения
- 21
- Реакции
- 4
cs:go, а не подскажите реализовывал кто подобное уже?какая игра ? можно через расширение dhooks.
cs:go, а не подскажите реализовывал кто подобное уже?какая игра ? можно через расширение dhooks.
На выделенной строке 32 уже надо сделать проверку на определенного игрока.cs:go, а не подскажите реализовывал кто подобное уже?
#include <sourcemod>
#include <sdktools>
#include <dhooks>
#pragma newdecls required
Handle hCanPlayerBuy;
public void OnPluginStart()
{
Handle conf = LoadGameConfigFile("canplayerbuy");
if (conf == INVALID_HANDLE)
SetFailState("Failed to load gamedata canplayerbuy");
hCanPlayerBuy = DHookCreateDetour(Address_Null, CallConv_THISCALL, ReturnType_Bool, ThisPointer_CBaseEntity);
if (!hCanPlayerBuy)
SetFailState("Failed to setup detour for CCSPlayer::CanPlayerBuy");
if (!DHookSetFromConf(hCanPlayerBuy, conf, SDKConf_Signature, "CCSPlayer::CanPlayerBuy"))
SetFailState("Failed to load CCSPlayer::CanPlayerBuy signature from gamedata");
if (!DHookEnableDetour(hCanPlayerBuy, false, CanPlayerBuy))
SetFailState("Failed to detour CCSPlayer::CanPlayerBuy");
delete conf;
}
public MRESReturn CanPlayerBuy(int client, Handle hReturn)
{
if(client && IsClientInGame(client) && IsPlayerAlive(client) && GetEntProp(client, Prop_Send, "m_bInBuyZone") == 1)
{
if(bSpecial[client])
{
DHookSetReturn(hReturn, 1);
return MRES_Supercede;
}
}
return MRES_Ignored;
}
config.Rewind();
config.JumpToKey("headshots");
IntToString(g_iHeadStreak[iAttacker], sKill, sizeof(sKill));
if(config.JumpToKey(sKill))
{
char sText[512];
config.GetString("text", sText, sizeof(sText));
Format(sText, sizeof(sText), "%s", sText, iAttacker);
PrintToChatAll(sText);
}
"headshots"
{
"2"
{
"duration" "3"
"text" "%N снес две башки подряд!"
}
"4"
{
"duration" "3"
"text" "%N прострелил уже четыре лица!"
}
}
config.Rewind();
config.JumpToKey("headshots");
IntToString(g_iHeadStreak[iAttacker], sKill, sizeof(sKill));
if(config.JumpToKey(sKill))
{
char sText[512], sName[MAX_NAME_LENGTH];
config.GetString("text", sText, sizeof(sText));
GetClientName(iAttacker, sName, sizeof(sName));
ReplaceString(sText, sizeof(sText), "{NAME}", sName);
//Format(sText, sizeof(sText), "%s", sText, iAttacker);
PrintToChatAll(sText);
}
Здравствуйте
Подскажите, как передать аргумент при получении строки из kv?
C-подобный:config.Rewind(); config.JumpToKey("headshots"); IntToString(g_iHeadStreak[iAttacker], sKill, sizeof(sKill)); if(config.JumpToKey(sKill)) { char sText[512]; config.GetString("text", sText, sizeof(sText)); Format(sText, sizeof(sText), "%s", sText, iAttacker); PrintToChatAll(sText); }
Конфиг::"headshots" { "2" { "duration" "3" "text" "%N снес две башки подряд!" } "4" { "duration" "3" "text" "%N прострелил уже четыре лица!" } }
На выходе получаю строку, в точности совпадающую со строкой в kv (%N вместо ника игрока)
так это не тот хочу именно такой@txxbio, тебе же уже дали ссылку в другой теме:
Поиск плагинов
Я прекрасно понимаю, что часто названия плагинов можно очень просто забыть. Однако это становится причиной постоянного создания тем рода "помогите найти плагин X". Так вот, чтобы содержать форум в порядке и чистоте, поступим следующим образом: В дальнейшем создаваемые темы с "помогите найти...hlmod.ru
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <shop>
#include <colors>
#define PLUGIN_VERSION "2.1.2"
new ItemId:id;
#define TEHNIC_SOUND "weapons/armor1.wav"
#define CATEGORY "stuff"
#define ARMOKIT "armokit"
#define ADD 0
#define SET 1
new Handle:g_hArmor, g_iArmor,
Handle:g_hMaxArmor, g_iMaxArmor,
Handle:g_hRoundUse, g_iRoundUse,
Handle:g_hPrice, g_iPrice;
new Handle:g_hSellPrice, g_iSellPrice;
new g_iArmokitMode = SET;
new iRoundUsed[MAXPLAYERS+1];
public Plugin:myinfo =
{
name = "[Shop] Armokit",
author = "FrozDark (HLModders LLC)",
description = "Armokit component for Shop",
version = PLUGIN_VERSION,
url = "http://www.hlmod.ru/"
};
public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
{
MarkNativeAsOptional("GetUserMessageType");
}
public OnPluginStart()
{
g_hArmor = CreateConVar("sm_shop_armokit_armor", "10", "Armokit armor. Raw numbers just set armor to that value and + adds");
g_iArmor = GetConVarInt(g_hArmor);
HookConVarChange(g_hArmor, OnConVarChange);
g_hMaxArmor = CreateConVar("sm_shop_armokit_max_armor", "+25", "Max amount of armor a player can hold", 0, true, 0.0);
g_iMaxArmor = GetConVarInt(g_hMaxArmor);
HookConVarChange(g_hMaxArmor, OnConVarChange);
g_hRoundUse = CreateConVar("sm_shop_armokit_per_round", "1", "How many armokits available per round.");
g_iRoundUse = GetConVarInt(g_hRoundUse);
HookConVarChange(g_hRoundUse, OnConVarChange);
g_hPrice = CreateConVar("sm_shop_armokit_price", "265", "The price of the armokit.");
g_iPrice = GetConVarInt(g_hPrice);
HookConVarChange(g_hPrice, OnConVarChange);
g_hSellPrice = CreateConVar("sm_shop_armokit_sellprice", "5", "Sell price for the armokit. -1 to make unsaleable");
g_iSellPrice = GetConVarInt(g_hSellPrice);
HookConVarChange(g_hSellPrice, OnConVarChange);
AutoExecConfig(true, "shop_armokit", "shop");
RegConsoleCmd("sm_armor", Command_Tehnic);
RegConsoleCmd("sm_armokit", Command_Tehnic);
LoadTranslations("shop_armokit.phrases.txt");
HookEvent("round_start", OnRoundStart, EventHookMode_PostNoCopy);
if (Shop_IsStarted()) Shop_Started();
}
public OnConVarChange(Handle:convar, const String:oldValue[], const String:newValue[])
{
if (convar == g_hArmor)
{
g_iArmor = StringToInt(newValue);
if (newValue[0] == '+')
{
g_iArmokitMode = ADD;
}
else
{
g_iArmokitMode = SET;
}
}
else if (convar == g_hMaxArmor)
{
g_iMaxArmor = StringToInt(newValue);
}
else if (convar == g_hRoundUse)
{
g_iRoundUse = StringToInt(newValue);
}
else if (convar == g_hPrice)
{
g_iPrice = StringToInt(newValue);
if (id != INVALID_ITEM)
{
Shop_SetItemPrice(id, g_iPrice);
}
}
else if (convar == g_hSellPrice)
{
g_iSellPrice = StringToInt(newValue);
if (id != INVALID_ITEM)
{
Shop_SetItemSellPrice(id, g_iSellPrice);
}
}
}
public OnRoundStart(Handle:event, const String:name[], bool:donBroadcast)
{
for (new i = 1; i <= MaxClients; i++)
{
iRoundUsed[i] = 0;
}
}
public Action:Command_Tehnic(client, args)
{
if (!client)
{
return Plugin_Continue;
}
if (!Shop_UseClientItem(client, id))
{
CPrintToChat(client, "%t", "NoArmokit");
}
return Plugin_Handled;
}
public OnMapStart()
{
PrecacheSound(TEHNIC_SOUND, true);
}
public OnPluginEnd()
{
Shop_UnregisterMe();
}
public Shop_Started()
{
new CategoryId:category_id = Shop_RegisterCategory(CATEGORY, "Stuff", "", OnCategoryDisplay, OnCategoryDescription);
if (Shop_StartItem(category_id, ARMOKIT))
{
Shop_SetInfo("Armokit", "", g_iPrice, g_iSellPrice, Item_Finite);
Shop_SetCallbacks(OnItemRegistered, OnArmokitChoose, _, OnDisplay, OnDescription, _, _);
Shop_EndItem();
}
}
public OnItemRegistered(CategoryId:category_id, const String:category[], const String:item[], ItemId:item_id)
{
id = item_id;
}
public bool:OnCategoryDisplay(client, CategoryId:category_id, const String:category[], const String:name[], String:buffer[], maxlen)
{
FormatEx(buffer, maxlen, "%T", "display", client);
return true;
}
public bool:OnCategoryDescription(client, CategoryId:category_id, const String:category[], const String:description[], String:buffer[], maxlen)
{
FormatEx(buffer, maxlen, "%T", "description", client);
return true;
}
public bool:OnDisplay(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], ShopMenu:menu, &bool:disabled, const String:name[], String:buffer[], maxlen)
{
FormatEx(buffer, maxlen, "%T", "armokit", client);
return true;
}
public bool:OnDescription(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], ShopMenu:menu, const String:description[], String:buffer[], maxlen)
{
FormatEx(buffer, maxlen, "%T", "armokit_description", client);
return true;
}
public ShopAction:OnArmokitChoose(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[])
{
if (g_iRoundUse > 0 && iRoundUsed[client] >= g_iRoundUse)
{
CPrintToChat(client, "%t", "RoundUsed", g_iRoundUse);
return Shop_Raw;
}
if (IsPlayerAlive(client))
{
new armor = GetClientArmor(client);
if (armor < g_iMaxArmor)
{
if (g_iArmokitMode == ADD)
{
armor += g_iArmor;
}
else
{
armor = g_iArmor;
}
if (armor > g_iMaxArmor)
{
armor = g_iMaxArmor;
}
//SetEntityArmor(client, armor); //не работает
GivePlayerItem(client, "item_assaultsuit"); //Работает , но пополняет броню до фулла, а надо с конфига "sm_shop_armokit_max_armor", "+25"
CPrintToChat(client, "%t", "UsedArmokit");
EmitSoundToAll(TEHNIC_SOUND, client);
iRoundUsed[client]++;
return Shop_UseOn;
}
else
{
CPrintToChat(client, "%t", "EnoughArmor");
}
}
else
{
CPrintToChat(client, "%t", "MustAlive");
}
return Shop_Raw;
}
Через SetEntProp выставляй нужное значение по m_ArmorValueДоброго времени суток, решил задублировать модуль к shop medkit но для брони , - в итоге не могу сделать пополнение плюсом, на данный момент при команде !armor восстанавливает до фулла, а надо что бы добавлял к броне +N количество.
P.S в скриптинге не силен, кому не сложно - подсобите пожалуйста
shop_armorkit.sp:#pragma semicolon 1 #include <sourcemod> #include <sdktools> #include <shop> #include <colors> #define PLUGIN_VERSION "2.1.2" new ItemId:id; #define TEHNIC_SOUND "weapons/armor1.wav" #define CATEGORY "stuff" #define ARMOKIT "armokit" #define ADD 0 #define SET 1 new Handle:g_hArmor, g_iArmor, Handle:g_hMaxArmor, g_iMaxArmor, Handle:g_hRoundUse, g_iRoundUse, Handle:g_hPrice, g_iPrice; new Handle:g_hSellPrice, g_iSellPrice; new g_iArmokitMode = SET; new iRoundUsed[MAXPLAYERS+1]; public Plugin:myinfo = { name = "[Shop] Armokit", author = "FrozDark (HLModders LLC)", description = "Armokit component for Shop", version = PLUGIN_VERSION, url = "http://www.hlmod.ru/" }; public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max) { MarkNativeAsOptional("GetUserMessageType"); } public OnPluginStart() { g_hArmor = CreateConVar("sm_shop_armokit_armor", "10", "Armokit armor. Raw numbers just set armor to that value and + adds"); g_iArmor = GetConVarInt(g_hArmor); HookConVarChange(g_hArmor, OnConVarChange); g_hMaxArmor = CreateConVar("sm_shop_armokit_max_armor", "+25", "Max amount of armor a player can hold", 0, true, 0.0); g_iMaxArmor = GetConVarInt(g_hMaxArmor); HookConVarChange(g_hMaxArmor, OnConVarChange); g_hRoundUse = CreateConVar("sm_shop_armokit_per_round", "1", "How many armokits available per round."); g_iRoundUse = GetConVarInt(g_hRoundUse); HookConVarChange(g_hRoundUse, OnConVarChange); g_hPrice = CreateConVar("sm_shop_armokit_price", "265", "The price of the armokit."); g_iPrice = GetConVarInt(g_hPrice); HookConVarChange(g_hPrice, OnConVarChange); g_hSellPrice = CreateConVar("sm_shop_armokit_sellprice", "5", "Sell price for the armokit. -1 to make unsaleable"); g_iSellPrice = GetConVarInt(g_hSellPrice); HookConVarChange(g_hSellPrice, OnConVarChange); AutoExecConfig(true, "shop_armokit", "shop"); RegConsoleCmd("sm_armor", Command_Tehnic); RegConsoleCmd("sm_armokit", Command_Tehnic); LoadTranslations("shop_armokit.phrases.txt"); HookEvent("round_start", OnRoundStart, EventHookMode_PostNoCopy); if (Shop_IsStarted()) Shop_Started(); } public OnConVarChange(Handle:convar, const String:oldValue[], const String:newValue[]) { if (convar == g_hArmor) { g_iArmor = StringToInt(newValue); if (newValue[0] == '+') { g_iArmokitMode = ADD; } else { g_iArmokitMode = SET; } } else if (convar == g_hMaxArmor) { g_iMaxArmor = StringToInt(newValue); } else if (convar == g_hRoundUse) { g_iRoundUse = StringToInt(newValue); } else if (convar == g_hPrice) { g_iPrice = StringToInt(newValue); if (id != INVALID_ITEM) { Shop_SetItemPrice(id, g_iPrice); } } else if (convar == g_hSellPrice) { g_iSellPrice = StringToInt(newValue); if (id != INVALID_ITEM) { Shop_SetItemSellPrice(id, g_iSellPrice); } } } public OnRoundStart(Handle:event, const String:name[], bool:donBroadcast) { for (new i = 1; i <= MaxClients; i++) { iRoundUsed[i] = 0; } } public Action:Command_Tehnic(client, args) { if (!client) { return Plugin_Continue; } if (!Shop_UseClientItem(client, id)) { CPrintToChat(client, "%t", "NoArmokit"); } return Plugin_Handled; } public OnMapStart() { PrecacheSound(TEHNIC_SOUND, true); } public OnPluginEnd() { Shop_UnregisterMe(); } public Shop_Started() { new CategoryId:category_id = Shop_RegisterCategory(CATEGORY, "Stuff", "", OnCategoryDisplay, OnCategoryDescription); if (Shop_StartItem(category_id, ARMOKIT)) { Shop_SetInfo("Armokit", "", g_iPrice, g_iSellPrice, Item_Finite); Shop_SetCallbacks(OnItemRegistered, OnArmokitChoose, _, OnDisplay, OnDescription, _, _); Shop_EndItem(); } } public OnItemRegistered(CategoryId:category_id, const String:category[], const String:item[], ItemId:item_id) { id = item_id; } public bool:OnCategoryDisplay(client, CategoryId:category_id, const String:category[], const String:name[], String:buffer[], maxlen) { FormatEx(buffer, maxlen, "%T", "display", client); return true; } public bool:OnCategoryDescription(client, CategoryId:category_id, const String:category[], const String:description[], String:buffer[], maxlen) { FormatEx(buffer, maxlen, "%T", "description", client); return true; } public bool:OnDisplay(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], ShopMenu:menu, &bool:disabled, const String:name[], String:buffer[], maxlen) { FormatEx(buffer, maxlen, "%T", "armokit", client); return true; } public bool:OnDescription(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], ShopMenu:menu, const String:description[], String:buffer[], maxlen) { FormatEx(buffer, maxlen, "%T", "armokit_description", client); return true; } public ShopAction:OnArmokitChoose(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[]) { if (g_iRoundUse > 0 && iRoundUsed[client] >= g_iRoundUse) { CPrintToChat(client, "%t", "RoundUsed", g_iRoundUse); return Shop_Raw; } if (IsPlayerAlive(client)) { new armor = GetClientArmor(client); if (armor < g_iMaxArmor) { if (g_iArmokitMode == ADD) { armor += g_iArmor; } else { armor = g_iArmor; } if (armor > g_iMaxArmor) { armor = g_iMaxArmor; } //SetEntityArmor(client, armor); //не работает GivePlayerItem(client, "item_assaultsuit"); //Работает , но пополняет броню до фулла, а надо с конфига "sm_shop_armokit_max_armor", "+25" CPrintToChat(client, "%t", "UsedArmokit"); EmitSoundToAll(TEHNIC_SOUND, client); iRoundUsed[client]++; return Shop_UseOn; } else { CPrintToChat(client, "%t", "EnoughArmor"); } } else { CPrintToChat(client, "%t", "MustAlive"); } return Shop_Raw; }
int currHp = GetEntProp(client, Prop_Send, "m_ArmorValue");
SetEntProp(client,Prop_Send, "m_ArmorValue", currHp+10)
К сожалению я не дорос еще до этого уровня)), могу максимум задублировать с аналога с изменёнными переменными + заменой cmd и идом (если это модуль к кору)Через SetEntProp выставляй нужное значение по m_ArmorValue
C++:int currHp = GetEntProp(client, Prop_Send, "m_ArmorValue"); SetEntProp(client,Prop_Send, "m_ArmorValue", currHp+10)
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <shop>
#include <colors>
#define PLUGIN_VERSION "2.1.2"
new ItemId:id;
#define TEHNIC_SOUND "weapons/armor1.wav"
#define CATEGORY "stuff"
#define ARMOKIT "armokit"
#define ADD 0
#define SET 1
new Handle:g_hArmor, g_iArmor,
Handle:g_hMaxArmor, g_iMaxArmor,
Handle:g_hRoundUse, g_iRoundUse,
Handle:g_hPrice, g_iPrice;
new Handle:g_hSellPrice, g_iSellPrice;
new g_iArmokitMode = SET;
new iRoundUsed[MAXPLAYERS+1];
public Plugin:myinfo =
{
name = "[Shop] Armokit",
author = "FrozDark (HLModders LLC)",
description = "Armokit component for Shop",
version = PLUGIN_VERSION,
url = "http://www.hlmod.ru/"
};
public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
{
MarkNativeAsOptional("GetUserMessageType");
}
public OnPluginStart()
{
g_hArmor = CreateConVar("sm_shop_armokit_armor", "10", "Armokit armor. Raw numbers just set armor to that value and + adds");
g_iArmor = GetConVarInt(g_hArmor);
HookConVarChange(g_hArmor, OnConVarChange);
g_hMaxArmor = CreateConVar("sm_shop_armokit_max_armor", "+25", "Max amount of armor a player can hold", 0, true, 0.0);
g_iMaxArmor = GetConVarInt(g_hMaxArmor);
HookConVarChange(g_hMaxArmor, OnConVarChange);
g_hRoundUse = CreateConVar("sm_shop_armokit_per_round", "1", "How many armokits available per round.");
g_iRoundUse = GetConVarInt(g_hRoundUse);
HookConVarChange(g_hRoundUse, OnConVarChange);
g_hPrice = CreateConVar("sm_shop_armokit_price", "265", "The price of the armokit.");
g_iPrice = GetConVarInt(g_hPrice);
HookConVarChange(g_hPrice, OnConVarChange);
g_hSellPrice = CreateConVar("sm_shop_armokit_sellprice", "5", "Sell price for the armokit. -1 to make unsaleable");
g_iSellPrice = GetConVarInt(g_hSellPrice);
HookConVarChange(g_hSellPrice, OnConVarChange);
AutoExecConfig(true, "shop_armokit", "shop");
RegConsoleCmd("sm_armor", Command_Tehnic);
RegConsoleCmd("sm_armokit", Command_Tehnic);
LoadTranslations("shop_armokit.phrases.txt");
HookEvent("round_start", OnRoundStart, EventHookMode_PostNoCopy);
if (Shop_IsStarted()) Shop_Started();
}
public OnConVarChange(Handle:convar, const String:oldValue[], const String:newValue[])
{
if (convar == g_hArmor)
{
g_iArmor = StringToInt(newValue);
if (newValue[0] == '+')
{
g_iArmokitMode = ADD;
}
else
{
g_iArmokitMode = SET;
}
}
else if (convar == g_hMaxArmor)
{
g_iMaxArmor = StringToInt(newValue);
}
else if (convar == g_hRoundUse)
{
g_iRoundUse = StringToInt(newValue);
}
else if (convar == g_hPrice)
{
g_iPrice = StringToInt(newValue);
if (id != INVALID_ITEM)
{
Shop_SetItemPrice(id, g_iPrice);
}
}
else if (convar == g_hSellPrice)
{
g_iSellPrice = StringToInt(newValue);
if (id != INVALID_ITEM)
{
Shop_SetItemSellPrice(id, g_iSellPrice);
}
}
}
public OnRoundStart(Handle:event, const String:name[], bool:donBroadcast)
{
for (new i = 1; i <= MaxClients; i++)
{
iRoundUsed[i] = 0;
}
}
public Action:Command_Tehnic(client, args)
{
if (!client)
{
return Plugin_Continue;
}
if (!Shop_UseClientItem(client, id))
{
CPrintToChat(client, "%t", "NoArmokit");
}
return Plugin_Handled;
}
public OnMapStart()
{
PrecacheSound(TEHNIC_SOUND, true);
}
public OnPluginEnd()
{
Shop_UnregisterMe();
}
public Shop_Started()
{
new CategoryId:category_id = Shop_RegisterCategory(CATEGORY, "Stuff", "", OnCategoryDisplay, OnCategoryDescription);
if (Shop_StartItem(category_id, ARMOKIT))
{
Shop_SetInfo("Armokit", "", g_iPrice, g_iSellPrice, Item_Finite);
Shop_SetCallbacks(OnItemRegistered, OnArmokitChoose, _, OnDisplay, OnDescription, _, _);
Shop_EndItem();
}
}
public OnItemRegistered(CategoryId:category_id, const String:category[], const String:item[], ItemId:item_id)
{
id = item_id;
}
public bool:OnCategoryDisplay(client, CategoryId:category_id, const String:category[], const String:name[], String:buffer[], maxlen)
{
FormatEx(buffer, maxlen, "%T", "display", client);
return true;
}
public bool:OnCategoryDescription(client, CategoryId:category_id, const String:category[], const String:description[], String:buffer[], maxlen)
{
FormatEx(buffer, maxlen, "%T", "description", client);
return true;
}
public bool:OnDisplay(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], ShopMenu:menu, &bool:disabled, const String:name[], String:buffer[], maxlen)
{
FormatEx(buffer, maxlen, "%T", "armokit", client);
return true;
}
public bool:OnDescription(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], ShopMenu:menu, const String:description[], String:buffer[], maxlen)
{
FormatEx(buffer, maxlen, "%T", "armokit_description", client);
return true;
}
public ShopAction:OnArmokitChoose(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[])
{
if (g_iRoundUse > 0 && iRoundUsed[client] >= g_iRoundUse)
{
CPrintToChat(client, "%t", "RoundUsed", g_iRoundUse);
return Shop_Raw;
}
if (IsPlayerAlive(client))
{
new armor = GetClientArmor(client);
if (armor < g_iMaxArmor)
{
if (g_iArmokitMode == ADD)
{
armor += g_iArmor;
}
else
{
armor = g_iArmor;
}
if (armor > g_iMaxArmor)
{
armor = g_iMaxArmor;
}
//SetEntityArmor(client, armor); //не работает
SetEntProp(client,Prop_Send, "m_ArmorValue", armor+g_iMaxArmor); //Работает , но пополняет броню до фулла, а надо с конфига "sm_shop_armokit_max_armor", "+25"
CPrintToChat(client, "%t", "UsedArmokit");
EmitSoundToAll(TEHNIC_SOUND, client);
iRoundUsed[client]++;
return Shop_UseOn;
}
else
{
CPrintToChat(client, "%t", "EnoughArmor");
}
}
else
{
CPrintToChat(client, "%t", "MustAlive");
}
return Shop_Raw;
}
В вашем случае происходит суммирование лимита и выдача брони - это число заменяет количество единиц брони клиенту а не добавляет, я убрал g_iMaxArmor - в итоге плуг не суммирует более а просто устанавливает число (хотя идея в приплюсовывании к остаткам единиц брони у клиента) - но все же это лучше чем у меня было до этогоНу попробуй:#pragma semicolon 1 #include <sourcemod> #include <sdktools> #include <shop> #include <colors> #define PLUGIN_VERSION "2.1.2" new ItemId:id; #define TEHNIC_SOUND "weapons/armor1.wav" #define CATEGORY "stuff" #define ARMOKIT "armokit" #define ADD 0 #define SET 1 new Handle:g_hArmor, g_iArmor, Handle:g_hMaxArmor, g_iMaxArmor, Handle:g_hRoundUse, g_iRoundUse, Handle:g_hPrice, g_iPrice; new Handle:g_hSellPrice, g_iSellPrice; new g_iArmokitMode = SET; new iRoundUsed[MAXPLAYERS+1]; public Plugin:myinfo = { name = "[Shop] Armokit", author = "FrozDark (HLModders LLC)", description = "Armokit component for Shop", version = PLUGIN_VERSION, url = "http://www.hlmod.ru/" }; public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max) { MarkNativeAsOptional("GetUserMessageType"); } public OnPluginStart() { g_hArmor = CreateConVar("sm_shop_armokit_armor", "10", "Armokit armor. Raw numbers just set armor to that value and + adds"); g_iArmor = GetConVarInt(g_hArmor); HookConVarChange(g_hArmor, OnConVarChange); g_hMaxArmor = CreateConVar("sm_shop_armokit_max_armor", "+25", "Max amount of armor a player can hold", 0, true, 0.0); g_iMaxArmor = GetConVarInt(g_hMaxArmor); HookConVarChange(g_hMaxArmor, OnConVarChange); g_hRoundUse = CreateConVar("sm_shop_armokit_per_round", "1", "How many armokits available per round."); g_iRoundUse = GetConVarInt(g_hRoundUse); HookConVarChange(g_hRoundUse, OnConVarChange); g_hPrice = CreateConVar("sm_shop_armokit_price", "265", "The price of the armokit."); g_iPrice = GetConVarInt(g_hPrice); HookConVarChange(g_hPrice, OnConVarChange); g_hSellPrice = CreateConVar("sm_shop_armokit_sellprice", "5", "Sell price for the armokit. -1 to make unsaleable"); g_iSellPrice = GetConVarInt(g_hSellPrice); HookConVarChange(g_hSellPrice, OnConVarChange); AutoExecConfig(true, "shop_armokit", "shop"); RegConsoleCmd("sm_armor", Command_Tehnic); RegConsoleCmd("sm_armokit", Command_Tehnic); LoadTranslations("shop_armokit.phrases.txt"); HookEvent("round_start", OnRoundStart, EventHookMode_PostNoCopy); if (Shop_IsStarted()) Shop_Started(); } public OnConVarChange(Handle:convar, const String:oldValue[], const String:newValue[]) { if (convar == g_hArmor) { g_iArmor = StringToInt(newValue); if (newValue[0] == '+') { g_iArmokitMode = ADD; } else { g_iArmokitMode = SET; } } else if (convar == g_hMaxArmor) { g_iMaxArmor = StringToInt(newValue); } else if (convar == g_hRoundUse) { g_iRoundUse = StringToInt(newValue); } else if (convar == g_hPrice) { g_iPrice = StringToInt(newValue); if (id != INVALID_ITEM) { Shop_SetItemPrice(id, g_iPrice); } } else if (convar == g_hSellPrice) { g_iSellPrice = StringToInt(newValue); if (id != INVALID_ITEM) { Shop_SetItemSellPrice(id, g_iSellPrice); } } } public OnRoundStart(Handle:event, const String:name[], bool:donBroadcast) { for (new i = 1; i <= MaxClients; i++) { iRoundUsed[i] = 0; } } public Action:Command_Tehnic(client, args) { if (!client) { return Plugin_Continue; } if (!Shop_UseClientItem(client, id)) { CPrintToChat(client, "%t", "NoArmokit"); } return Plugin_Handled; } public OnMapStart() { PrecacheSound(TEHNIC_SOUND, true); } public OnPluginEnd() { Shop_UnregisterMe(); } public Shop_Started() { new CategoryId:category_id = Shop_RegisterCategory(CATEGORY, "Stuff", "", OnCategoryDisplay, OnCategoryDescription); if (Shop_StartItem(category_id, ARMOKIT)) { Shop_SetInfo("Armokit", "", g_iPrice, g_iSellPrice, Item_Finite); Shop_SetCallbacks(OnItemRegistered, OnArmokitChoose, _, OnDisplay, OnDescription, _, _); Shop_EndItem(); } } public OnItemRegistered(CategoryId:category_id, const String:category[], const String:item[], ItemId:item_id) { id = item_id; } public bool:OnCategoryDisplay(client, CategoryId:category_id, const String:category[], const String:name[], String:buffer[], maxlen) { FormatEx(buffer, maxlen, "%T", "display", client); return true; } public bool:OnCategoryDescription(client, CategoryId:category_id, const String:category[], const String:description[], String:buffer[], maxlen) { FormatEx(buffer, maxlen, "%T", "description", client); return true; } public bool:OnDisplay(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], ShopMenu:menu, &bool:disabled, const String:name[], String:buffer[], maxlen) { FormatEx(buffer, maxlen, "%T", "armokit", client); return true; } public bool:OnDescription(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], ShopMenu:menu, const String:description[], String:buffer[], maxlen) { FormatEx(buffer, maxlen, "%T", "armokit_description", client); return true; } public ShopAction:OnArmokitChoose(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[]) { if (g_iRoundUse > 0 && iRoundUsed[client] >= g_iRoundUse) { CPrintToChat(client, "%t", "RoundUsed", g_iRoundUse); return Shop_Raw; } if (IsPlayerAlive(client)) { new armor = GetClientArmor(client); if (armor < g_iMaxArmor) { if (g_iArmokitMode == ADD) { armor += g_iArmor; } else { armor = g_iArmor; } if (armor > g_iMaxArmor) { armor = g_iMaxArmor; } //SetEntityArmor(client, armor); //не работает SetEntProp(client,Prop_Send, "m_ArmorValue", armor+g_iMaxArmor); //Работает , но пополняет броню до фулла, а надо с конфига "sm_shop_armokit_max_armor", "+25" CPrintToChat(client, "%t", "UsedArmokit"); EmitSoundToAll(TEHNIC_SOUND, client); iRoundUsed[client]++; return Shop_UseOn; } else { CPrintToChat(client, "%t", "EnoughArmor"); } } else { CPrintToChat(client, "%t", "MustAlive"); } return Shop_Raw; }
SetEntProp(client,Prop_Send, "m_ArmorValue", armor);
Я просто не особо понял, что должно происходить. В любом случае приплюсовывание - будет установкой Armor+NВ вашем случае происходит суммирование лимита и выдача брони - это число заменяет количество единиц брони клиенту а не добавляет, я убрал g_iMaxArmor - в итоге плуг не суммирует более а просто устанавливает число (хотя идея в приплюсовывании к остаткам единиц брони у клиента) - но все же это лучше чем у меня было до этогоP.S В любом случае - большое спасибо за помощь)как то так):SetEntProp(client,Prop_Send, "m_ArmorValue", armor);
Пример: у игрока сталось 23 ед. брони , он использует рем.комплект который прибавляет к остатку 30 ед. брони = в итоге у игрока 53 ед.брониЯ просто не особо понял, что должно происходить. В любом случае приплюсовывание - будет установкой Armor+N
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <shop>
#include <colors>
#define PLUGIN_VERSION "2.1.2"
new ItemId:id;
#define MEDIC_SOUND "items/smallmedkit1.wav"
#define CATEGORY "stuff"
#define MEDKIT "medkit"
#define ADD 0
#define SET 1
new Handle:g_hHealth, g_iHealth,
Handle:g_hMaxHealth, g_iMaxHealth,
Handle:g_hRoundUse, g_iRoundUse,
Handle:g_hPrice, g_iPrice;
new Handle:g_hSellPrice, g_iSellPrice;
new g_iMedkitMode = SET;
new iRoundUsed[MAXPLAYERS+1];
public Plugin:myinfo =
{
name = "[Shop] Medkit",
author = "FrozDark (HLModders LLC)",
description = "Medkit component for Shop",
version = PLUGIN_VERSION,
url = "http://www.hlmod.ru/"
};
public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
{
MarkNativeAsOptional("GetUserMessageType");
}
public OnPluginStart()
{
g_hHealth = CreateConVar("sm_shop_medkit_health", "+25", "Medkit health. Raw numbers just set health to that value and + adds");
g_iHealth = GetConVarInt(g_hHealth);
HookConVarChange(g_hHealth, OnConVarChange);
g_hMaxHealth = CreateConVar("sm_shop_medkit_max_health", "90", "Max amount of health a player can hold", 0, true, 0.0);
g_iMaxHealth = GetConVarInt(g_hMaxHealth);
HookConVarChange(g_hMaxHealth, OnConVarChange);
g_hRoundUse = CreateConVar("sm_shop_medkit_per_round", "1", "How many medkits available per round.");
g_iRoundUse = GetConVarInt(g_hRoundUse);
HookConVarChange(g_hRoundUse, OnConVarChange);
g_hPrice = CreateConVar("sm_shop_medkit_price", "25", "The price of the medkit.");
g_iPrice = GetConVarInt(g_hPrice);
HookConVarChange(g_hPrice, OnConVarChange);
g_hSellPrice = CreateConVar("sm_shop_medkit_sellprice", "5", "Sell price for the medkit. -1 to make unsaleable");
g_iSellPrice = GetConVarInt(g_hSellPrice);
HookConVarChange(g_hSellPrice, OnConVarChange);
AutoExecConfig(true, "shop_medkit", "shop");
RegConsoleCmd("sm_medic", Command_Medic);
RegConsoleCmd("sm_medkit", Command_Medic);
LoadTranslations("shop_medkit.phrases.txt");
HookEvent("round_start", OnRoundStart, EventHookMode_PostNoCopy);
if (Shop_IsStarted()) Shop_Started();
}
public OnConVarChange(Handle:convar, const String:oldValue[], const String:newValue[])
{
if (convar == g_hHealth)
{
g_iHealth = StringToInt(newValue);
if (newValue[0] == '+')
{
g_iMedkitMode = ADD;
}
else
{
g_iMedkitMode = SET;
}
}
else if (convar == g_hMaxHealth)
{
g_iMaxHealth = StringToInt(newValue);
}
else if (convar == g_hRoundUse)
{
g_iRoundUse = StringToInt(newValue);
}
else if (convar == g_hPrice)
{
g_iPrice = StringToInt(newValue);
if (id != INVALID_ITEM)
{
Shop_SetItemPrice(id, g_iPrice);
}
}
else if (convar == g_hSellPrice)
{
g_iSellPrice = StringToInt(newValue);
if (id != INVALID_ITEM)
{
Shop_SetItemSellPrice(id, g_iSellPrice);
}
}
}
public OnRoundStart(Handle:event, const String:name[], bool:donBroadcast)
{
for (new i = 1; i <= MaxClients; i++)
{
iRoundUsed[i] = 0;
}
}
public Action:Command_Medic(client, args)
{
if (!client)
{
return Plugin_Continue;
}
if (!Shop_UseClientItem(client, id))
{
CPrintToChat(client, "%t", "NoMedkit");
}
return Plugin_Handled;
}
public OnMapStart()
{
PrecacheSound(MEDIC_SOUND, true);
}
public OnPluginEnd()
{
Shop_UnregisterMe();
}
public Shop_Started()
{
new CategoryId:category_id = Shop_RegisterCategory(CATEGORY, "Stuff", "", OnCategoryDisplay, OnCategoryDescription);
if (Shop_StartItem(category_id, MEDKIT))
{
Shop_SetInfo("Medkit", "", g_iPrice, g_iSellPrice, Item_Finite);
Shop_SetCallbacks(OnItemRegistered, OnMedkitChoose, _, OnDisplay, OnDescription, _, _);
Shop_EndItem();
}
}
public OnItemRegistered(CategoryId:category_id, const String:category[], const String:item[], ItemId:item_id)
{
id = item_id;
}
public bool:OnCategoryDisplay(client, CategoryId:category_id, const String:category[], const String:name[], String:buffer[], maxlen)
{
FormatEx(buffer, maxlen, "%T", "display", client);
return true;
}
public bool:OnCategoryDescription(client, CategoryId:category_id, const String:category[], const String:description[], String:buffer[], maxlen)
{
FormatEx(buffer, maxlen, "%T", "description", client);
return true;
}
public bool:OnDisplay(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], ShopMenu:menu, &bool:disabled, const String:name[], String:buffer[], maxlen)
{
FormatEx(buffer, maxlen, "%T", "medkit", client);
return true;
}
public bool:OnDescription(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], ShopMenu:menu, const String:description[], String:buffer[], maxlen)
{
FormatEx(buffer, maxlen, "%T", "medkit_description", client);
return true;
}
public ShopAction:OnMedkitChoose(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[])
{
if (g_iRoundUse > 0 && iRoundUsed[client] >= g_iRoundUse)
{
CPrintToChat(client, "%t", "RoundUsed", g_iRoundUse);
return Shop_Raw;
}
if (IsPlayerAlive(client))
{
new health = GetClientHealth(client);
if (health < g_iMaxHealth)
{
if (g_iMedkitMode == ADD)
{
health += g_iHealth;
}
else
{
health = g_iHealth;
}
if (health > g_iMaxHealth)
{
health = g_iMaxHealth;
}
SetEntityHealth(client, health);
CPrintToChat(client, "%t", "UsedMedkit");
EmitSoundToAll(MEDIC_SOUND, client);
iRoundUsed[client]++;
return Shop_UseOn;
}
else
{
CPrintToChat(client, "%t", "EnoughHealth");
}
}
else
{
CPrintToChat(client, "%t", "MustAlive");
}
return Shop_Raw;
}
Пример: у игрока сталось 23 ед. брони , он использует рем.комплект который прибавляет к остатку 30 ед. брони = в итоге у игрока 53 ед.брони
так же есть лимит на превышение: использовать рем.комплект можно только если брони к примеру меньше 70 ед
вот код оригинального модуля "медик"
shop_medkit.sp:#pragma semicolon 1 #include <sourcemod> #include <sdktools> #include <shop> #include <colors> #define PLUGIN_VERSION "2.1.2" new ItemId:id; #define MEDIC_SOUND "items/smallmedkit1.wav" #define CATEGORY "stuff" #define MEDKIT "medkit" #define ADD 0 #define SET 1 new Handle:g_hHealth, g_iHealth, Handle:g_hMaxHealth, g_iMaxHealth, Handle:g_hRoundUse, g_iRoundUse, Handle:g_hPrice, g_iPrice; new Handle:g_hSellPrice, g_iSellPrice; new g_iMedkitMode = SET; new iRoundUsed[MAXPLAYERS+1]; public Plugin:myinfo = { name = "[Shop] Medkit", author = "FrozDark (HLModders LLC)", description = "Medkit component for Shop", version = PLUGIN_VERSION, url = "http://www.hlmod.ru/" }; public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max) { MarkNativeAsOptional("GetUserMessageType"); } public OnPluginStart() { g_hHealth = CreateConVar("sm_shop_medkit_health", "+25", "Medkit health. Raw numbers just set health to that value and + adds"); g_iHealth = GetConVarInt(g_hHealth); HookConVarChange(g_hHealth, OnConVarChange); g_hMaxHealth = CreateConVar("sm_shop_medkit_max_health", "90", "Max amount of health a player can hold", 0, true, 0.0); g_iMaxHealth = GetConVarInt(g_hMaxHealth); HookConVarChange(g_hMaxHealth, OnConVarChange); g_hRoundUse = CreateConVar("sm_shop_medkit_per_round", "1", "How many medkits available per round."); g_iRoundUse = GetConVarInt(g_hRoundUse); HookConVarChange(g_hRoundUse, OnConVarChange); g_hPrice = CreateConVar("sm_shop_medkit_price", "25", "The price of the medkit."); g_iPrice = GetConVarInt(g_hPrice); HookConVarChange(g_hPrice, OnConVarChange); g_hSellPrice = CreateConVar("sm_shop_medkit_sellprice", "5", "Sell price for the medkit. -1 to make unsaleable"); g_iSellPrice = GetConVarInt(g_hSellPrice); HookConVarChange(g_hSellPrice, OnConVarChange); AutoExecConfig(true, "shop_medkit", "shop"); RegConsoleCmd("sm_medic", Command_Medic); RegConsoleCmd("sm_medkit", Command_Medic); LoadTranslations("shop_medkit.phrases.txt"); HookEvent("round_start", OnRoundStart, EventHookMode_PostNoCopy); if (Shop_IsStarted()) Shop_Started(); } public OnConVarChange(Handle:convar, const String:oldValue[], const String:newValue[]) { if (convar == g_hHealth) { g_iHealth = StringToInt(newValue); if (newValue[0] == '+') { g_iMedkitMode = ADD; } else { g_iMedkitMode = SET; } } else if (convar == g_hMaxHealth) { g_iMaxHealth = StringToInt(newValue); } else if (convar == g_hRoundUse) { g_iRoundUse = StringToInt(newValue); } else if (convar == g_hPrice) { g_iPrice = StringToInt(newValue); if (id != INVALID_ITEM) { Shop_SetItemPrice(id, g_iPrice); } } else if (convar == g_hSellPrice) { g_iSellPrice = StringToInt(newValue); if (id != INVALID_ITEM) { Shop_SetItemSellPrice(id, g_iSellPrice); } } } public OnRoundStart(Handle:event, const String:name[], bool:donBroadcast) { for (new i = 1; i <= MaxClients; i++) { iRoundUsed[i] = 0; } } public Action:Command_Medic(client, args) { if (!client) { return Plugin_Continue; } if (!Shop_UseClientItem(client, id)) { CPrintToChat(client, "%t", "NoMedkit"); } return Plugin_Handled; } public OnMapStart() { PrecacheSound(MEDIC_SOUND, true); } public OnPluginEnd() { Shop_UnregisterMe(); } public Shop_Started() { new CategoryId:category_id = Shop_RegisterCategory(CATEGORY, "Stuff", "", OnCategoryDisplay, OnCategoryDescription); if (Shop_StartItem(category_id, MEDKIT)) { Shop_SetInfo("Medkit", "", g_iPrice, g_iSellPrice, Item_Finite); Shop_SetCallbacks(OnItemRegistered, OnMedkitChoose, _, OnDisplay, OnDescription, _, _); Shop_EndItem(); } } public OnItemRegistered(CategoryId:category_id, const String:category[], const String:item[], ItemId:item_id) { id = item_id; } public bool:OnCategoryDisplay(client, CategoryId:category_id, const String:category[], const String:name[], String:buffer[], maxlen) { FormatEx(buffer, maxlen, "%T", "display", client); return true; } public bool:OnCategoryDescription(client, CategoryId:category_id, const String:category[], const String:description[], String:buffer[], maxlen) { FormatEx(buffer, maxlen, "%T", "description", client); return true; } public bool:OnDisplay(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], ShopMenu:menu, &bool:disabled, const String:name[], String:buffer[], maxlen) { FormatEx(buffer, maxlen, "%T", "medkit", client); return true; } public bool:OnDescription(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], ShopMenu:menu, const String:description[], String:buffer[], maxlen) { FormatEx(buffer, maxlen, "%T", "medkit_description", client); return true; } public ShopAction:OnMedkitChoose(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[]) { if (g_iRoundUse > 0 && iRoundUsed[client] >= g_iRoundUse) { CPrintToChat(client, "%t", "RoundUsed", g_iRoundUse); return Shop_Raw; } if (IsPlayerAlive(client)) { new health = GetClientHealth(client); if (health < g_iMaxHealth) { if (g_iMedkitMode == ADD) { health += g_iHealth; } else { health = g_iHealth; } if (health > g_iMaxHealth) { health = g_iMaxHealth; } SetEntityHealth(client, health); CPrintToChat(client, "%t", "UsedMedkit"); EmitSoundToAll(MEDIC_SOUND, client); iRoundUsed[client]++; return Shop_UseOn; } else { CPrintToChat(client, "%t", "EnoughHealth"); } } else { CPrintToChat(client, "%t", "MustAlive"); } return Shop_Raw; }
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <shop>
#include <colors>
#define PLUGIN_VERSION "2.1.3"
new ItemId:id;
#define MEDIC_SOUND "items/smallmedkit1.wav"
#define CATEGORY "stuff"
#define MEDKIT "medkit"
#define ADD 0
#define SET 1
new Handle:g_hHealth, g_iHealth,
Handle:g_hMaxHealth, g_iMaxHealth,
Handle:g_hRoundUse, g_iRoundUse,
Handle:g_hPrice, g_iPrice;
new Handle:g_hSellPrice, g_iSellPrice;
new g_iMedkitMode = ADD;
new iRoundUsed[MAXPLAYERS+1];
public Plugin:myinfo =
{
name = "[Shop] Medkit",
author = "FrozDark (HLModders LLC)",
description = "Medkit component for Shop",
version = PLUGIN_VERSION,
url = "http://www.hlmod.ru/"
};
public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
{
MarkNativeAsOptional("GetUserMessageType");
}
public OnPluginStart()
{
g_hHealth = CreateConVar("sm_shop_medkit_health", "+25", "Medkit health. Raw numbers just set health to that value and + adds");
g_iHealth = GetConVarInt(g_hHealth);
HookConVarChange(g_hHealth, OnConVarChange);
g_hMaxHealth = CreateConVar("sm_shop_medkit_max_health", "90", "Max amount of health a player can hold", 0, true, 0.0);
g_iMaxHealth = GetConVarInt(g_hMaxHealth);
HookConVarChange(g_hMaxHealth, OnConVarChange);
g_hRoundUse = CreateConVar("sm_shop_medkit_per_round", "1", "How many medkits available per round.");
g_iRoundUse = GetConVarInt(g_hRoundUse);
HookConVarChange(g_hRoundUse, OnConVarChange);
g_hPrice = CreateConVar("sm_shop_medkit_price", "25", "The price of the medkit.");
g_iPrice = GetConVarInt(g_hPrice);
HookConVarChange(g_hPrice, OnConVarChange);
g_hSellPrice = CreateConVar("sm_shop_medkit_sellprice", "5", "Sell price for the medkit. -1 to make unsaleable");
g_iSellPrice = GetConVarInt(g_hSellPrice);
HookConVarChange(g_hSellPrice, OnConVarChange);
AutoExecConfig(true, "shop_medkit", "shop");
RegConsoleCmd("sm_medic", Command_Medic);
RegConsoleCmd("sm_medkit", Command_Medic);
LoadTranslations("shop_medkit.phrases.txt");
HookEvent("round_start", OnRoundStart, EventHookMode_PostNoCopy);
if (Shop_IsStarted()) Shop_Started();
}
public OnConVarChange(Handle:convar, const String:oldValue[], const String:newValue[])
{
if (convar == g_hHealth)
{
g_iHealth = StringToInt(newValue);
if (newValue[0] == '+')
{
g_iMedkitMode = ADD;
}
else
{
g_iMedkitMode = SET;
}
}
else if (convar == g_hMaxHealth)
{
g_iMaxHealth = StringToInt(newValue);
}
else if (convar == g_hRoundUse)
{
g_iRoundUse = StringToInt(newValue);
}
else if (convar == g_hPrice)
{
g_iPrice = StringToInt(newValue);
if (id != INVALID_ITEM)
{
Shop_SetItemPrice(id, g_iPrice);
}
}
else if (convar == g_hSellPrice)
{
g_iSellPrice = StringToInt(newValue);
if (id != INVALID_ITEM)
{
Shop_SetItemSellPrice(id, g_iSellPrice);
}
}
}
public OnRoundStart(Handle:event, const String:name[], bool:donBroadcast)
{
for (new i = 1; i <= MaxClients; i++)
{
iRoundUsed[i] = 0;
}
}
public Action:Command_Medic(client, args)
{
if (!client)
{
return Plugin_Continue;
}
if (!Shop_UseClientItem(client, id))
{
CPrintToChat(client, "%t", "NoMedkit");
}
return Plugin_Handled;
}
public OnMapStart()
{
PrecacheSound(MEDIC_SOUND, true);
}
public OnPluginEnd()
{
Shop_UnregisterMe();
}
public Shop_Started()
{
new CategoryId:category_id = Shop_RegisterCategory(CATEGORY, "Stuff", "", OnCategoryDisplay, OnCategoryDescription);
if (Shop_StartItem(category_id, MEDKIT))
{
Shop_SetInfo("Medkit", "", g_iPrice, g_iSellPrice, Item_Finite);
Shop_SetCallbacks(OnItemRegistered, OnMedkitChoose, _, OnDisplay, OnDescription, _, _);
Shop_EndItem();
}
}
public OnItemRegistered(CategoryId:category_id, const String:category[], const String:item[], ItemId:item_id)
{
id = item_id;
}
public bool:OnCategoryDisplay(client, CategoryId:category_id, const String:category[], const String:name[], String:buffer[], maxlen)
{
FormatEx(buffer, maxlen, "%T", "display", client);
return true;
}
public bool:OnCategoryDescription(client, CategoryId:category_id, const String:category[], const String:description[], String:buffer[], maxlen)
{
FormatEx(buffer, maxlen, "%T", "description", client);
return true;
}
public bool:OnDisplay(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], ShopMenu:menu, &bool:disabled, const String:name[], String:buffer[], maxlen)
{
FormatEx(buffer, maxlen, "%T", "medkit", client);
return true;
}
public bool:OnDescription(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], ShopMenu:menu, const String:description[], String:buffer[], maxlen)
{
FormatEx(buffer, maxlen, "%T", "medkit_description", client);
return true;
}
public ShopAction:OnMedkitChoose(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[])
{
if (g_iRoundUse > 0 && iRoundUsed[client] >= g_iRoundUse)
{
CPrintToChat(client, "%t", "RoundUsed", g_iRoundUse);
return Shop_Raw;
}
if (IsPlayerAlive(client))
{
new health = GetEntProp(client, Prop_Data, "m_ArmorValue");
if (health < g_iMaxHealth)
{
if (g_iMedkitMode == ADD)
{
health += g_iHealth;
}
else
{
health = g_iHealth;
}
if (health > g_iMaxHealth)
{
health = g_iMaxHealth;
}
SetEntProp(client, Prop_Data, "m_ArmorValue", health);
CPrintToChat(client, "%t", "UsedMedkit");
EmitSoundToAll(MEDIC_SOUND, client);
iRoundUsed[client]++;
return Shop_UseOn;
}
else
{
CPrintToChat(client, "%t", "EnoughHealth");
}
}
else
{
CPrintToChat(client, "%t", "MustAlive");
}
return Shop_Raw;
}
Огромное спасибо, все работает (заменил ид категории +phrases.txt под броню ), все идеально , ошибок нету)))na:#pragma semicolon 1 #include <sourcemod> #include <sdktools> #include <shop> #include <colors> #define PLUGIN_VERSION "2.1.3" new ItemId:id; #define MEDIC_SOUND "items/smallmedkit1.wav" #define CATEGORY "stuff" #define MEDKIT "medkit" #define ADD 0 #define SET 1 new Handle:g_hHealth, g_iHealth, Handle:g_hMaxHealth, g_iMaxHealth, Handle:g_hRoundUse, g_iRoundUse, Handle:g_hPrice, g_iPrice; new Handle:g_hSellPrice, g_iSellPrice; new g_iMedkitMode = ADD; new iRoundUsed[MAXPLAYERS+1]; public Plugin:myinfo = { name = "[Shop] Medkit", author = "FrozDark (HLModders LLC)", description = "Medkit component for Shop", version = PLUGIN_VERSION, url = "http://www.hlmod.ru/" }; public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max) { MarkNativeAsOptional("GetUserMessageType"); } public OnPluginStart() { g_hHealth = CreateConVar("sm_shop_medkit_health", "+25", "Medkit health. Raw numbers just set health to that value and + adds"); g_iHealth = GetConVarInt(g_hHealth); HookConVarChange(g_hHealth, OnConVarChange); g_hMaxHealth = CreateConVar("sm_shop_medkit_max_health", "90", "Max amount of health a player can hold", 0, true, 0.0); g_iMaxHealth = GetConVarInt(g_hMaxHealth); HookConVarChange(g_hMaxHealth, OnConVarChange); g_hRoundUse = CreateConVar("sm_shop_medkit_per_round", "1", "How many medkits available per round."); g_iRoundUse = GetConVarInt(g_hRoundUse); HookConVarChange(g_hRoundUse, OnConVarChange); g_hPrice = CreateConVar("sm_shop_medkit_price", "25", "The price of the medkit."); g_iPrice = GetConVarInt(g_hPrice); HookConVarChange(g_hPrice, OnConVarChange); g_hSellPrice = CreateConVar("sm_shop_medkit_sellprice", "5", "Sell price for the medkit. -1 to make unsaleable"); g_iSellPrice = GetConVarInt(g_hSellPrice); HookConVarChange(g_hSellPrice, OnConVarChange); AutoExecConfig(true, "shop_medkit", "shop"); RegConsoleCmd("sm_medic", Command_Medic); RegConsoleCmd("sm_medkit", Command_Medic); LoadTranslations("shop_medkit.phrases.txt"); HookEvent("round_start", OnRoundStart, EventHookMode_PostNoCopy); if (Shop_IsStarted()) Shop_Started(); } public OnConVarChange(Handle:convar, const String:oldValue[], const String:newValue[]) { if (convar == g_hHealth) { g_iHealth = StringToInt(newValue); if (newValue[0] == '+') { g_iMedkitMode = ADD; } else { g_iMedkitMode = SET; } } else if (convar == g_hMaxHealth) { g_iMaxHealth = StringToInt(newValue); } else if (convar == g_hRoundUse) { g_iRoundUse = StringToInt(newValue); } else if (convar == g_hPrice) { g_iPrice = StringToInt(newValue); if (id != INVALID_ITEM) { Shop_SetItemPrice(id, g_iPrice); } } else if (convar == g_hSellPrice) { g_iSellPrice = StringToInt(newValue); if (id != INVALID_ITEM) { Shop_SetItemSellPrice(id, g_iSellPrice); } } } public OnRoundStart(Handle:event, const String:name[], bool:donBroadcast) { for (new i = 1; i <= MaxClients; i++) { iRoundUsed[i] = 0; } } public Action:Command_Medic(client, args) { if (!client) { return Plugin_Continue; } if (!Shop_UseClientItem(client, id)) { CPrintToChat(client, "%t", "NoMedkit"); } return Plugin_Handled; } public OnMapStart() { PrecacheSound(MEDIC_SOUND, true); } public OnPluginEnd() { Shop_UnregisterMe(); } public Shop_Started() { new CategoryId:category_id = Shop_RegisterCategory(CATEGORY, "Stuff", "", OnCategoryDisplay, OnCategoryDescription); if (Shop_StartItem(category_id, MEDKIT)) { Shop_SetInfo("Medkit", "", g_iPrice, g_iSellPrice, Item_Finite); Shop_SetCallbacks(OnItemRegistered, OnMedkitChoose, _, OnDisplay, OnDescription, _, _); Shop_EndItem(); } } public OnItemRegistered(CategoryId:category_id, const String:category[], const String:item[], ItemId:item_id) { id = item_id; } public bool:OnCategoryDisplay(client, CategoryId:category_id, const String:category[], const String:name[], String:buffer[], maxlen) { FormatEx(buffer, maxlen, "%T", "display", client); return true; } public bool:OnCategoryDescription(client, CategoryId:category_id, const String:category[], const String:description[], String:buffer[], maxlen) { FormatEx(buffer, maxlen, "%T", "description", client); return true; } public bool:OnDisplay(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], ShopMenu:menu, &bool:disabled, const String:name[], String:buffer[], maxlen) { FormatEx(buffer, maxlen, "%T", "medkit", client); return true; } public bool:OnDescription(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], ShopMenu:menu, const String:description[], String:buffer[], maxlen) { FormatEx(buffer, maxlen, "%T", "medkit_description", client); return true; } public ShopAction:OnMedkitChoose(client, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[]) { if (g_iRoundUse > 0 && iRoundUsed[client] >= g_iRoundUse) { CPrintToChat(client, "%t", "RoundUsed", g_iRoundUse); return Shop_Raw; } if (IsPlayerAlive(client)) { new health = GetEntProp(client, Prop_Data, "m_ArmorValue"); if (health < g_iMaxHealth) { if (g_iMedkitMode == ADD) { health += g_iHealth; } else { health = g_iHealth; } if (health > g_iMaxHealth) { health = g_iMaxHealth; } SetEntProp(client, Prop_Data, "m_ArmorValue", health); CPrintToChat(client, "%t", "UsedMedkit"); EmitSoundToAll(MEDIC_SOUND, client); iRoundUsed[client]++; return Shop_UseOn; } else { CPrintToChat(client, "%t", "EnoughHealth"); } } else { CPrintToChat(client, "%t", "MustAlive"); } return Shop_Raw; }