Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

OnPlayerDisconnect/Connect - Array index out of bounds

$
0
0
I'm getting errors in my console when the player dis/connect and i can't figure out why this happens.
This is the printed errors:

Code:

[17:10:39] [debug] Run time error 4: "Array index out of bounds"
[17:10:39] [debug] AMX backtrace:
[17:10:39] [debug] #0 00084cec in public _y_utils_OnPlayerDisconnect (playerid=0, reason=1) at C:\Users\_oMa37\Desktop\San Andreas Wars\gamemodes\SA-Wars.pwn:2134
[17:10:39] [debug] #1 00040230 in public SSCANF_OnPlayerDisconnect (playerid=0, reason=1) at C:\Users\_oMa37\Desktop\San Andreas Wars\pawno\include\YSI\..\YSI_Data\..\YSI_Internal\..\YSI_Core\y_utils.inc:254
[17:10:39] [debug] #2 00032300 in public ac_OnPlayerDisconnect (playerid=0, reason=1) at C:\Users\_oMa37\Desktop\San Andreas Wars\pawno\include\sscanf2.inc:260
[17:10:39] [debug] #3 0000b6c4 in public Streamer_OnPlayerDisconnect (playerid=0, reason=1) at C:\Users\_oMa37\Desktop\San Andreas Wars\pawno\include\nex-ac.inc:2148
[17:10:39] [debug] #4 00000788 in OnPlayerDisconnect (playerid=0, reason=1, ... <1073741821 arguments>) at C:\Users\_oMa37\Desktop\San Andreas Wars\pawno\include\streamer.inc:325
[17:10:39] [debug] #5 00041930 in public OnPlayerDisconnect (... <2 arguments>) at C:\Users\_oMa37\Desktop\San Andreas Wars\pawno\include\YSI\..\YSI_Data\..\YSI_Coding\..\YSI_Internal\y_cgen.inc:30

And when i connect back:

Code:

[17:11:15] [debug] Run time error 4: "Array index out of bounds"
[17:11:15] [debug] AMX backtrace:
[17:11:15] [debug] #0 00082240 in public Hook_OnPlayerConnect (playerid=0) at C:\Users\_oMa37\Desktop\San Andreas Wars\gamemodes\SA-Wars.pwn:1970
[17:11:15] [debug] #1 native CallLocalFunction () from samp-server.exe
[17:11:15] [debug] #2 00078940 in public _y_utils_OnPlayerConnect (playerid=0) at C:\Users\_oMa37\Desktop\San Andreas Wars\pawno\include\antiafk.inc:101
[17:11:15] [debug] #3 000401a0 in public SSCANF_OnPlayerConnect (playerid=0) at C:\Users\_oMa37\Desktop\San Andreas Wars\pawno\include\YSI\..\YSI_Data\..\YSI_Internal\..\YSI_Core\y_utils.inc:234
[17:11:15] [debug] #4 000322b4 in public ac_OnPlayerConnect (playerid=0) at C:\Users\_oMa37\Desktop\San Andreas Wars\pawno\include\sscanf2.inc:236
[17:11:15] [debug] #5 0000ac7c in public Streamer_OnPlayerConnect (playerid=0) at C:\Users\_oMa37\Desktop\San Andreas Wars\pawno\include\nex-ac.inc:2093
[17:11:15] [debug] #6 00000710 in OnPlayerConnect (playerid=0, ... <1073741822 arguments>) at C:\Users\_oMa37\Desktop\San Andreas Wars\pawno\include\streamer.inc:305
[17:11:15] [debug] #7 00041844 in public OnPlayerConnect (... <1 argument>) at C:\Users\_oMa37\Desktop\San Andreas Wars\pawno\include\YSI\..\YSI_Data\..\YSI_Coding\..\YSI_Internal\y_cgen.inc:30

There is my OnPlayerConnect/Disconnect:

PHP Code:

public OnPlayerConnect(playerid)
{
new 
pname[MAX_PLAYER_NAME], string[128];
    
GetPlayerName(playeridpnamesizeof(pname));
    
format(stringsizeof(string), "%s has joined the server"pname);
    
SendClientMessageToAll(0x999999FFstring);
     
PlayAudioStreamForPlayer(playerid"http://k003.kiwi6.com/hotlink/rx3og20szd/SA-Wars.mp3");

    
SetPVarInt(playerid"SelectedObject",-1);
    
SetPVarString(playerid"SettingTxt""Click_to_set");
    
SetPVarString(playerid"SettingTxd""Click_to_set");
    
SetPVarInt(playerid"SettingIdx"0);
    
SetPVarInt(playerid"SettingModel"11111);
    
ObjTextdraw[playerid] = PlayerText:INVALID_TEXT_DRAW;
    for(new 
0sizeof(objinfo[]); ++) objinfo[playerid][i] = PlayerText:INVALID_TEXT_DRAW;

    
//Map Icons
     
SetPlayerMapIcon(playerid12516.1040, -1674.623013.9011620MAPICON_LOCAL); // Grove
     
SetPlayerMapIcon(playerid22169.1062, -1674.524515.0859590MAPICON_LOCAL); // Ballas
     
SetPlayerMapIcon(playerid3, -2153.4622642.978752.3672430MAPICON_LOCAL); // Triads
     
SetPlayerMapIcon(playerid41552.5533, -1675.595116.1953300MAPICON_LOCAL); // Police
     
SetPlayerMapIcon(playerid51953.0042, -2035.991613.5469580MAPICON_LOCAL); // Aztecas
     
SetPlayerMapIcon(playerid6, -1694.06811323.34317.1745610MAPICON_LOCAL); // Rifa
     
SetPlayerMapIcon(playerid72352.0703, -1165.595827.4588600MAPICON_LOCAL); // Vagos
    
SetPlayerMapIcon(playerid82635.48122345.118410.6719520MAPICON_LOCAL); // Bikers

    
new playaname[MAX_PLAYER_NAME], query[128];
    
GetPlayerName(playeridplayanamesizeof(playaname));
    
mysql_format(mysqlquerysizeof(query), "SELECT Password, ID FROM playerdata WHERE PlayerName = '%e' LIMIT 1"playaname);
    
mysql_tquery(mysqlquery"OnAccountCheck""i"playerid);
    for(new  
0<= 100i++) SCM(playerid, -1"");
    return 
1;


PHP Code:

public OnPlayerDisconnect(playeridreason)
{
    new 
query[520];
    
mysql_format(mysqlquerysizeof(query), "UPDATE playerdata SET Level = '%d', Money = '%d', Kills = '%d', Deaths = '%d', Hours = '%d', Minutes = '%d', Seconds = '%d', Marijuana = '%d', Cocaine = '%d', \
    Premium = '%d', xLevel = '%d', XP = '%d', WantedLevel = '%d', Muted = '%d', Jailed = '%d', Hitman = '%d', ColoredText = '%x', ColoredName = '%x', MapHide = '%x', Skin = '%d'  WHERE ID = '%d'"
,
    
Info[playerid][Level], GetPlayerMoney(playerid), Info[playerid][Kills], Info[playerid][Deaths], Info[playerid][Hours], Info[playerid][Minutes], Info[playerid][Seconds],
    
Info[playerid][Marijuana], Info[playerid][Cocaine], Info[playerid][Premium], Info[playerid][xLevel], Info[playerid][XP], GetPlayerWantedLevel(playerid), Info[playerid][Muted], Info[playerid][Jailed],
    
Info[playerid][Hitman], Info[playerid][ColoredText] >>> 8GetPlayerColor(playerid) >>> 8Info[playerid][MapHide], GetPlayerSkin(playerid), Info[playerid][ID]);
    
mysql_tquery(mysqlquery);

    
OnObjectEditMode(playerid,false);
    
PlayerTextDrawDestroy(playeridTextdraw2);
    
PlayerTextDrawDestroy(playeridTextdraw3);
    
TextDrawHideForPlayer(playeridServerTime);

    
OnEvent[playerid] = 0;
    
Headshoot[playerid] = 0;
    
Info[playerid][InDM] = 0;
    
Info[playerid][DMZone] = 0;
    
GotJetpack[playerid] = 0;
    
Died[playerid] = 0;
    
KilledBy[playerid] = 0;
    
MaterialApplied[playerid] = 0;

    if(
gTeam[playerid])
    {
        
gTeamCount[gTeam[playerid]] --;
        
UpdateTeamLabel(gTeam[playerid]);
    }

    if(
Info[playerid][SpawnedCars] > 0)
    {
       for(new 
i=0i<Info[playerid][SpawnedCars]; i++)
       {
           
DestroyVehicle(Info[playerid][Cars][i]);
       }
       
Info[playerid][SpawnedCars] = 0;
    }
    for(new 
VehicleIDVehicleID MAX_VEHICLESVehicleID++)
    {
      if(
VehicleIsLocked[VehicleID] == && VehicleLockedBy[VehicleID] == playerid)
        {
          
VehicleIsLocked[VehicleID] = 0;
          
VehicleLockedBy[VehicleID] = 0;
        }
    }
    new 
string[39 MAX_PLAYER_NAME];
    new 
pname[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,pname,sizeof(pname));
    switch(
reason)
    {
        case 
0format(stringsizeof(string), "%s has left the server [Timeout]"pname);
        case 
1format(stringsizeof(string), "%s has left the server"pname);
        case 
2format(stringsizeof(string), "%s has left the server [Kicked]"pname);
    }
    
SendClientMessageToAll(0x999999FFstring);
    return 
1;


Anyone know why this keeps happens?
Thanks in advance.

Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>