AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Run Time Error 4 - Not sure why... (https://forums.alliedmods.net/showthread.php?t=19482)

nanbread 10-17-2005 20:24

Run Time Error 4 - Not sure why...
 
Could some one explain why this is giving me:

Quote:

L 10/17/2005 - 18:14:20: [AMXX] Displaying debug trace (plugin "plugin_blatt_monster.amxx")
L 10/17/2005 - 18:14:20: [AMXX] Run time error 4: index out of bounds
L 10/17/2005 - 18:14:20: [AMXX] [0] phppwRw9w.sma::ManiaSpawn (line 575)
L 10/17/2005 - 18:14:20: [AMXX] [1] phppwRw9w.sma::ManiaTimer (line 566)
It's part of the plugin_blatt_monster.amxx plugin.

Code:

        new players[32]
        new chPl[2],num,pName[32]
        get_players(players,num,"ae","CT")
        chPl[0] = players[random(num)]  //this line causes the error (line 575)
        get_players(players,num,"ae","TERRORIST")
        chPl[1] = players[random(num)]

Help is appreciated.

geekforce 10-22-2005 14:02

index out of bounds mean that the number inside the [] of an array exceeds the max number..

Code:

new Array[32]

Array[0] = 1 //works
Array[31] = 1 //works too
Array[32] = 1 // error.. out fo bounds.. why?: new Array[32] initializes an array with 32 elements.. starting from 0 and up to 31...
//so make sure that the number doesnt exceed the max number :P

Hope you understand now.. :P

*still pretty unstable with pawn/small... just know general coding stuff :P (wrote it to show you what i was meaning.. kinda.. meh :P)

-- GeekFOrce


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

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