Sneaky.amxx 发表于 2015-5-2 18:23:18

Precache Manager / Precache file limit FIX


这是一个改善 public plugin_precache 数量限制的方法

MAX_MODELS 1024 (半条命使用了: 512)
MAX_SOUNDS 1024 (半条命使用了: 512)

这意味着你总共只能缓存 512 个声音文件和 512 个模型文件,如果你超出了这个限制你的服务器将不能启动。


这个插件将释放出 200+ 个缓存空间供你的插件使用!
他的工作原理是腾出一些半条命的缓存空间,让你使用。

如果你发现一些文件在这个插件里面,但是你有使用到这个文件,不要担心,他还是会在你的插件里面加载的,这个插件只会删除不是 amxx 缓存的文件。


This is a helpful fix to the limitations of public plugin_precache .

MAX_MODELS 1024 (default HalfLife Files Used: 512)
MAX_SOUNDS 1024 (defaulHalfLife Files Usedt: 512)

That means you can only have a number of 512 sound files
Or 512 Model files.. if you go over that limit your server will NOT start.

With my plugin. It frees about 200+ file spaces so you can add more content to your Plugins!
The way my plugin works is.. it takes some halflife files out of precache so you have more space.

If you see a halflife file in my plugin that 1 of your plugins is using.. do not worry! it will still be precached by your plugin.. my plugin only removed files that amxx doesn't precache..



#include <amxmodx>
#include <fakemeta>

#define PLUGIN "Precache Manager"
#define VERSION "1.0"
#define AUTHOR "Sneaky.amxx"

new Array:ArModel, Array:ArSound
new TempData

new const UnPrecache_SoundList[] =
{
        "models/w_antidote.mdl",
        "models/w_security.mdl",
        "models/w_longjump.mdl",
        "items/suitcharge1.wav",
        "items/suitchargeno1.wav",
        "items/suitchargeok1.wav",
        "common/wpn_hudoff.wav",
        "common/wpn_hudon.wav",
        "common/wpn_moveselect.wav",
        "common/wpn_denyselect.wav",
        "player/geiger6.wav",
        "player/geiger5.wav",
        "player/geiger4.wav",
        "player/geiger3.wav",
        "player/geiger2.wav",
        "player/geiger1.wav",
        "sprites/zerogxplode.spr",
        "sprites/WXplo1.spr",
        "sprites/steam1.spr",
        "sprites/bubble.spr",
        "sprites/bloodspray.spr",
        "sprites/blood.spr",
        "sprites/smokepuff.spr",
        "sprites/eexplo.spr",
        "sprites/fexplo.spr",
        "sprites/fexplo1.spr",
        "sprites/b-tele1.spr",
        "sprites/c-tele1.spr",
        "sprites/ledglow.spr",
        "sprites/laserdot.spr",
        "sprites/explode1.spr",
        "weapons/bullet_hit1.wav",
        "weapons/bullet_hit2.wav",
        "items/weapondrop1.wav",
        "weapons/generic_reload.wav",
        "sprites/smoke.spr",
        "buttons/bell1.wav",
        "buttons/blip1.wav",
        "buttons/blip2.wav",
        "buttons/button11.wav",
        "buttons/latchunlocked2.wav",
        "buttons/lightswitch2.wav",
        "ambience/quail1.wav",
        "events/tutor_msg.wav",
        "events/enemy_died.wav",
        "events/friend_died.wav",
        "events/task_complete.wav",
       
        "weapons/ak47_clipout.wav",
        "weapons/ak47_clipin.wav",
        "weapons/ak47_boltpull.wav",
        "weapons/aug_clipout.wav",
        "weapons/aug_clipin.wav",
        "weapons/aug_boltpull.wav",
        "weapons/aug_boltslap.wav",
        "weapons/aug_forearm.wav",
        "weapons/c4_click.wav",
        "weapons/c4_beep1.wav",
        "weapons/c4_beep2.wav",
        "weapons/c4_beep3.wav",
        "weapons/c4_beep4.wav",
        "weapons/c4_beep5.wav",
        "weapons/c4_explode1.wav",
        "weapons/c4_plant.wav",
        "weapons/c4_disarm.wav",
        "weapons/c4_disarmed.wav",
        "weapons/elite_reloadstart.wav",
        "weapons/elite_leftclipin.wav",
        "weapons/elite_clipout.wav",
        "weapons/elite_sliderelease.wav",
        "weapons/elite_rightclipin.wav",
        "weapons/elite_deploy.wav",
        "weapons/famas_clipout.wav",
        "weapons/famas_clipin.wav",
        "weapons/famas_boltpull.wav",
        "weapons/famas_boltslap.wav",
        "weapons/famas_forearm.wav",
        "weapons/g3sg1_slide.wav",
        "weapons/g3sg1_clipin.wav",
        "weapons/g3sg1_clipout.wav",
        "weapons/galil_clipout.wav",
        "weapons/galil_clipin.wav",
        "weapons/galil_boltpull.wav",
        "weapons/m4a1_clipin.wav",
        "weapons/m4a1_clipout.wav",
        "weapons/m4a1_boltpull.wav",
        "weapons/m4a1_deploy.wav",
        "weapons/m4a1_silencer_on.wav",
        "weapons/m4a1_silencer_off.wav",
        "weapons/m249_boxout.wav",
        "weapons/m249_boxin.wav",
        "weapons/m249_chain.wav",
        "weapons/m249_coverup.wav",
        "weapons/m249_coverdown.wav",
        "weapons/mac10_clipout.wav",
        "weapons/mac10_clipin.wav",
        "weapons/mac10_boltpull.wav",
        "weapons/mp5_clipout.wav",
        "weapons/mp5_clipin.wav",
        "weapons/mp5_slideback.wav",
        "weapons/p90_clipout.wav",
        "weapons/p90_clipin.wav",
        "weapons/p90_boltpull.wav",
        "weapons/p90_cliprelease.wav",
        "weapons/p228_clipout.wav",
        "weapons/p228_clipin.wav",
        "weapons/p228_sliderelease.wav",
        "weapons/p228_slidepull.wav",
        "weapons/scout_bolt.wav",
        "weapons/scout_clipin.wav",
        "weapons/scout_clipout.wav",
        "weapons/sg550_boltpull.wav",
        "weapons/sg550_clipin.wav",
        "weapons/sg550_clipout.wav",
        "weapons/sg552_clipout.wav",
        "weapons/sg552_clipin.wav",
        "weapons/sg552_boltpull.wav",
        "weapons/ump45_clipout.wav",
        "weapons/ump45_clipin.wav",
        "weapons/ump45_boltslap.wav",
        "weapons/usp_clipout.wav",
        "weapons/usp_clipin.wav",
        "weapons/usp_silencer_on.wav",
        "weapons/usp_silencer_off.wav",
        "weapons/usp_sliderelease.wav",
        "weapons/usp_slideback.wav"
}

public plugin_init()
{
        register_plugin(PLUGIN, VERSION, AUTHOR)
       
        server_print(" Precache Manager: Reserved Slots (Model: %i | Sound: %i)", 512 - ArraySize(ArModel), 512 - ArraySize(ArSound))
}

public plugin_precache()
{
        ArModel = ArrayCreate(64, 1)
        ArSound = ArrayCreate(64, 1)
       
        register_forward(FM_PrecacheModel, "fw_PrecacheModel")
        register_forward(FM_PrecacheSound, "fw_PrecacheSound")
}

public fw_PrecacheModel(const Model[])
{
        new Precached = 0
       
        for(new i = 0; i < ArraySize(ArModel); i++)
        {
                ArrayGetString(ArModel, i, TempData, sizeof(TempData))
                if(equal(TempData, Model)) { Precached = 1; break; }
        }
       
        if(!Precached) ArrayPushString(ArModel, Model)
}

public fw_PrecacheSound(const Sound[])
{
        if(Sound == 'h' && Sound == 'o')
                return FMRES_SUPERCEDE
        for(new i = 0; i < sizeof(UnPrecache_SoundList); i++)
        {
                if(equal(Sound, UnPrecache_SoundList))
                        return FMRES_SUPERCEDE
        }
               
        new Precached = 0
       
        for(new i = 0; i < ArraySize(ArSound); i++)
        {
                ArrayGetString(ArSound, i, TempData, sizeof(TempData))
                if(equal(TempData, Sound)) { Precached = 1; break; }
        }
       
        if(!Precached) ArrayPushString(ArSound, Sound)
       
        return FMRES_HANDLED
}

Rulzy 发表于 2015-5-4 21:42:09

Good plugin. thanks!

xuwenqi 发表于 2015-5-5 01:17:35

很好,相关解决512限制的插件或模块已经有很多了{:4_128:}

Sneaky.amxx 发表于 2015-5-6 11:41:34

:)

q695290484 发表于 2015-5-12 19:42:14

i have't have any trouble with 512 limitation yet
but ... ... gj & nice code :P

css 发表于 2015-5-16 15:31:20

关注一下啊,不知道中用吗

ttbs123 发表于 2015-5-16 18:18:09

Rulzy 发表于 2015-5-4 21:42
Good plugin. thanks!

R大大,能不能利用mem_patch制作一个突破512资源限制的插件呢?

Sneaky.amxx 发表于 2015-5-16 21:15:17

q695290484 发表于 2015-5-12 19:42
i have't have any trouble with 512 limitation yet
but ... ... gj & nice code :P

I've been developing HUGE gameplay plugins.. and i've came across this problem.. so this is my fix for it.. and i've posted it so any other big developers can use it.

Sneaky.amxx 发表于 2015-5-16 21:15:52

ttbs123 发表于 2015-5-16 18:18
R大大,能不能利用mem_patch制作一个突破512资源限制的插件呢?

I'm not sure what you're asking.. sorry my Chinese is not so good.
This plugin allows you to go over the 512 precache file limit.

ttbs123 发表于 2015-5-19 12:15:16

Sneaky.amxx 发表于 2015-5-16 21:15
I'm not sure what you're asking.. sorry my Chinese is not so good.
This plugin allows you to go o ...

大师,我的英文也是not good{:4_100:}
页: [1] 2
查看完整版本: Precache Manager / Precache file limit FIX