Array Out of bounds problem
#1

Guys i have a hosted server so problem is my server getting auto-shutdown on 10 or 15 minutes always so i decide to put crash detect plugin so when i add the plugin in my server i got these messages

Код:
----------
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3z-R2, ©2005-2014 SA-MP Team

[18:18:59] 
[18:18:59] Server Plugins
[18:18:59] --------------
[18:18:59]  Loading plugin: streamer.dll
[18:18:59] 

*** Streamer Plugin v2.7.2 by Incognito loaded ***

[18:18:59]   Loaded.
[18:18:59]  Loading plugin: PointToPoint.dll
[18:18:59]  PointToPoint Plugin Loaded.
[18:18:59]   Loaded.
[18:18:59]  Loading plugin: MerRandom.dll
[18:18:59] Plugin MerRandom v2.1 - by Cyber_Punk got loaded.
[18:18:59]   Loaded.
[18:18:59]  Loading plugin: sscanf.dll
[18:18:59] 

[18:18:59]  ===============================

[18:18:59]       sscanf plugin loaded.     

[18:18:59]    © 2009 Alex "******" Cole

[18:18:59]    0.3d-R2 500 Players "dnee"

[18:18:59]  ===============================

[18:18:59]   Loaded.
[18:18:59]  Loading plugin: crashdetect.dll
[18:18:59]   CrashDetect v4.15.1 is OK.
[18:18:59]   Loaded.
[18:18:59]  Loaded 5 plugins.

[18:18:59] 
[18:18:59] Ban list
[18:18:59] --------
[18:18:59]  Loaded: samp.ban
[18:18:59] 
[18:18:59] 
[18:18:59] Filterscripts
[18:18:59] ---------------
[18:18:59]   Loading filterscript 'buildings.amx'...
[18:18:59]   Loading filterscript 'oupdates.amx'...
[18:18:59] OnFilter
[18:18:59]   Loading filterscript 'shamal2.amx'...
[18:18:59]   Loading filterscript 'ls_elevator2.amx'...
[18:18:59]   Loaded 4 filterscripts.

[18:18:59] SSCANF2 Loaded
[18:19:00] SSCANF2 Loaded
[18:19:00] Number of vehicle models: 119
[18:19:00] [debug] Run time error 4: "Array index out of bounds"
[18:19:00] [debug]  Accessing element at negative index -1
[18:19:00] [debug] AMX backtrace:
[18:19:00] [debug] #0 000091dc in public org_gatesF () from oupdates.amx
[18:19:01] [debug] Run time error 4: "Array index out of bounds"
[18:19:01] [debug]  Accessing element at negative index -1
[18:19:01] [debug] AMX backtrace:
[18:19:01] [debug] #0 000091dc in public org_gatesF () from oupdates.amx
and here is my code which have problem

pawn Код:
#define gates 20
new gateids[gates][2];
new gateopen[gates];
new gatetype[18];


public org_gatesF()
{
    new tvar, Float:z;

    for (new g = 0; g < gates; g++) {
        tvar = 0;
       
        if (g == 1 || g == 8 || gatetype[gateids[g][1]-1] != 1) continue;

        for (new i = 0; i < PLAYERS; i++) {
            if (IsPlayerConnected(i)) {

                if (GetPlayerState(i) == PLAYER_STATE_SPECTATING || GetPVarInt(i, "playerorg") != gateids[g][1]) continue;

                GetPlayerPos(i, z, z, z);

                if (g == 0)
                {
                    if (IsPlayerInAreaEx(i, 207.994, 1891.140, 219.605, 1891.136, 217.563, 1875.891, 217.563, 1865.891, 210.236, 1865.954, 210.236, 1875.954) && (z >= 12.141 && z <= 16.641))
                    {
                        if (gateopen[g] == 0)
                        {
                            StopObject(gateids[g][0]);
                            StopObject(gateids[1][0]);
                            MoveObject(gateids[g][0], 219.941, 1874.571, 13.903, 1.0);
                            MoveObject(gateids[1][0], 207.842, 1874.571, 13.903, 1.0);
                            gateopen[g] = 1;
                        }
                        tvar ++;
                    }
                }
                else if (g == 2)
                {
                    if (IsPlayerInAreaEx(i, 141.889, 1925.978, 141.889, 1955.978, 128.329, 1955.978, 128.329, 1925.978) && (z >= 18.312 && z <= 23.312))
                    {
                        if (gateopen[g] == 0)
                        {
                            StopObject(gateids[g][0]);
                            MoveObject(gateids[g][0], 123.412, 1941.522, 21.775, 1.7);
                            gateopen[g] = 1;
                        }
                        tvar ++;
                    }
                }
                else if (g == 3)
                {
                    if (IsPlayerInAreaEx(i, 270.275, 1827.311, 300.275, 1827.311, 300.275, 1815.416, 270.275, 1815.416) && (z >= 16.648 && z <= 21.648))
                    {
                        if (gateopen[g] == 0)
                        {
                            StopObject(gateids[g][0]);
                            MoveObject(gateids[g][0], 285.990, 1832.248, 20.095, 1.7);
                            gateopen[g] = 1;
                        }
                        tvar ++;
                    }
                }
                else if (g == 4)
                {
                    if (IsPlayerInAreaEx(i, 267.321, 1868.394, 270.033, 1868.394, 270.033, 1858.394, 267.321, 1858.394) && (z >= 7.757 && z <= 11.257))
                    {
                        if (gateopen[g] == 0)
                        {
                            StopObject(gateids[g][0]);
                            MoveObject(gateids[g][0], 268.66, 1864.059, 10.5, 0.6);
                            gateopen[g] = 1;
                        }
                        tvar ++;
                    }
                }
                else if (g == 5)
                {
                    if (IsPlayerInAreaEx(i, 2306.976, 2492.599, 2279.976, 2492.599, 2279.976, 2502.404, 2306.976, 2502.404) && (z >= 2.273 && z <= 9.613))
                    {
                        if (gateopen[g] == 0)
                        {
                            StopObject(gateids[g][0]);
                            MoveObject(gateids[g][0], 2293.83, 2498.804, 8.4414, 1.0);
                            gateopen[g] = 1;
                        }
                        tvar ++;
                    }
                }
                else if (g == 6)
                {
                    if (IsPlayerInAreaEx(i, 2351.216, 2432.937, 2340.626, 2429.053, 2319.332, 2440.480, 2319.314, 2452.331, 2346.757, 2455.847) && (z >= 2.273 && z <= 11.266))
                    {
                        if (gateopen[g] == 0)
                        {
                            StopObject(gateids[g][0]);
                            MoveObject(gateids[g][0], 2335.178, 2443.621, 10.9743, 1.0);
                            gateopen[g] = 1;
                        }
                        tvar ++;
                    }
                }
                else if (g == 7)
                {
                    if (IsPlayerInAreaEx(i, 2482.921, 2780.974, 2512.921, 2780.974, 2512.921, 2765.149, 2482.921, 2765.149) && (z >= 9.820 && z <= 14.820))
                    {
                        if (gateopen[g] == 0)
                        {
                            StopObject(gateids[g][0]);
                            StopObject(gateids[8][0]);
                            MoveObject(gateids[g][0], 2497.4063, 2782.5703, 11.5313, 1.2);
                            MoveObject(gateids[8][0], 2497.4063, 2763.6094, 11.5313, 1.2);
                            gateopen[g] = 1;
                        }
                        tvar ++;
                    }
                }
                else if (g == 9)
                {
                    if (IsPlayerInAreaEx(i, 1584.627, -1623.722, 1592.439, -1623.722, 1592.439, -1653.722, 1584.627, -1653.722) && (z >= 7.294 && z <= 17.382))
                    {
                        if (gateopen[g] == 0)
                        {
                            StopObject(gateids[g][0]);
                            MoveObject(gateids[g][0], 1595.503, -1637.872, 14.5641, 1.0);
                            gateopen[g] = 1;
                        }
                        tvar ++;
                    }
                }
                else if (g == 13)
                {
                    if(IsPlayerInRangeOfPoint(i, 10.0, -2175.9946,645.2326,49.4375) || IsPlayerInRangeOfPoint(i, 10.0, -2175.7043,651.1565,49.4375))
                    {
                        if (gateopen[g] == 0)
                        {
                            StopObject(gateids[g][0]);
                            MoveObject(gateids[g][0], -2167.6001000,647.7999900,51.8000000, 1.2);
                            gateopen[g] = 1;
                        }
                        tvar ++;
                    }
                }
                else if (g == 14)
                {
                   
                    if(IsPlayerInRangeOfPoint(i, 10.0, -2181.7979,708.0063,53.8906) || IsPlayerInRangeOfPoint(i, 10.0, -2181.6938,715.3218,53.8919))
                    {
                        if (gateopen[g] == 0)
                        {
                            StopObject(gateids[g][0]);
                            MoveObject(gateids[g][0], -2192.5000000,711.4000200,55.3000000, 1.2);
                            gateopen[g] = 1;
                        }
                        tvar ++;
                    }
                }

            }
        }

        if (tvar == 0)
        {
            if (gateopen[g] == 1)
            {
                if (g == 0)
                {
                    StopObject(gateids[g][0]);
                    StopObject(gateids[1][0]);
                    MoveObject(gateids[g][0], 215.941, 1874.571, 13.903, 1.0);
                    MoveObject(gateids[1][0], 211.842, 1874.571, 13.903, 1.0);
                }
                else if (g == 2)
                {
                    StopObject(gateids[g][0]);
                    MoveObject(gateids[g][0], 134.912, 1941.522, 21.775, 1.7);
                }
                else if (g == 3)
                {
                    StopObject(gateids[g][0]);
                    MoveObject(gateids[g][0], 285.990, 1822.312, 20.095, 1.7);
                }
                else if (g == 4)
                {
                    StopObject(gateids[g][0]);
                    MoveObject(gateids[g][0], 268.66, 1864.059, 7.5, 0.6);
                }
                else if (g == 5)
                {
                    StopObject(gateids[g][0]);
                    MoveObject(gateids[g][0], 2293.83, 2498.804, 4.4414, 1.0);
                }
                else if (g == 6)
                {
                    StopObject(gateids[g][0]);
                    MoveObject(gateids[g][0], 2335.178, 2443.621, 6.9743, 1.0);
                }
                else if (g == 7)
                {
                    StopObject(gateids[g][0]);
                    StopObject(gateids[8][0]);
                    MoveObject(gateids[g][0], 2497.4063, 2777.0703, 11.5313, 1.2);
                    MoveObject(gateids[8][0], 2497.4063, 2769.1094, 11.5313, 1.2);
                }
                else if (g == 9)
                {
                    StopObject(gateids[g][0]);
                    MoveObject(gateids[g][0], 1588.503, -1637.872, 14.5641, 1.0);
                }
                else if (g == 13)
                {
                    StopObject(gateids[g][0]);
                    MoveObject(gateids[g][0], -2175.5000000,647.9000200,51.8000000, 1.2);
                }
                else if (g == 14)
                {
                    StopObject(gateids[g][0]);
                    MoveObject(gateids[g][0], -2181.6001000,711.4000200,55.3000000, 1.2);
                }
                gateopen[g] = 0;
            }
        }
    }
}
can any one solve the problem and tell me what i have to do for fix of this please?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)