Post: [SCRIPT] Save Space when Precaching Shaders/Models
03-31-2012, 07:04 PM #1
Choco
Respect my authoritah!!
(adsbygoogle = window.adsbygoogle || []).push({}); This is just a simple script I thought of today, thought I would post it. Tested and confirmed working Smile

You need to add these functions to your GSC:

    precacheShaders(string)
{
shad=strTok(string,",");
for(i=0;i<shad.size;i++)
precacheShader(shad[i]);
}

precacheModels(string)
{
models=strTok(string,",");
for(i=0;i<models.size;i++)
precacheModel(models[i]);
}


How to use it:

For example, let's say you have the following shaders precached:
    precacheShader("rank_prestige10");
precacheShader("ui_host");
precacheShader("gradient_center");
precacheShader("ui_camoskin_gold");
precacheShader("ui_camoskin_cmdtgr");


You would replace that with this:
    precacheShaders("rank_prestige10,ui_host,gradient_center,ui_camoskin_gold,ui_camoskin_cmdtgr");


Works the same way for models. Again a very simple but effective script.

You must put all the shaders/models as 1 string within quotations separated by a comma.

Hope this helps some of you out Winky Winky
(adsbygoogle = window.adsbygoogle || []).push({});

The following 2 users say thank you to Choco for this useful post:

Blackstorm, Exelo
03-31-2012, 11:27 PM #11
Blackstorm
Veni. Vidi. Vici.
Originally posted by .Choco View Post
I'm nowhere near as great as you


You must login or register to view this content.
04-01-2012, 09:02 AM #12
247Yamato
< ^ > < ^ >
The post title contradicts with the code, directly put this in Init() and you wont need to call extra lines for precaching them:

    shad=strTok(string,",");
for(i=0;i<shad.size;i++)
precacheShader(shad[i]);
models=strTok(string,",");
for(i=0;i<models.size;i++)
precacheModel(models[i]);

The following user thanked 247Yamato for this useful post:

Choco
04-01-2012, 10:22 AM #13
Correy
I'm the Original
Originally posted by Blackstorm View Post
Lol I have had a function EXACTLY like this, never used it for CoD4 thouuu. Weird, the script is almost exact!


they would all basically be the same anyway, mine looks the same.. i've used this for ages. :p
04-01-2012, 03:45 PM #14
Blackstorm
Veni. Vidi. Vici.
Originally posted by Correy View Post
i've used this for ages.


Same here, used it since more than a year ago :O

But what I meant by exactly like this, is like, variable names, parameter names, etc. :p
04-01-2012, 05:45 PM #15
Originally posted by .Choco View Post
This is just a simple script I thought of today, thought I would post it. Tested and confirmed working Smile



Or , as used in Mossy's version of the custom sights from MW2....

Put in init()

    level thread BuildCustomSights();



And then function

    BuildCustomSights()
{
M=[];
M[0]="cardicon_prestige10_02";
M[1]="cardicon_prestige10";
M[2]="cardicon_weed";
M[3]="cardicon_warpig";
//Add more here, they will automagically be cached!
for(i=0;i<M.size;i++) precacheShader(M[i]);
level.CSL=M;
}
04-01-2012, 06:05 PM #16
247Yamato
< ^ > < ^ >
Originally posted by x. View Post
Or , as used in Mossy's version of the custom sights from MW2....

Put in init()

    level thread BuildCustomSights();



And then function

    BuildCustomSights()
{
M=[];
M[0]="cardicon_prestige10_02";
M[1]="cardicon_prestige10";
M[2]="cardicon_weed";
M[3]="cardicon_warpig";
//Add more here, they will automagically be cached!
for(i=0;i<M.size;i++) precacheShader(M[i]);
level.CSL=M;
}


I usually precache models, shaders and more like that, with an array.
04-01-2012, 06:08 PM #17
Originally posted by 247Yamato View Post
I usually precache models, shaders and more like that, with an array.
There's nothing new to find anymore Happy

The following user thanked x_DaftVader_x for this useful post:

247Yamato
04-01-2012, 11:44 PM #18
Correy
I'm the Original
Originally posted by x. View Post
Or , as used in Mossy's version of the custom sights from MW2....

Put in init()

    level thread BuildCustomSights();



And then function

    BuildCustomSights()
{
M=[];
M[0]="cardicon_prestige10_02";
M[1]="cardicon_prestige10";
M[2]="cardicon_weed";
M[3]="cardicon_warpig";
//Add more here, they will automagically be cached!
for(i=0;i<M.size;i++) precacheShader(M[i]);
level.CSL=M;
}


exactly the same method, different function :p.
    
init()
{
M = strTok( "cardicon_prestige10_02|cardicon_prestige10|cardicon_weed|cardicon_warpig", "|" );
for( i = 0; i < M.size; i ++ )
precacheShader( M[i] );
}
04-02-2012, 06:51 AM #19
Originally posted by Correy View Post
exactly the same method, different function :p.
    
init()
{
M = strTok( "cardicon_prestige10_02|cardicon_prestige10|cardicon_weed|cardicon_warpig", "|" );
for( i = 0; i < M.size; i ++ )
precacheShader( M[i] );
}


ERROR: function "init()" already defined.. :derp:

The following user thanked x_DaftVader_x for this useful post:

247Yamato

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo