AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Run time error 4: index out of bounds (https://forums.alliedmods.net/showthread.php?t=135536)

Vechta 08-17-2010 08:28

[HELP] Run time error 4: index out of bounds
 
Why this error comes?

Code:

L 08/18/2010 - 14:15:40: [AMXX] Displaying debug trace (plugin "zombie_plague40.amxx")
L 08/18/2010 - 14:15:40: [AMXX] Run time error 4: index out of bounds
L 08/18/2010 - 14:15:40: [AMXX]    [0] zombie_plague40.sma::countdown (line 11531)

Error line (line 11531):
Code:

        emit_sound( 0, CHAN_VOICE, speak[ countdown ], 1.0, ATTN_NORM, 0, PITCH_NORM )
complete countdown part:
Code:

public countdown(id)

        new speak[ 10 ][] = { "fvox/one.wav", "fvox/two.wav", "fvox/three.wav", "fvox/four.wav", "fvox/five.wav", "fvox/six.wav", "fvox/seven.wav", "fvox/eight.wav", "fvox/nine.wav", "fvox/ten.wav" }
   
        emit_sound( 0, CHAN_VOICE, speak[ countdown ], 1.0, ATTN_NORM, 0, PITCH_NORM )
        countdown--
   
        set_hudmessage(255, 255, 0, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10); 
        show_hudmessage(0, "Countdown ^nInfection in: %i", time_s); 
        --time_s;
   
        if(time_s >= 1)
        {
                set_task(1.0, "countdown", 0)
        }
}


Excalibur.007 08-17-2010 10:34

Re: [HELP] Run time error 4: index out of bounds
 
Since you are playing it to everybody, I would use
PHP Code:

client_cmd(0"mp3 sound file"

. If you have a WAV file, you can convert it into MP3 format file. This is a converter, Convert WAV to MP3

Good thing is MP3 is smaller than WAV with very little quality changes.

EDIT: Btw if you have a CVar remember to use return PLUGIN_HANDLED instead of return to prevent run time error 4.

RedRobster 08-17-2010 13:08

Re: [HELP] Run time error 4: index out of bounds
 
However, if you want to keep it in .wav, you can use client_cmd(0, "spk file name")

@Excalibur.007
fvox/one.wav, and the others are the included countdown file names. Not that easy to convert, or it is just a pain since everyone already has the files anyways.

And his runtime is that emit_sound() has to go from a real players id (I might be mistaken). It is meant so that if you are close enough to them, you can hear it. Like switching to a knife, turning on nightvision, etc. If I am right though, the runtime error is occuring because 0 is not a player's id.


All times are GMT -4. The time now is 22:00.

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