Szerző Téma: Eljárás crash  (Megtekintve 479 alkalommal)

Nem elérhető Gabor..

  • 1883
  • Gabor..
    • Profil megtekintése
Eljárás crash
« Dátum: 2012. November 10. - 22:01:39 »
0 Show voters
Sziasztok!
A fallout scriptembe van egy eljárás, ami ha meghívodik, ledobja(elvesz az object magassági pozíciójából) az objectet, és ha az összes object lent van, és még nem ért véget a menet, akkor döntetlent nyílvánít. Amikor ez lezajlik, akkor kifagy a szerver.
Itt a kód:
 

public FalloutDropObjects( )
{
if( GetGVarInt( \"FalloutStarted\" ) == 1 )
{
              if( AllFalloutObjectsDropped( ) )
      {
     foreach(Player, i)
     {
            if( GetPVarInt( i, \"Minigame\" ) == 2 )
       {
         SetPVarInt( i, \"Minigame\", 0 );
         SpawnPlayer( i );
         TogglePlayerControllable( i, 1 );
        }
     }
     SetGVarInt( \"FalloutPlayers\", 0 );
     SetGVarInt( \"FalloutActive\",  0 );
     SetGVarInt( \"FalloutStarted\", 0 );
     for( new iObjects; iObjects < sizeof( iFalloutObjects ); iObjects++ )
     {
      FalloutObjectsDropped[ iObjects ] = false;
     }
             for( new iPos; iPos < 13; iPos++ )
     {
       FalloutPositionUsed[ iPos ] = false;
     }
     FalloutMapUnload( );
     FalloutMapLoad( );
     SendClientMessageToAll( COLOR_RED, \"Fallout: A Fallout minijátékot senki nem nyerte meg, döntetlen az eredmény.\" );
                     return 1;
                }
    
       RandomGotoDrop:
       {
    new
        iRandObj = random( 36 );
     if( FalloutObjectsDropped[ iRandObj ] == true )
     {
                 goto RandomGotoDrop;
     }
     new
                                      Float: fObjectPos[ 3 ];
     GetObjectPos( iFalloutObjects[ iRandObj ], fObjectPos[ 0 ], fObjectPos[ 1 ], fObjectPos[ 2 ] );
     SetObjectPos( iFalloutObjects[ iRandObj ], fObjectPos[ 0 ], fObjectPos[ 1 ], fObjectPos[ 2 ] - 170 );
    
     FalloutObjectsDropped[ iRandObj ] = true;
              }
       }
       return 1;
}

 
Ezt írja a crashdetect:
 

[19:48:15] [debug] Run time error 4: \"Array index out of bounds\"
[19:48:15] [debug]  Accessing element at index 36 past array upper bound 35
[19:48:15] [debug] AMX backtrace:
[19:48:15] [debug] #0 00055368 in ?? () from gm.amx
[19:48:15] [debug] #1 0002dbec in public FalloutDropObjects () from gm.amx
« Utoljára szerkesztve: 2012. November 10. - 22:20:37 írta Gabor.. »

Nem elérhető Casamiro

  • 1046
    • Profil megtekintése
Eljárás crash
« Válasz #1 Dátum: 2012. November 10. - 22:20:46 »
0 Show voters
Esetleg így?
public FalloutDropObjects( )
{
        if( GetGVarInt( \"FalloutStarted\" ) == 1 )
        {
              if( AllFalloutObjectsDropped( ) )
              {
                     foreach(Player, i)
                     {
                            if( GetPVarInt( i, \"Minigame\" ) == 2 )
                            {
                                   SetPVarInt( i, \"Minigame\", 0 );
                                   SpawnPlayer( i );
                                   TogglePlayerControllable( i, 1 );
                             }
                     }
                     SetGVarInt( \"FalloutPlayers\", 0 );
                     SetGVarInt( \"FalloutActive\",  0 );
                     SetGVarInt( \"FalloutStarted\", 0 );
                     for( new iObjects; iObjects < sizeof( iFalloutObjects ); iObjects++ )
                     {
                           FalloutObjectsDropped[ iObjects ] = false;
                     }
                     for( new iPos; iPos < 13; iPos++ )
                     {
                            FalloutPositionUsed[ iPos ] = false;
                     }
                     FalloutMapUnload( );
                     FalloutMapLoad( );
                     SendClientMessageToAll( COLOR_RED, \"Fallout: A Fallout minijátékot senki nem nyerte meg, döntetlen az eredmény.\" );
              }
                         
               RandomGotoDrop:
               {
                         new
                                  iRandObj = random( 35 );
                          if( FalloutObjectsDropped[ iRandObj ] == true )
                          {
                                      goto RandomGotoDrop;
                          }
                          new
                                      Float: fObjectPos[ 3 ];
                          GetObjectPos( iFalloutObjects[ iRandObj ], fObjectPos[ 0 ], fObjectPos[ 1 ], fObjectPos[ 2 ] );
                          SetObjectPos( iFalloutObjects[ iRandObj ], fObjectPos[ 0 ], fObjectPos[ 1 ], fObjectPos[ 2 ] - 170 );
                         
                         FalloutObjectsDropped[ iRandObj ] = true;
              }
       }
       return 1;
}

Ha nem jó, akkor másold be hogy hozod létre a FalloutObjectsDropped változót

Nem elérhető Kovacs_Richard

  • 1743
  • HRP Fejlesztő
  • Discord: Kovacs_Richard#0321
    • Profil megtekintése
    • Hun Role Play Web
Eljárás crash
« Válasz #2 Dátum: 2012. November 10. - 22:24:03 »
0 Show voters
FalloutObjectsDropped

 
ennek a tömbnek mekkora a mérete?
Régóta nem tevékenykedem, mint SA-MP scripter.
HRP Fejlesztő.

Nem elérhető Gabor..

  • 1883
  • Gabor..
    • Profil megtekintése
Eljárás crash
« Válasz #3 Dátum: 2012. November 11. - 08:11:20 »
0 Show voters
Idézetet írta: Casamiro date=1352582446\" data-ipsquote-contentapp=\"forums\" data-ipsquote-contenttype=\"forums\" data-ipsquote-contentid=\"29710\" data-ipsquote-contentclass=\"forums_Topic
Esetleg így?
public FalloutDropObjects( )
{
        if( GetGVarInt( \"FalloutStarted\" ) == 1 )
        {
              if( AllFalloutObjectsDropped( ) )
              {
                     foreach(Player, i)
                     {
                            if( GetPVarInt( i, \"Minigame\" ) == 2 )
                            {
                                   SetPVarInt( i, \"Minigame\", 0 );
                                   SpawnPlayer( i );
                                   TogglePlayerControllable( i, 1 );
                             }
                     }
                     SetGVarInt( \"FalloutPlayers\", 0 );
                     SetGVarInt( \"FalloutActive\",  0 );
                     SetGVarInt( \"FalloutStarted\", 0 );
                     for( new iObjects; iObjects < sizeof( iFalloutObjects ); iObjects++ )
                     {
                           FalloutObjectsDropped[ iObjects ] = false;
                     }
                     for( new iPos; iPos < 13; iPos++ )
                     {
                            FalloutPositionUsed[ iPos ] = false;
                     }
                     FalloutMapUnload( );
                     FalloutMapLoad( );
                     SendClientMessageToAll( COLOR_RED, \"Fallout: A Fallout minijátékot senki nem nyerte meg, döntetlen az eredmény.\" );
              }
                         
               RandomGotoDrop:
               {
                         new
                                  iRandObj = random( 35 );
                          if( FalloutObjectsDropped[ iRandObj ] == true )
                          {
                                      goto RandomGotoDrop;
                          }
                          new
                                      Float: fObjectPos[ 3 ];
                          GetObjectPos( iFalloutObjects[ iRandObj ], fObjectPos[ 0 ], fObjectPos[ 1 ], fObjectPos[ 2 ] );
                          SetObjectPos( iFalloutObjects[ iRandObj ], fObjectPos[ 0 ], fObjectPos[ 1 ], fObjectPos[ 2 ] - 170 );
                         
                         FalloutObjectsDropped[ iRandObj ] = true;
              }
       }
       return 1;
}

Ha nem jó, akkor másold be hogy hozod létre a FalloutObjectsDropped változót
 
De így 0-34-ig fog generálni számokat, és nekem 0-35-ig vannak az objectek, így tehát 1 object nem fog leesni.

 
FalloutObjectsDropped

 
ennek a tömbnek mekkora a mérete?
 
[/quote]
36 cella.
 
bool: FalloutObjectsDropped[ 36 ]

 
E.: Idõközben kivettem az AllFalloutObjectDropped() eljárást, mert hibásan írtam meg.
« Utoljára szerkesztve: 2012. November 11. - 08:37:46 írta Gabor.. »

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal