Прочитай лучше что я написал ниже после его поста ...вот метод редактирования конфига оружки
http://hlmod.ru/forum/showpost.php?p=86840&postcount=7
мне бы это дело еще с кваром заюзать что бы только на определенных картах работал этот режим
Протестировал нормально все работает.Прочитай лучше что я написал ниже после его поста ...
#pragma semicolon 1
#include <sourcemod>
#include <sdktools_functions>
public Plugin:myinfo =
{
name = "weapon_ammo",
author = "wS / Schmidt",
description = "",
version = "1.0",
url = "http://world-source.ru/"
};
new Handle:g_Trie = INVALID_HANDLE;
new Handle:cvarEnabled = INVALID_HANDLE;
public OnPluginStart()
{
cvarEnabled = CreateConVar("plug_enable", "0", "1/0");
new Handle:kv = CreateKeyValues("weapon_ammo");
if (!FileToKeyValues(kv, "cfg/weapon_ammo.txt") || !KvGotoFirstSubKey(kv))
{
CloseHandle(kv);
SetFailState("cfg/weapon_ammo.txt not found or empty (or bad syntax / charset)");
return;
}
g_Trie = CreateTrie();
decl String:item[20], ammo[2];
do
{
if (KvGetSectionName(kv, item, 20))
{
ammo[0] = KvGetNum(kv, "ammo"); ammo[1] = KvGetNum(kv, "reserve");
SetTrieArray(g_Trie, item, ammo, 2);
}
}
while (KvGotoNextKey(kv));
CloseHandle(kv);
if (GetTrieSize(g_Trie) < 1) SetFailState("cfg/weapon_ammo.txt empty");
}
public Action:CS_OnBuyCommand(client, const String:item[])
{
if (GetConVarBool(cvarEnabled))
{
decl ammo[2];
if (GetTrieArray(g_Trie, item, ammo, 2))
{
new Handle:pack;
CreateDataTimer(0.1, wS_Function, pack);
WritePackCell(pack, client);
WritePackString(pack, item);
WritePackCell(pack, ammo[0]);
WritePackCell(pack, ammo[1]);
}
}
return Plugin_Continue;
}
public Action:wS_Function(Handle:timer, Handle:pack)
{
ResetPack(pack);
new client = ReadPackCell(pack);
if (IsClientInGame(client) && IsPlayerAlive(client))
{
decl String:weapon[25], String:class[25], index;
ReadPackString(pack, weapon, 25);
Format(weapon, 25, "weapon_%s", weapon);
for (new slot = 0; slot < 2; slot++)
{
if ((index = GetPlayerWeaponSlot(client, slot)) > 0 && GetEntityClassname(index, class, 25) && strcmp(class, weapon) == 0)
{
new m_iPrimaryAmmoType = -1;
if ((m_iPrimaryAmmoType = GetEntProp(index, Prop_Send, "m_iPrimaryAmmoType")) != -1)
{
SetEntProp(index, Prop_Send, "m_iClip1", ReadPackCell(pack));
SetEntProp(client, Prop_Send, "m_iAmmo", ReadPackCell(pack), _, m_iPrimaryAmmoType);
}
break;
}
}
}
}
Alcone, эм. Скопируй и скомпиль. Тот же плагин с кваром. plug_enable 0 (по умолчанию)
C-подобный:#pragma semicolon 1 #include <sourcemod> #include <sdktools_functions> public Plugin:myinfo = { name = "weapon_ammo", author = "wS / Schmidt", description = "", version = "1.0", url = "http://world-source.ru/" }; new Handle:g_Trie = INVALID_HANDLE; new Handle:cvarEnabled = INVALID_HANDLE; public OnPluginStart() { cvarEnabled = CreateConVar("plug_enable", "0", "1/0"); new Handle:kv = CreateKeyValues("weapon_ammo"); if (!FileToKeyValues(kv, "cfg/weapon_ammo.txt") || !KvGotoFirstSubKey(kv)) { CloseHandle(kv); SetFailState("cfg/weapon_ammo.txt not found or empty (or bad syntax / charset)"); return; } g_Trie = CreateTrie(); decl String:item[20], ammo[2]; do { if (KvGetSectionName(kv, item, 20)) { ammo[0] = KvGetNum(kv, "ammo"); ammo[1] = KvGetNum(kv, "reserve"); SetTrieArray(g_Trie, item, ammo, 2); } } while (KvGotoNextKey(kv)); CloseHandle(kv); if (GetTrieSize(g_Trie) < 1) SetFailState("cfg/weapon_ammo.txt empty"); } public Action:CS_OnBuyCommand(client, const String:item[]) { if (GetConVarBool(cvarEnabled)) { decl ammo[2]; if (GetTrieArray(g_Trie, item, ammo, 2)) { new Handle:pack; CreateDataTimer(0.1, wS_Function, pack); WritePackCell(pack, client); WritePackString(pack, item); WritePackCell(pack, ammo[0]); WritePackCell(pack, ammo[1]); } } return Plugin_Continue; } public Action:wS_Function(Handle:timer, Handle:pack) { ResetPack(pack); new client = ReadPackCell(pack); if (IsClientInGame(client) && IsPlayerAlive(client)) { decl String:weapon[25], String:class[25], index; ReadPackString(pack, weapon, 25); Format(weapon, 25, "weapon_%s", weapon); for (new slot = 0; slot < 2; slot++) { if ((index = GetPlayerWeaponSlot(client, slot)) > 0 && GetEntityClassname(index, class, 25) && strcmp(class, weapon) == 0) { new m_iPrimaryAmmoType = -1; if ((m_iPrimaryAmmoType = GetEntProp(index, Prop_Send, "m_iPrimaryAmmoType")) != -1) { SetEntProp(index, Prop_Send, "m_iClip1", ReadPackCell(pack)); SetEntProp(client, Prop_Send, "m_iAmmo", ReadPackCell(pack), _, m_iPrimaryAmmoType); } break; } } } }
Попробовал но не чего не получилось все по стандарту :(
В смысле? Я же попробывал у себя прежде чем выложить) если ставишь 1 и покупаешь дигл, то дается 6 патронов. Если оставить как есть и купить дигл, то патронов будет 7 +35, как по стандарту.
Я взял плагин, который выше упоминался. Я ничего не менял, просто засунул как ты попросил туда квар на включение и выключение.Скинь пожалуйста свой
cfg/weapon_ammo.txt