AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   (OLD) Bug Reports (https://forums.alliedmods.net/forumdisplay.php?f=24)
-   -   [REQ] Automatic precaching (speech.ini) (https://forums.alliedmods.net/showthread.php?t=50743)

Arkshine 02-02-2007 23:05

[REQ] Automatic precaching (speech.ini)
 
Another request. :)

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

Thanks. :wink:

ConnorMcLeod 02-03-2007 11:00

Re: [REQ] Automatic precaching (speech.ini)
 
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.

BAILOPAN 02-03-2007 22:27

Re: [REQ] Automatic precaching (speech.ini)
 
I don't understand this request. The sounds are played client-side.

VEN 02-04-2007 02:42

Re: [REQ] Automatic precaching (speech.ini)
 
I believe that they want to add a custom sounds to the config.

BAILOPAN 02-04-2007 03:26

Re: [REQ] Automatic precaching (speech.ini)
 
Why can't they just do that by editing the file then?

VEN 02-04-2007 04:40

Re: [REQ] Automatic precaching (speech.ini)
 
They want it to be precached to upload to the clients i believe.

ConnorMcLeod 02-04-2007 05:09

Re: [REQ] Automatic precaching (speech.ini)
 
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 ;)

sawce 02-05-2007 02:28

Re: [REQ] Automatic precaching (speech.ini)
 
I will add this, but I'm thinking the define should be turned off by default.

ConnorMcLeod 02-05-2007 18:32

Re: [REQ] Automatic precaching (speech.ini)
 
That's fine :)


All times are GMT -4. The time now is 23:58.

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