Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Finch on Mar 21, 2015, 01:47 PM

Title: savestats
Post by: Finch on Mar 21, 2015, 01:47 PM
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 );
}

Title: Re: savestats
Post by: MacTavish on Mar 21, 2015, 03:10 PM
Are you Sure that Your Database is saving nicks in tolower()

try changing
WHERE Name='" + player.Name.tolower() + "'to WHERE Name='" + player.Name + "'
Title: Re: savestats
Post by: Finch on Mar 22, 2015, 04:03 AM
database save nicks in lower case
Title: Re: savestats
Post by: Finch on Mar 22, 2015, 04:11 AM
still not working
Title: Re: savestats
Post by: Thijn on Mar 22, 2015, 02:21 PM
Have you tried opening the database and see if there's actually data in there?
Title: Re: savestats
Post by: Finch on Mar 22, 2015, 03:58 PM
yes thijn their is data
Title: Re: savestats
Post by: Thijn on Mar 22, 2015, 04:01 PM
The correct data? If there is, show the code where you load the stats.
Title: Re: savestats
Post by: Finch on Mar 22, 2015, 04:06 PM
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
Title: Re: savestats
Post by: vcmptr on Mar 22, 2015, 04:18 PM
Are you using Warchief?
Title: Re: savestats
Post by: MacTavish on Mar 22, 2015, 05:03 PM
Then probably the fault is in accinfo

Post your accinfo function here
Title: Re: savestats
Post by: Finch on Mar 23, 2015, 03:39 AM
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 );
}
Title: Re: savestats
Post by: Kratos_ on Mar 23, 2015, 04:21 AM
Click here (http://forum.vc-mp.org/?topic=336.msg1991#msg1991)
Title: Re: savestats
Post by: Finch on Mar 23, 2015, 09:45 AM
so ur mean that kills and deaths etc not save in server?
Title: Re: savestats
Post by: . on Mar 23, 2015, 10:07 AM
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.
Title: Re: savestats
Post by: . on Mar 23, 2015, 10:16 AM
Few advices:

One more question: Do you even debug your code? Or you just come here and every time something doesn't work.
Title: Re: savestats
Post by: DizzasTeR on Mar 23, 2015, 10:43 AM
Quote from: S.L.C on Mar 23, 2015, 10:16 AMOne more question: Do you even debug your code? Or you just come here and every time something doesn't work.

I don't think you need to ask that. The answer is No.

Edit: Finch kia tum urdu read kar saktay ho?
Reply me if you understood that finch.
Title: Re: savestats
Post by: EK.IceFlake on Mar 23, 2015, 12:06 PM
Quote from: Finch on Mar 21, 2015, 01:47 PMmy 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 );
}


QuoteQuerySQL( 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() + "'" );
Are you sure these guys are stored as a string? Try changing to
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() + "'" );
Title: Re: savestats
Post by: Finch on Mar 23, 2015, 01:49 PM
Not working crystal
Title: Re: savestats
Post by: vcmptr on Mar 23, 2015, 01:58 PM
function SaveStats( player )
{
       try{
    local id = player.ID;
if ( ( status[ player.ID ].IsReg == true ) && ( status[ player.ID ].IsLogged == 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 );
}
Try this.
Title: Re: savestats
Post by: Finch on Mar 23, 2015, 03:10 PM
Yeah i Can Understand Doom_Killer <.>


Again not working
Title: Re: savestats
Post by: . on Mar 23, 2015, 03:20 PM
Quote from: Finch on Mar 23, 2015, 03:10 PMYeah i Can Understand Doom_Killer <.>

Are you sure?

Quote from: Finch on Mar 23, 2015, 03:10 PMAgain not working

You're just dying to prove me right with every post you make ;D
Quote from: S.L.C on Mar 23, 2015, 10:07 AMAll you can say is something like "Not work!" and give some sh!tty code, copied from god knows where.
Title: Re: savestats
Post by: DizzasTeR on Mar 23, 2015, 05:22 PM
Quote from: Finch on Mar 23, 2015, 03:10 PMYeah i Can Understand Doom_Killer <.>


Again not working

Sorry if this is against rules but maybe this will reduce this disaster.

Finch Khuda kay leye agr ap scripting nahi kar saktay to na karein kyun kay ap ko samajh nahi aati aur aap theke.tara say error bhi nahi post kartay, Behtar ho ga agar aap dosroon kay server mein khelein ya phir jald jab mera server host ho jai ga jo kay mein apnay aik bro kay sath bana raha hun to ap wahan bhi khelna. Laiken agar aap kisi tareeqay say bhi scripting karna nahi chorna chahte to theke hai magar kam as kam error to theke post kia karein, console aur script notepad mein khol kar os error line ki bhi screen lia karo aur post karo aur jitna ho sakay detail dia karo error ki, aur agar aap sahi tareeqay say post karo gey i bet koi aap ki insult nahi karay ga.
 :)
Hope you will act upon my advice.
Title: Re: savestats
Post by: Finch on Mar 24, 2015, 08:27 AM
me janta hu doom magr is me post karne me he hi kya phr bhi yeh lo screen shot sari cheezo ke phele set kills in server ke stats cmd ke sath

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi60.tinypic.com%2Fszx650.png&hash=02c0dc911c9ce11a5b1cb5ef606e31873988a039)


or ab console ki screen shot


(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi60.tinypic.com%2Fw7k2v7.png&hash=a151b257050f3107a04949aba8868ad609682763)


or yeh ab rejoin server ki stats cmd ke sath


(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi62.tinypic.com%2F161hjio.png&hash=398764d49f1a3fb771041207d3bcf973a3ca891e)
Title: Re: savestats
Post by: EK.IceFlake on Mar 24, 2015, 08:58 AM
Quote from: Finch on Mar 24, 2015, 08:27 AMor ab console ki screen shot


(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi60.tinypic.com%2Fw7k2v7.png&hash=a151b257050f3107a04949aba8868ad609682763)
Yeh tumhe kahan se console ka screenshot lagta he?
English: From where does it look like a screenshot of console?
Title: Re: savestats
Post by: rObInX on Mar 24, 2015, 09:06 AM
Database is fucked up.

Try deleting the db and then try.
Title: Re: savestats
Post by: DizzasTeR on Mar 24, 2015, 10:03 AM
Quote from: NE.CrystalBlue on Mar 24, 2015, 08:58 AM
Quote from: Finch on Mar 24, 2015, 08:27 AMor ab console ki screen shot


(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi60.tinypic.com%2Fw7k2v7.png&hash=a151b257050f3107a04949aba8868ad609682763)
Yeh tumhe kahan se console ka screenshot lagta he?
English: From where does it look like a screenshot of console?

Guzara karta hai, atleast samajh to a rahi hai.

try what robinx said.
Title: Re: savestats
Post by: rww on Mar 24, 2015, 12:26 PM
I know that it will not help you, but:

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi62.tinypic.com%2Feukdi9.png&hash=84d249092ebb0bf57045ddada83b67e098317628)

2x the same module
Title: Re: savestats
Post by: . on Mar 24, 2015, 01:19 PM
Quote from: rwwpl on Mar 24, 2015, 12:26 PMI know that it will not help you, but:

2x the same module

The functions will simply be overwritten by the second loaded module. If the functions weren't available then you'd get a message like "index doesn't exist". I'm sure the bug is really simple. I'll look later into the SQLite module of stormeus and see if I can add proper error reporting. That way you will know there's something wrong with the query if it fails.
Title: Re: savestats
Post by: MacTavish on Mar 24, 2015, 01:49 PM
Off: Guys maybe you didnt noticed but in his top 5 killers have 900 kills so it is clear that none of his function have problem, maybe his stats cmd is bugged
Title: Re: savestats
Post by: Kratos_ on Mar 24, 2015, 03:25 PM

I tried to make some attempts to conclude something from the codes he posted , here they are :-

-> On console , it prints that his stats saved
This points that the value that array holds is actually transferred to the database because his Savestats function do not have any issue . Thus , it is actually called .

-> When he sets his kills to 900 then this change appear in stats on that particular Join
This points that he is making change to the array variables & so stats gets modified as well .

-> On Next Join, his name appear on Top 5 Killers
This points that arrays were successful in transferring the changed value of Kills on previous Join & that Top 5 list will be made by getting Kills directly from the database .

-> But , on next Join, his kills doesn't gets modified in Stats
This points that arrays aren't syncing anything from the database during login . The arrays are just exploited as one-way . They just transfer the value to the database but aren't designed to get anything from the database when a player does login .

So , After having a glance at all the possibilities , Its the arrays which aren't getting anything from the database while they are supposed to .

Then why the kills & deaths are showing as 0 when player types stats command ?
Answer : Because they're initialized as 0 in class PlayerStats . This way :-
class PlayerStats
{
Kills = 0;
Deaths = 0;
}

Without getting the values from the database , how can u expect that this will appear on your stats ? You need to make a request to the database so that it will give you its contents .

What should you do ?
-> You should take the Kills value from the database so that they can be stored in array & thus making up your stats .

OffTopic :- I tried to tell you this fact here (http://forum.vc-mp.org/?topic=408.msg2664#msg2664) but you haven't responded . Anyway , make those changes to your login function I described & make them sync Kills , Deaths etc  otherwise it will do the same for the remaining values as well .


Title: Re: savestats
Post by: . on Mar 24, 2015, 03:33 PM
Quote from: Kratos_ on Mar 24, 2015, 03:25 PMWithout getting the values from the database , how can u expect that this will appear on your stats ? You need to make a request to the database so that it will give you its contents .

LOL it's not the first time he did this (http://forum.vc-mp.org/?topic=336.msg1962#msg1962). Same thing happened with his previous account. That's why I've told you so simply ignore the question because he doesn't know what he's doing.
Title: Re: savestats
Post by: Finch on Mar 27, 2015, 05:24 AM
so what is method to correct savestats?
Title: Re: savestats
Post by: EK.IceFlake on Mar 27, 2015, 05:32 AM
Quote from: Finch on Mar 27, 2015, 05:24 AMso what is method to correct savestats?
Do it yourself. We are not helping you. You really need to know a very basic things. Thats why if you dont know them you shouldnt scripting.