OnPlayerSpawn Array index of Bounds
#1

[18:00:10] [debug] Run time error 4: "Array index out of bounds"
[18:00:10] [debug] Accessing element at index 193 past array upper bound 13
[18:00:10] [debug] AMX backtrace:
[18:00:10] [debug] #0 000c0c58 in ?? (0) from ESS2.amx
[18:00:10] [debug] #1 0002297c in public OnPlayerSpawn (0) from ESS2.amx


Player Spawns only here
https://www.imgx.ro/view.php?id=243752



public OnPlayerSpawn(playerid)
{
ShowZonesForPlayer(playerid); God_Mode_Verify(playerid);
SetPlayerInterior(playerid, 0); SetPlayerSpecialAction(playerid, 0);
SetPlayerVirtualWorld(playerid, 0); SavePlayer(playerid);
CosminInfo[playerid][AFKBRB] = 0; CosminInfo[playerid][Spawned] = 1;
TextDrawHideForPlayer(playerid,BRB[0]);
ConnectTDHide(playerid);
PlayerPlaySound(playerid, 1063, 0.0, 0.0, 0.0);
if(CosminInfo[playerid][HideTDS] == 0) TextDrawShowForPlayer(playerid, WES_TD[0]), TextDrawShowForPlayer(playerid, WES_TD[1]), TextDrawShowForPlayer(playerid, WES_TD[2]), TextDrawShowForPlayer(playerid, WES_TD[3]), TextDrawShowForPlayer(playerid, WES_TD[4]), TextDrawShowForPlayer(playerid, WES_TD[5]), TextDrawShowForPlayer(playerid, liTeleTD); //TextDrawShowForPlayer(playerid, Pont[0]), TextDrawShowForPlayer(playerid, Pont[1]), TextDrawShowForPlayer(playerid, Pont[2]);
//--------------------------------------------------------------------------
SetPlayerCheckpoint(playerid, 1319.1544,1249.3938,10.8203, 2.0);
//--------------------------------------------------------------------------
switch(CosminInfo[playerid][Language])
{
case 0: PlayerTextDrawShow(playerid, Random_TD_Texts);
case 1: PlayerTextDrawShow(playerid, Random_TD_Texts_RO);
}
//--------------------------------------------------------------------------
if(ClanInfo[CosminInfo[playerid][ClanID]][SpawnX] != 0)
{
SetPlayerPos(playerid, ClanInfo[CosminInfo[playerid][ClanID]][SpawnX], ClanInfo[CosminInfo[playerid][ClanID]][SpawnY], ClanInfo[CosminInfo[playerid][ClanID]][SpawnZ]);
SetPlayerFacingAngle(playerid, ClanInfo[CosminInfo[playerid][ClanID]][SpawnA]);
}
//--------------------------------------------------------------------------
if(ClanInfo[CosminInfo[playerid][ClanID]][SpawnX] == 0)
{
new rSpawn = random(; switch(rSpawn)
{
case 0: SetPlayerPos(playerid, -70.0371,2502.8616,16.6314 ); // AA
case 1: SetPlayerPos(playerid, 1942.1929,-2383.1050,13.6628 ); // LSAir
case 2: SetPlayerPos(playerid, -1369.4698,-478.3749,14.2305 ); // SFAir
case 3: SetPlayerPos(playerid, 1315.9774,1277.6951,10.8203 ); // LVAir
case 4: SetPlayerPos(playerid, -2340.3953,-1602.7417,483.7599 ); // Chilliad
case 5: SetPlayerPos(playerid, 1420.3746,2773.9958,11.0972 ); // Stunt Golf
case 6: SetPlayerPos(playerid, -2227.6587,2326.2891,7.5894 ); // Pimps
case 7: SetPlayerPos(playerid, -2639.6819,1356.3484,7.1629 ); // Jizzy's
case 8: SetPlayerPos(playerid, 356.9382,-1840.1594,3.7349 ); // Beach
}
}
//--------------------------------------------------------------------------
if(CosminInfo[playerid][Jailed] != 0)
{
SendClientMessage(playerid, COLOR_ULTRARED, "You cannot escape from Jail! You have to wait a few minutes.");
SetTimerEx("Jailing", 1000, 0, "i", playerid);
}
//--------------------------------------------------------------------------
mysql_tquery(DB_Connect, "SELECT * FROM `Clans`", "LoadClans", "");
//--------------------------------------------------------------------------
if(CosminInfo[playerid][GangID] != 0)
{
SetupPlayerForGang(playerid, CosminInfo[playerid][GangID]);
}
//--------------------------------------------------------------------------
if(CosminInfo[playerid][ClanID] != 0)
{
SetupPlayerForClan(playerid, CosminInfo[playerid][ClanID]);
}
//--------------------------------------------------------------------------
CheckDMInfo(playerid); SetPlayerScore(playerid, GiveNote(playerid));
//--------------------------------------------------------------------------
return 1;
}
Reply
#2

A more readable version of this, i'll edit my comment soon.

Код:
[18:00:10] [debug] Run time error 4: "Array index out of bounds"
[18:00:10] [debug] Accessing element at index 193 past array upper bound 13
[18:00:10] [debug] AMX backtrace:
[18:00:10] [debug] #0 000c0c58 in ?? (0) from ESS2.amx
[18:00:10] [debug] #1 0002297c in public OnPlayerSpawn (0) from ESS2.amx
PHP код:
public OnPlayerSpawn(playerid)
{
    
ShowZonesForPlayer(playerid); 
    
God_Mode_Verify(playerid);
    
SetPlayerInterior(playerid0); 
    
SetPlayerSpecialAction(playerid0);
    
SetPlayerVirtualWorld(playerid0); 
    
SavePlayer(playerid);
    
CosminInfo[playerid][AFKBRB] = 0
    
CosminInfo[playerid][Spawned] = 1;
    
TextDrawHideForPlayer(playerid,BRB[0]);
    
ConnectTDHide(playerid);
    
PlayerPlaySound(playerid10630.00.00.0);
    if(
CosminInfo[playerid][HideTDS] == 0
        
TextDrawShowForPlayer(playeridWES_TD[0]), 
        
TextDrawShowForPlayer(playeridWES_TD[1]), 
        
TextDrawShowForPlayer(playeridWES_TD[2]), 
        
TextDrawShowForPlayer(playeridWES_TD[3]), 
        
TextDrawShowForPlayer(playeridWES_TD[4]), 
        
TextDrawShowForPlayer(playeridWES_TD[5]), 
        
TextDrawShowForPlayer(playeridliTeleTD); 
        
//TextDrawShowForPlayer(playerid, Pont[0]), TextDrawShowForPlayer(playerid, Pont[1]), TextDrawShowForPlayer(playerid, Pont[2]);
    
    //--------------------------------------------------------------------------
    
SetPlayerCheckpoint(playerid1319.1544,1249.3938,10.82032.0);
    
//--------------------------------------------------------------------------
    
    
switch(CosminInfo[playerid][Language])
    {
        case 
0PlayerTextDrawShow(playeridRandom_TD_Texts);
        case 
1PlayerTextDrawShow(playeridRandom_TD_Texts_RO);
    }
    
//--------------------------------------------------------------------------
    
    
if(ClanInfo[CosminInfo[playerid][ClanID]][SpawnX] != 0)
    {
        
SetPlayerPos(playeridClanInfo[CosminInfo[playerid][ClanID]][SpawnX], ClanInfo[CosminInfo[playerid][ClanID]][SpawnY], ClanInfo[CosminInfo[playerid][ClanID]][SpawnZ]);
        
SetPlayerFacingAngle(playeridClanInfo[CosminInfo[playerid][ClanID]][SpawnA]);
    }
    
//--------------------------------------------------------------------------
    
    
if(ClanInfo[CosminInfo[playerid][ClanID]][SpawnX] == 0)
    {
        new 
rSpawn random(; switch(rSpawn)
        {
            case 
0SetPlayerPos(playerid, -70.0371,2502.8616,16.6314 ); // AA
            
case 1SetPlayerPos(playerid1942.1929,-2383.1050,13.6628    ); // LSAir
            
case 2SetPlayerPos(playerid, -1369.4698,-478.3749,14.2305    ); // SFAir
            
case 3SetPlayerPos(playerid1315.9774,1277.6951,10.8203    ); // LVAir
            
case 4SetPlayerPos(playerid, -2340.3953,-1602.7417,483.7599 ); // Chilliad
            
case 5SetPlayerPos(playerid1420.3746,2773.9958,11.0972 ); // Stunt Golf
            
case 6SetPlayerPos(playerid, -2227.6587,2326.2891,7.5894 ); // Pimps
            
case 7SetPlayerPos(playerid, -2639.6819,1356.3484,7.1629 ); // Jizzy's
            
case 8SetPlayerPos(playerid356.9382,-1840.1594,3.7349 ); // Beach
        
}
    }
    
//--------------------------------------------------------------------------
    
    
if(CosminInfo[playerid][Jailed] != 0)
    {
        
SendClientMessage(playeridCOLOR_ULTRARED"You cannot escape from Jail! You have to wait a few minutes.");
        
SetTimerEx("Jailing"10000"i"playerid);
    }
   
    
//--------------------------------------------------------------------------
    
mysql_tquery(DB_Connect"SELECT * FROM `Clans`""LoadClans""");
    
//--------------------------------------------------------------------------
    
    
if(CosminInfo[playerid][GangID] != 0)
    {
        
SetupPlayerForGang(playeridCosminInfo[playerid][GangID]);
    }
    
//--------------------------------------------------------------------------
    
    
if(CosminInfo[playerid][ClanID] != 0)
    {
        
SetupPlayerForClan(playeridCosminInfo[playerid][ClanID]);
    }
    
    
//--------------------------------------------------------------------------
    
CheckDMInfo(playerid); 
    
SetPlayerScore(playeridGiveNote(playerid));
    
//--------------------------------------------------------------------------
    
return 1;

1- Indent your code
2- One function used per line
3- Show declarations for all the variables used in this public function.

I.e the variable ClanInfo and the enum used.
Reply
#3

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
A more readable version of this, i'll edit my comment soon.

Код:
[18:00:10] [debug] Run time error 4: "Array index out of bounds"
[18:00:10] [debug] Accessing element at index 193 past array upper bound 13
[18:00:10] [debug] AMX backtrace:
[18:00:10] [debug] #0 000c0c58 in ?? (0) from ESS2.amx
[18:00:10] [debug] #1 0002297c in public OnPlayerSpawn (0) from ESS2.amx
PHP код:
public OnPlayerSpawn(playerid)
{
    
ShowZonesForPlayer(playerid); 
    
God_Mode_Verify(playerid);
    
SetPlayerInterior(playerid0); 
    
SetPlayerSpecialAction(playerid0);
    
SetPlayerVirtualWorld(playerid0); 
    
SavePlayer(playerid);
    
CosminInfo[playerid][AFKBRB] = 0
    
CosminInfo[playerid][Spawned] = 1;
    
TextDrawHideForPlayer(playerid,BRB[0]);
    
ConnectTDHide(playerid);
    
PlayerPlaySound(playerid10630.00.00.0);
    if(
CosminInfo[playerid][HideTDS] == 0
        
TextDrawShowForPlayer(playeridWES_TD[0]), 
        
TextDrawShowForPlayer(playeridWES_TD[1]), 
        
TextDrawShowForPlayer(playeridWES_TD[2]), 
        
TextDrawShowForPlayer(playeridWES_TD[3]), 
        
TextDrawShowForPlayer(playeridWES_TD[4]), 
        
TextDrawShowForPlayer(playeridWES_TD[5]), 
        
TextDrawShowForPlayer(playeridliTeleTD); 
        
//TextDrawShowForPlayer(playerid, Pont[0]), TextDrawShowForPlayer(playerid, Pont[1]), TextDrawShowForPlayer(playerid, Pont[2]);
    
    //--------------------------------------------------------------------------
    
SetPlayerCheckpoint(playerid1319.1544,1249.3938,10.82032.0);
    
//--------------------------------------------------------------------------
    
    
switch(CosminInfo[playerid][Language])
    {
        case 
0PlayerTextDrawShow(playeridRandom_TD_Texts);
        case 
1PlayerTextDrawShow(playeridRandom_TD_Texts_RO);
    }
    
//--------------------------------------------------------------------------
    
    
if(ClanInfo[CosminInfo[playerid][ClanID]][SpawnX] != 0)
    {
        
SetPlayerPos(playeridClanInfo[CosminInfo[playerid][ClanID]][SpawnX], ClanInfo[CosminInfo[playerid][ClanID]][SpawnY], ClanInfo[CosminInfo[playerid][ClanID]][SpawnZ]);
        
SetPlayerFacingAngle(playeridClanInfo[CosminInfo[playerid][ClanID]][SpawnA]);
    }
    
//--------------------------------------------------------------------------
    
    
if(ClanInfo[CosminInfo[playerid][ClanID]][SpawnX] == 0)
    {
        new 
rSpawn random(; switch(rSpawn)
        {
            case 
0SetPlayerPos(playerid, -70.0371,2502.8616,16.6314 ); // AA
            
case 1SetPlayerPos(playerid1942.1929,-2383.1050,13.6628    ); // LSAir
            
case 2SetPlayerPos(playerid, -1369.4698,-478.3749,14.2305    ); // SFAir
            
case 3SetPlayerPos(playerid1315.9774,1277.6951,10.8203    ); // LVAir
            
case 4SetPlayerPos(playerid, -2340.3953,-1602.7417,483.7599 ); // Chilliad
            
case 5SetPlayerPos(playerid1420.3746,2773.9958,11.0972 ); // Stunt Golf
            
case 6SetPlayerPos(playerid, -2227.6587,2326.2891,7.5894 ); // Pimps
            
case 7SetPlayerPos(playerid, -2639.6819,1356.3484,7.1629 ); // Jizzy's
            
case 8SetPlayerPos(playerid356.9382,-1840.1594,3.7349 ); // Beach
        
}
    }
    
//--------------------------------------------------------------------------
    
    
if(CosminInfo[playerid][Jailed] != 0)
    {
        
SendClientMessage(playeridCOLOR_ULTRARED"You cannot escape from Jail! You have to wait a few minutes.");
        
SetTimerEx("Jailing"10000"i"playerid);
    }
   
    
//--------------------------------------------------------------------------
    
mysql_tquery(DB_Connect"SELECT * FROM `Clans`""LoadClans""");
    
//--------------------------------------------------------------------------
    
    
if(CosminInfo[playerid][GangID] != 0)
    {
        
SetupPlayerForGang(playeridCosminInfo[playerid][GangID]);
    }
    
//--------------------------------------------------------------------------
    
    
if(CosminInfo[playerid][ClanID] != 0)
    {
        
SetupPlayerForClan(playeridCosminInfo[playerid][ClanID]);
    }
    
    
//--------------------------------------------------------------------------
    
CheckDMInfo(playerid); 
    
SetPlayerScore(playeridGiveNote(playerid));
    
//--------------------------------------------------------------------------
    
return 1;

1- Indent your code
2- One function used per line
3- Show declarations for all the variables used in this public function.

I.e the variable ClanInfo and the enum used.
Does not work.


enum ClanData
{
Float:SpawnX, ClanName[30], Float:SpawnY, Float:SpawnZ, LeaderSkin, Skin, Name, Rank, Float:SpawnA,
Weap1, Weap2, Weap3, Weap4, Weap5, Weap6, Weap7, ClanColor, ID
};

new ClanInfo[MAX_CLANS][ClanData];

#define MAX_CLANS 1150
Reply
#4

Quote:
Originally Posted by Cezar98
Посмотреть сообщение
Does not work.


enum ClanData
{
Float:SpawnX, ClanName[30], Float:SpawnY, Float:SpawnZ, LeaderSkin, Skin, Name, Rank, Float:SpawnA,
Weap1, Weap2, Weap3, Weap4, Weap5, Weap6, Weap7, ClanColor, ID
};

new ClanInfo[MAX_CLANS][ClanData];

#define MAX_CLANS 1150
CosminInfo[playerid][ClanID] < Now show me this and it's variable/enum and what is it exactly supposed to return.
Reply
#5

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
CosminInfo[playerid][ClanID] < Now show me this and it's variable/enum and what is it exactly supposed to return.
CosminInfo[playerid][ClanID] = cache_get_field_content_int(0, "ClanID", DB_Connect);

if(CosminInfo[playerid][ClanID] > 0) return SendError(playerid, "You are not member of any clan");
Reply
#6

Quote:
Originally Posted by Cezar98
Посмотреть сообщение
CosminInfo[playerid][ClanID] = cache_get_field_content_int(0, "ClanID", DB_Connect);

if(CosminInfo[playerid][ClanID] > 0) return SendError(playerid, "You are not member of any clan");
I also asked what their delcaration was, second of all
PHP код:
if(CosminInfo[playerid][ClanID] > 0) return SendError(playerid"You are not member of any clan"); 
Doesn't make any sense. If it isn't supposed to be bigger than 0 then why is MAX_CLANS 1150 ???
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)