Skocz do zawartości

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Misiaczek ;c - zdjęcie

Misiaczek ;c

Rejestracja: 23.04.2008
Aktualnie: Nieaktywny
Poza forum Ostatnio: 14.04.2026 06:18
*****

Moje posty

W temacie: Battlefield 2 : Rank Mod Web Stats

07.04.2026 10:57

Hej, nie wiem czy ktoś jeszcze z tego korzysta, ale aktualnie staram się to przepisać i może dodam panel admina ;)

W temacie: Szukam pluginu który naprawia wyrzucanie broni powyżej 30

07.04.2026 08:29

Zjarany, wrzuc ten plik amxx na serwer, daj mu popracować kilka godzin i daj mi logi jakie ci wyprodukował

 

logi z pluginu będą się zaczynać od "entity_profiler_"

W temacie: Szukam pluginu który naprawia wyrzucanie broni powyżej 30

07.04.2026 07:50


Użycie CurWeapon to istne marnowanie zasobów do tak trywialnego zadania.

 

wiem o tym że to jak strzelanie z czołgu do mrówki :P

#include <amxmodx>
#include <engine>

#define PLUGIN  "Entity & Drop Fix"
#define VERSION "1.4"
#define AUTHOR  "Misiaczek ;c / Err0r"

#define TASK_CLEANUP_EXPIRED   1001
#define TASK_CHECK_LIMIT       1002
#define TASK_CHECK_EDICTS      1003

#define CLEANUP_INTERVAL       1.0
#define LIMIT_INTERVAL         2.0
#define EDICTS_INTERVAL        3.0

new g_pMaxWeapons;
new g_pWeaponLife;
new g_pMaxEdicts;
new g_pDebug;

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR);

    g_pMaxWeapons = register_cvar("guard_max_weapons", "20");
    g_pWeaponLife = register_cvar("guard_weapon_life", "12.0");
    g_pMaxEdicts  = register_cvar("guard_max_edicts", "850");
    g_pDebug      = register_cvar("guard_debug", "0");

    set_task(CLEANUP_INTERVAL, "Task_CleanupExpiredWeapons", TASK_CLEANUP_EXPIRED, _, _, "b");
    set_task(LIMIT_INTERVAL, "Task_CheckWeaponLimit", TASK_CHECK_LIMIT, _, _, "b");
    set_task(EDICTS_INTERVAL, "Task_CheckEdicts", TASK_CHECK_EDICTS, _, _, "b");

    DebugLog("Plugin initialized. max_weapons=%d | weapon_life=%.1f | max_edicts=%d",
        get_pcvar_num(g_pMaxWeapons),
        get_pcvar_float(g_pWeaponLife),
        get_pcvar_num(g_pMaxEdicts)
    );
}

public Task_CleanupExpiredWeapons()
{
    new removed = CleanupExpiredWeapons();

    if (removed > 0)
    {
        DebugLog("Expired cleanup removed %d weaponbox(es)", removed);
    }
}

public Task_CheckWeaponLimit()
{
    new maxWeapons = max(1, get_pcvar_num(g_pMaxWeapons));
    new weaponCount = CountWeaponBoxes();

    DebugLog("Weapon count: %d / %d", weaponCount, maxWeapons);

    if (weaponCount <= maxWeapons)
        return;

    new removed = TrimWeaponBoxesToLimit(maxWeapons);

    if (removed > 0)
    {
        DebugLog("Limit cleanup removed %d weaponbox(es)", removed);
    }
}

public Task_CheckEdicts()
{
    new maxEdicts = max(1, get_pcvar_num(g_pMaxEdicts));
    new totalEdicts = CountAllEdicts();

    if (totalEdicts < maxEdicts)
        return;

    new removed = PanicCleanupWeapons();

    DebugLog("PANIC CLEANUP! Edicts: %d / %d | removed weaponbox(es): %d",
        totalEdicts,
        maxEdicts,
        removed
    );
}

stock CountWeaponBoxes()
{
    new count = 0;
    new ent = -1;

    while ((ent = find_ent_by_class(ent, "weaponbox")))
    {
        if (!IsManagedWeaponBox(ent))
            continue;

        count++;
    }

    return count;
}

stock CleanupExpiredWeapons()
{
    new removed = 0;
    new ent = -1;
    new Float:currentTime = get_gametime();
    new Float:lifetime = get_pcvar_float(g_pWeaponLife);

    if (lifetime <= 0.0)
        return 0;

    while ((ent = find_ent_by_class(ent, "weaponbox")))
    {
        if (!IsManagedWeaponBox(ent))
            continue;

        new Float:spawnTime = entity_get_float(ent, EV_FL_fuser1);

        if (spawnTime <= 0.0)
        {
            entity_set_float(ent, EV_FL_fuser1, currentTime);
            continue;
        }

        if ((currentTime - spawnTime) >= lifetime)
        {
            remove_entity(ent);
            removed++;
        }
    }

    return removed;
}

stock TrimWeaponBoxesToLimit(maxWeapons)
{
    new weaponCount = CountWeaponBoxes();

    if (weaponCount <= maxWeapons)
        return 0;

    new removed = 0;
    new needToRemove = weaponCount - maxWeapons;

    while (needToRemove > 0)
    {
        new oldestEnt = 0;
        new Float:oldestSpawnTime = 9999999.0;
        new ent = -1;

        while ((ent = find_ent_by_class(ent, "weaponbox")))
        {
            if (!IsManagedWeaponBox(ent))
                continue;

            new Float:spawnTime = entity_get_float(ent, EV_FL_fuser1);

            if (spawnTime <= 0.0)
                spawnTime = 0.0;

            if (spawnTime < oldestSpawnTime)
            {
                oldestSpawnTime = spawnTime;
                oldestEnt = ent;
            }
        }

        if (!oldestEnt || !is_valid_ent(oldestEnt))
            break;

        remove_entity(oldestEnt);
        removed++;
        needToRemove--;
    }

    return removed;
}

stock PanicCleanupWeapons()
{
    new removed = 0;
    new ent = -1;

    while ((ent = find_ent_by_class(ent, "weaponbox")))
    {
        if (!IsManagedWeaponBox(ent))
            continue;

        remove_entity(ent);
        removed++;
    }

    return removed;
}

stock CountAllEdicts()
{
    new count = 0;
    new ent = -1;

    while ((ent = find_ent_by_class(ent, "*")))
    {
        if (is_valid_ent(ent))
            count++;
    }

    return count;
}

stock bool:IsManagedWeaponBox(ent)
{
    if (!is_valid_ent(ent))
        return false;

    if (IsC4(ent))
        return false;

    return true;
}

stock bool:IsC4(ent)
{
    static model[64];
    entity_get_string(ent, EV_SZ_model, model, charsmax(model));

    return containi(model, "c4") != -1;
}

stock DebugLog(const fmt[], any:...)
{
    if (!get_pcvar_num(g_pDebug))
        return;

    static buffer[192];
    vformat(buffer, charsmax(buffer), fmt, 2);
    server_print("[GUARD] %s", buffer);
}

W temacie: Szukam pluginu który naprawia wyrzucanie broni powyżej 30

02.04.2026 12:45

#include <amxmodx>
#include <engine>

#define PLUGIN  "Entity & Drop Fix"
#define VERSION "1.1"
#define AUTHOR  "Misiaczek ;c / Err0r"

new g_pMaxWeapons;
new g_pWeaponLife;
new g_pMaxEdicts;
new g_pDebug;
new g_iWeaponCount;

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR);

    g_pMaxWeapons = register_cvar("guard_max_weapons", "20");
    g_pWeaponLife = register_cvar("guard_weapon_life", "12.0");
    g_pMaxEdicts  = register_cvar("guard_max_edicts", "850");
    g_pDebug      = register_cvar("guard_debug", "0");

    register_event("CurWeapon", "OnWeaponDropCheck", "be");

    set_task(1.0, "CleanupWeapons", _, _, _, "b");
    set_task(3.0, "CheckEdicts", _, _, _, "b");
}

public plugin_cfg()
{
    SyncWeapons();
}

public OnWeaponDropCheck(id)
{
    if (!is_user_alive(id))
        return;

    SyncWeapons();

    if (g_iWeaponCount >= get_pcvar_num(g_pMaxWeapons))
    {
        client_print(id, print_center, "[GUARD] Za duzo broni na mapie!");
    }
}

public CleanupWeapons()
{
    new ent = -1;
    new Float:time = get_gametime();
    new Float:lifetime = get_pcvar_float(g_pWeaponLife);

    while ((ent = find_ent_by_class(ent, "weaponbox")))
    {
        if (!is_valid_ent(ent))
            continue;

        if (IsC4(ent))
            continue;

        new Float:spawn = entity_get_float(ent, EV_FL_fuser1);

        if (spawn == 0.0)
        {
            entity_set_float(ent, EV_FL_fuser1, time);
            continue;
        }

        if ((time - spawn) > lifetime)
        {
            remove_entity(ent);
        }
    }
}

public CheckEdicts()
{
    new total = 0;
    new ent = -1;

    while ((ent = find_ent_by_class(ent, "*")))
    {
        if (is_valid_ent(ent))
            total++;
    }

    if (total >= get_pcvar_num(g_pMaxEdicts))
    {
        new w = -1;

        while ((w = find_ent_by_class(w, "weaponbox")))
        {
            if (is_valid_ent(w))
                remove_entity(w);
        }

        if (get_pcvar_num(g_pDebug))
            server_print("[GUARD] CLEANUP! Edicts: %d", total);
    }
}

public SyncWeapons()
{
    new ent = -1;
    g_iWeaponCount = 0;

    while ((ent = find_ent_by_class(ent, "weaponbox")))
    {
        if (is_valid_ent(ent) && !IsC4(ent))
            g_iWeaponCount++;
    }
}

stock bool:IsC4(ent)
{
    static model[64];
    entity_get_string(ent, EV_SZ_model, model, charsmax(model));

    return containi(model, "c4") != -1;
}

mój błąd wcześniej, w reapi sugerowałem się częściowo fakemeta, przez co nieściłośc wyszła, ale prosze , to działa bez problemu

//AMXXPC compile.exe
// by the AMX Mod X Dev Team


//// test.sma
//
// Header size:            728 bytes
// Code size:             2480 bytes
// Data size:             1684 bytes
// Stack/heap size:      16384 bytes
// Total requirements:   21276 bytes
// Done.
//
// Compilation Time: 0,7 sec
// ----------------------------------------

W temacie: Szukam pluginu który naprawia wyrzucanie broni powyżej 30

31.03.2026 16:43

Jutro w domu bede to puszcze to przez kompilator :)