AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Runtime error 4: index out of bounds (https://forums.alliedmods.net/showthread.php?t=326531)

Abhinash 08-04-2020 16:35

Runtime error 4: index out of bounds
 
I am getting runtime error 4 on this simple part of code.
Can anyone help me to fix it ?
Code:

// Current Weapon info
public message_cur_weapon(id)
{
        // Not alive or zombie
        if (!g_isalive[id] || g_zombie[id])
                return;
       
        if (g_sniper[id])
                return;
       
        if (b_uAmmo[id])
        {
                // HUD should show full clip all the time
                set_msg_arg_int(3, get_msg_argtype(3), MAXCLIP[weapon])
        }
}

Error on this line : if (!g_isalive[id] || g_zombie[id])

OciXCrom 08-04-2020 16:57

Re: Runtime error 4: index out of bounds
 
Show how the two variables are defined.

fysiks 08-04-2020 22:49

Re: Runtime error 4: index out of bounds
 
Any time that you have an error like this you should add your own debugging code to determine the value being passed to the various arrays being used on or near the line that has the problem. It will often lead you to the answer. If you're going to be posting in the Scripting Help section, this should be your first step unless it is difficult to reproduce.

Abhinash 08-05-2020 03:49

Re: Runtime error 4: index out of bounds
 
Actually the message function required 3 parameters to run that's why


All times are GMT -4. The time now is 13:54.

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