Error

Started by FinchDon, Sep 18, 2015, 10:34 AM

Previous topic - Next topic

FinchDon

I make this function to save BFME Coins

function SaveStats( player )
{
       try{
   local id = player.ID;
   if ( pstats[ id ].Logged == true )
   {
             QuerySQL( sqliteDB, "UPDATE Accounts SET Coins='" + pstats[ id ].BFME + "' WHERE Name='" + player.Name.tolower() + "'" );
   print( "Saved Stats of Player " + player.Name + "[" + player.ID + "]" );
   pstats[ id ] = null;
   }
   }
   catch(e) print( "Save Stats Error: " + e );
}

and add this on PlayerPart

SaveStats( player );

when i do /q

it show error on this line
index Update does not exist
pstats[ player.ID ].Update( player, sqliteDB );

when i remove SaveStats( player ); and do /q no error appear

there is pstats[ player.ID ].Update( player, sqliteDB ); FUnction

function Update( player, dbGlobal ){
::QuerySQL( dbGlobal, "UPDATE Accounts SET Cash=" + Cash + ", Bank=" + Bank + ", Kills=" + Kills + ", Deaths=" + Deaths + ", Level=" + Level + ",  LastUsedIP='" + LastUsedIP + "' WHERE Name='" + player.Name + "' AND NameLower='" + player.Name.tolower() + "'" );
  }
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

.

Quote from: FinchDon on Sep 18, 2015, 10:34 AM...
index Update does not exist
...

Seriously? Are we still doing this?
.

KAKAN

Yea, we are, FinchDon, I'll tell you as soon as I get in my PC, else you may try.
Add the query line to function Update, but make it dbGobal before doing it, as it is already described
oh no

Kratos_

#3
Quote from: FinchDon on Sep 18, 2015, 10:34 AMfunction SaveStats( player )
{
// body ..............
pstats[ id ] = null;
// body ..............
}

You're clearing the array so that class object have become vanished . Now , you couldn't retrieve function Update which was member of
that object .  You should clear the array after calling the Update function .
In the middle of chaos , lies opportunity.

Thijn

Locked. Like @S.L.C. said, read the stickied topics and figure it out. I refuse to give support if you wont learn from it. We've dealt with an error like that a million times now and I'm done.