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

[REQ] Automatic precaching (speech.ini)


  
 
 
Thread Tools Display Modes
Author Message
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-02-2007 , 23:05   [REQ] Automatic precaching (speech.ini)
#1

Another request.

Is it possible to add an automatic precaching for the speech.ini file like in Amx, please ?

Thanks.
__________________
Arkshine is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-03-2007 , 11:00   Re: [REQ] Automatic precaching (speech.ini)
#2

Yes, with a define at the beginning of .sma :

#define AUTOMATIC_PRECACHE

so with commenting it we can load a no_precache_cmdmenu.amxx on some maps

and the same for miscstats.amxx please.
ConnorMcLeod is offline
BAILOPAN
Join Date: Jan 2004
Old 02-03-2007 , 22:27   Re: [REQ] Automatic precaching (speech.ini)
#3

I don't understand this request. The sounds are played client-side.
__________________
egg
BAILOPAN is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 02-04-2007 , 02:42   Re: [REQ] Automatic precaching (speech.ini)
#4

I believe that they want to add a custom sounds to the config.
VEN is offline
BAILOPAN
Join Date: Jan 2004
Old 02-04-2007 , 03:26   Re: [REQ] Automatic precaching (speech.ini)
#5

Why can't they just do that by editing the file then?
__________________
egg
BAILOPAN is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 02-04-2007 , 04:40   Re: [REQ] Automatic precaching (speech.ini)
#6

They want it to be precached to upload to the clients i believe.
VEN is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-04-2007 , 05:09   Re: [REQ] Automatic precaching (speech.ini)
#7

amx2006.3 miscstats.sma
Code:
public plugin_precache() {
  new filename[64]
  build_path(filename, 63, "$configdir/stats.ini")
  if(file_exists(filename)) {
    new text[256], name[32]
    new len, pos = 0, xid
    while((pos = read_file(filename, pos, text, 255, len))) {
      if(text[0] == ';' || !len) continue // line is a comment
      parse(text, name, 31)
      if((xid = get_xvar_id(name)) != -1)
        set_xvar_num(xid, 1)
    }
  }
#if defined AUTOMATIC_PRECACHING
  if(MultiKillSound || KillingStreakSound) {
    for(new i = 0; i < 7; i++)
      precache_sound_custom(g_Sounds[i])
  }
  if(BombPlantedSound) {
    precache_sound_custom("djeyl/c4powa")
  }
  if(BombDefusedSound) {
    precache_sound_custom("djeyl/laugh")
  }
  if(BombFailedSound || GrenadeSuicideSound) {
    precache_sound_custom("djeyl/witch")
  }
  if(LastManSound) {
    precache_sound_custom("misc/maytheforce")
    precache_sound_custom("misc/oneandonly")
  }
  if(KnifeKillSound) {
    precache_sound_custom("misc/humiliation")
  }
  if(GrenadeKillSound) {
    precache_sound_custom("djeyl/grenade")
  }
  if(HeadShotKillSound) {
    precache_sound_custom("misc/headshot")
  }
  if(RoundCounterSound) {
    precache_sound_custom("misc/prepare")
  }
  if(DoubleKillSound) {
    precache_sound_custom("misc/doublekill")
  }
  if(FirstBloodSound) {
    precache_sound_custom("misc/firstblood")
  }
#endif
}

#if defined AUTOMATIC_PRECACHING
new g_precSoundCust[64]
public precache_sound_custom(sound[]) {
  format(g_precSoundCust, 63, "sound/%s.wav", sound)
  if(file_exists(g_precSoundCust)) {
    replace(g_precSoundCust, 63, "sound/", "")
    precache_sound(g_precSoundCust)
  }
}
#endif
amx2006.3 cmdmenu.sma :
Code:
#if defined AUTOMATIC_PRECACHING
public plugin_precache() {
  new szFilename[64]
  build_path(szFilename, 63, "$configdir/speech.ini")
  if(!file_exists(szFilename))
    return 0

  new text[256], szName[32], szSound[128], szFlags[32], szAccess[32]
  new num = 0, a, pos = 0
  new ext[5]
  new arg1[32], arg2[64], arg3[64]
  
  while(num < MAX_CMDS && (pos = read_file(szFilename, pos, text, 255, a))) {
    if(!a || text[0] == ';' || text[0] == '/') continue

    if(parse(text, szName, 31, szSound, 127, szFlags, 31, szAccess, 31) > 3) {
      new parsedNums = parse(szSound, arg1, 31, arg2, 63, arg3, 63)
      if(parsedNums == 2 && equali(arg1, "spk")) {
        copy(szSound, 127, arg2)
        copy(ext, 4, ".wav")
      }
      else if(parsedNums == 3 && equali(arg1, "mp3") && (equali(arg2, "play") || equali(arg2, "loop"))) {
        copy(szSound, 127, arg3)
        copy(ext, 4, ".mp3")
      }
      else continue

      replace_all(szSound, 127, "\'", "")

      if(szSound[0] == '/') replace(szSound, 127, "/", "")

      if(ext[1] == 'm' || (!equali(szSound, "vox", 3) && !equali(szSound, "barney", 6) && !equali(szSound, "hgrunt", 6))) {
        new len = strlen(szSound)
        if(len > 3 && !equali(szSound[len-4], ext)) add(szSound, 127, ext)
        if(ext[1] == 'w') format(szSound, 127, "sound/%s", szSound)
        if(file_exists(szSound)) {
          if(ext[1] == 'm') {
            precache_generic(szSound)
          }
          else {
            replace(szSound, 127, "sound/", "")
            precache_sound(szSound)
          }
        }
      }
      num++
    }
  }
  return 0
}
#endif
That's exactly what we want, let the #define commented by defaut if you think it's better ;)
ConnorMcLeod is offline
sawce
The null pointer exception error and virtual machine bug
Join Date: Oct 2004
Old 02-05-2007 , 02:28   Re: [REQ] Automatic precaching (speech.ini)
#8

I will add this, but I'm thinking the define should be turned off by default.
__________________
fyren sucks
sawce is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-05-2007 , 18:32   Re: [REQ] Automatic precaching (speech.ini)
#9

That's fine
ConnorMcLeod is offline
 



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 01:00.


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