savestats

Started by Finch, Mar 21, 2015, 01:47 PM

Previous topic - Next topic

Finch

my save stats system not working when i kill someone then i type /stats it tell kills 1 then when i do /q it say in console save stats player and when i rejoin and type /stats 0 kills and 0 deaths what is this?

this is savestats function
function SaveStats( player )
{
       try{
   local id = player.ID;
   if ( status[ id ].IsReg == true )
   {
       QuerySQL( db, "UPDATE Account SET Kills='" + status[ id ].Kills + "', Deaths='" + status[ player.ID ].Deaths + "', Cash='" + status[ id ].Cash + "', Bank='" + status[ id ].Bank + "' WHERE Name='" + player.Name.tolower() + "'" );
   print( "Saved Stats of Player " + player.Name + "[" + player.ID + "]" );
   status[ id ] = null;
   }
   }
   catch(e) print( "Save Stats Error: " + e );
}

Beztone is a scripter but he is too stupid

MacTavish

Are you Sure that Your Database is saving nicks in tolower()

try changing
WHERE Name='" + player.Name.tolower() + "'to WHERE Name='" + player.Name + "'

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

Finch

database save nicks in lower case
Beztone is a scripter but he is too stupid

Finch

still not working
Beztone is a scripter but he is too stupid

Thijn

Have you tried opening the database and see if there's actually data in there?

Finch

yes thijn their is data
Beztone is a scripter but he is too stupid

Thijn

The correct data? If there is, show the code where you load the stats.

Finch

thijn i register with nick Finch and go in database there is in small finch then i set my kills  in game and do /q and rejoin kills was 0
Beztone is a scripter but he is too stupid

vcmptr

Are you using Warchief?
My English is not good.

MacTavish

Then probably the fault is in accinfo

Post your accinfo function here

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

Finch

THere its is
function AccInfo( player )
{
      try{
qPrivMessage( "** [" + player.ID + "] " + player.Name + " Joined the Server.", player );
  if ( CheckBan( player ) == 1 ) Kick( player, "Server", "Banned From Server" );
  status[ player.ID ] = PlayerStats();
  local id = player.ID;
  local ip = player.IP;
  if ( GetLevel( player ) > 0 )
  {
      if ( ip != GetIP( player ) )
  {
      qPrivMessage( "Welcome to the Server " + player.Name + "!", player );
      wPrivMessage( "You're Not Logged-In. Please login by /login <password>", player );
  status[ player.ID ].IsReg = true;
  status[ player.ID ].IsLogged = false;
  }
  else if ( ip == GetIP( player ) )
  {
       local q = QuerySQL( db, "SELECT * FROM Account WHERE Name='" + player.Name.tolower() + "'" );
   if ( GetSQLColumnData( q, 0 ) != null )
              {
   status[ player.ID ].Kills = GetSQLColumnData( q, 4 );
   status[ player.ID ].Deaths = GetSQLColumnData( q, 5 );
   status[ player.ID ].Cash = GetSQLColumnData( q, 6 );
   status[ player.ID ].Bank = GetSQLColumnData( q, 7 );
   status[ player.ID ].Level = GetSQLColumnData( q, 2 );
   }
   GetSQLNextRow( q );
   rPrivMessage( "Welcome to the Server " + player.Name + "!", player );
   wPrivMessage( "You've Auto-Logged in onto the Server!", player );
   status[ player.ID ].IsReg = true;
   status[ player.ID ].IsLogged = true;
   tPrivMessage( ">> " + player.Name + " Auto-Logged In.", player );
   
  }
 
  }
  else
  {
      yPrivMessage( "Welcome to the Server " + player.Name + "!", player );
  qPrivMessage( "You're Not Registered with us. Register by /register <password>", player );   
  }
  }
  catch(e) print( "AccInfo Error: " + e );
}
Beztone is a scripter but he is too stupid

Kratos_

In the middle of chaos , lies opportunity.

Finch

so ur mean that kills and deaths etc not save in server?
Beztone is a scripter but he is too stupid

.

#13
Man, if I were you I'd just stop. I'd clearly see that all this scripting and databases n sh!t isn't made for me and I'd just stop. And you wanna know why?

Because you're too dumb to understand what's going on, to properly explain to these people what you need. Actually, you don't even know what you're doing to begin with. All you can say is something like "Not work!" and give some sh!tty code, copied from god knows where.

Can't you see that most of your questions either remain unanswered or require 10 posts just to get an idea of what you're trying to do and another 20 just to give you pieces of code because you can't even fix a variable name or something when the author simply forgot about it.

I know that the word "persistence" in a CV is important but not here. Go and read that god damn Squirrel documentation to have an idea of the language it self. Then go read the SQLite documentation to make sure you actually know what a database is and whether your queries are correct.

And then you can come here and ask some proper questions which we can gladly answer. Seriously, take a break, go learn some basics and then come back to ask.
.

.

#14
Few advices:
  • Use the format() function for queries and stop concatenating those values. Squirrel is a dynamically typed language, which means that those variables can literally contain any value that the language supports. And when you concatenate them, there's no one to tell you that you have the incorrect data type when you expect a number and you get a string.
  • Stop posting code that uses other private functions. Other people can't test that code or get any idea of what's happening. Because you also failed to describe the situation properly. Like my above post clearly insists on.
  • Stop placing an entire function in a try/catch block. Learn what that is for, and then start using it. Again, read the Squirrel manual like my previous post suggests.
  • Don't send your queries directly to the database. Form them in a string so that you can have a chance later to print them and see whether you have the correct query. Also, test them in other places where query errors are reported so you can pinpoint the source of the error.

One more question: Do you even debug your code? Or you just come here and every time something doesn't work.
.