Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: FinchDon on Sep 18, 2015, 10:34 AM

Title: Error
Post by: FinchDon on Sep 18, 2015, 10:34 AM
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() + "'" );
  }
Title: Re: Error
Post by: . on Sep 18, 2015, 01:10 PM
Quote from: FinchDon on Sep 18, 2015, 10:34 AM...
index Update does not exist
...

Seriously? Are we still doing this?
Title: Re: Error
Post by: KAKAN on Sep 18, 2015, 01:52 PM
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
Title: Re: Error
Post by: Kratos_ on Sep 18, 2015, 03:51 PM
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 .
Title: Re: Error
Post by: Thijn on Sep 18, 2015, 06:14 PM
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.