Raised This Month: $12 Target: $400
 3% 

Solved Precache Particle


Post New Thread Reply   
 
Thread Tools Display Modes
TitanTF
Senior Member
Join Date: Mar 2016
Location: Singapore
Old 05-26-2017 , 05:53   Re: Precache Particle
Reply With Quote #11

Quote:
Originally Posted by Pelipoika View Post
Can't do custom particles in TF2
then mapname_particles.txt is probably the only way then. thanks for the help guys
TitanTF is offline
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 05-26-2017 , 07:07   Re: Precache Particle
Reply With Quote #12

Quote:
Originally Posted by TitanTF View Post
then mapname_particles.txt is probably the only way then. thanks for the help guys
Be careful though, if the maps you are making a particles txt for are not yours, the map maker could ask you to take it down, also if some maps have already a particle text file, you can't use yours.
__________________

Last edited by Benoist3012; 05-26-2017 at 07:07.
Benoist3012 is offline
TitanTF
Senior Member
Join Date: Mar 2016
Location: Singapore
Old 05-26-2017 , 07:18   Re: Precache Particle
Reply With Quote #13

Quote:
Originally Posted by Benoist3012 View Post
Be careful though, if the maps you are making a particles txt for are not yours, the map maker could ask you to take it down, also if some maps have already a particle text file, you can't use yours.
crap.
TitanTF is offline
ph
AlliedModders Donor
Join Date: Mar 2006
Old 07-03-2020 , 22:15   Re: Precache Particle
Reply With Quote #14

Code:
stock int PrecacheParticleSystem(const char[] particleSystem)
{
    static int particleEffectNames = INVALID_STRING_TABLE;

    if (particleEffectNames == INVALID_STRING_TABLE) {
        if ((particleEffectNames = FindStringTable("ParticleEffectNames")) == INVALID_STRING_TABLE) {
            return INVALID_STRING_INDEX;
        }
    }

    int index = FindStringIndex2(particleEffectNames, particleSystem);
    if (index == INVALID_STRING_INDEX) {
        int numStrings = GetStringTableNumStrings(particleEffectNames);
        if (numStrings >= GetStringTableMaxStrings(particleEffectNames)) {
            return INVALID_STRING_INDEX;
        }
        
        AddToStringTable(particleEffectNames, particleSystem);
        index = numStrings;
    }
    
    return index;
}

stock int FindStringIndex2(int tableidx, const char[] str)
{
    char buf[1024];
    
    int numStrings = GetStringTableNumStrings(tableidx);
    for (int i=0; i < numStrings; i++) {
        ReadStringTable(tableidx, i, buf, sizeof(buf));
        
        if (StrEqual(buf, str)) {
            return i;
        }
    }
    
    return INVALID_STRING_INDEX;
}


I have compiled this script (as it is above) and running on my TF2 server.

Will I have any problems?
__________________

Last edited by ph; 07-03-2020 at 22:16.
ph is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:52.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode