Error
Weapon »

FinchDon

  • Sr. Member
  • Posts: 252
Error
« on September 18th, 2015, 11:34 AM »
I make this function to save BFME Coins

Code: [Select]
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

Code: [Select]
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 )

.

  • VC:MP Beta Tester
  • .
  • Posts: 1,807
.

KAKAN

  • Wiki Contributor
  • Posts: 3,343
Re: Error
« Reply #2, on September 18th, 2015, 02: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
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN

Kratos_

  • Jr. Member
  • Mutaros Apotheoses
  • Posts: 86
Re: Error
« Reply #3, on September 18th, 2015, 04:51 PM »Last edited on September 18th, 2015, 04:53 PM
Quote from FinchDon on September 18th, 2015, 11:34 AM
Code: [Select]
function 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

  • VC:MP Beta Tester
  • Posts: 1,688
Re: Error
« Reply #4, on September 18th, 2015, 07: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.