Количество патронов в обойме (CS:S)

Alcone

optizone.ru
Сообщения
318
Реакции
73
Нужен плагин регулирующий количество патронов в обойме(магазине) в котором будет квар plugin_enable 1 / 0

Может есть метод редактирования конфигов оружия на сервере?
 

Vit_ amin

Добрая душа
Сообщения
1,504
Реакции
660

Impulse72

Участник
Сообщения
244
Реакции
163
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;
			}
		}
	}
}
 

Alcone

optizone.ru
Сообщения
318
Реакции
73
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;
            }
        }
    }
}


Попробовал но не чего не получилось все по стандарту :(
 

Impulse72

Участник
Сообщения
244
Реакции
163
Попробовал но не чего не получилось все по стандарту :(

В смысле? Я же попробывал у себя прежде чем выложить) если ставишь 1 и покупаешь дигл, то дается 6 патронов. Если оставить как есть и купить дигл, то патронов будет 7 +35, как по стандарту.
 

Alcone

optizone.ru
Сообщения
318
Реакции
73
В смысле? Я же попробывал у себя прежде чем выложить) если ставишь 1 и покупаешь дигл, то дается 6 патронов. Если оставить как есть и купить дигл, то патронов будет 7 +35, как по стандарту.

Скинь пожалуйста свой
cfg/weapon_ammo.txt
 
Сверху Снизу