Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: ali_vcmp on Nov 08, 2014, 08:12 PM

Title: Stats Problem :-/
Post by: ali_vcmp on Nov 08, 2014, 08:12 PM
I Use This Stats System ===> http://liberty-unleashed.co.uk/vicewiki/index.php?title=Scripting/Squirrel/Examples/SQLite&oldid=1046
but is not work  i type /stats ali its send me ali stats: :/  I Type /kill and open stats database its Don't  add kills or deaths.

Stats Cmd

    else if ( cmd == "stats" )
     {
           if ( text )
           {
                local plr = FindPlayer( text );
                 
                 if ( !plr ) MessagePlayer( "Player " + text + " is not online." );
                 else
                 {
                        local plrStats = stats[ plr.ID ];
                     
                       MessagePlayer( plr.Name + "'s stats:", player );
                       MessagePlayer( "Kills: " + plrStats.Kills + ", Deaths: " + plrStats.Deaths, player );     <======    Error On This Line
                       MessagePlayer( "Joins: " + plrStats.Joins, player );
                 }
           }
           else MessagePlayer( "Usage: /c stats <player>", player );
     }



Onplayepart

     // Load the player stats from the array + lowercase name
     local
          id = player.ID,
          name = player.Name.tolower();
     
     // If player had any data in the database, update the old stats
     if ( stats[ id ].PreviousData )
     {
          // Format the query string using 'format'
          local query = format( "UPDATE Stats SET Kills=%i, Deaths=%i, Joins=%i WHERE Name='%s'",
                                 stats[ id ].Kills, stats[ id ].Deaths, stats[ id ].Joins, name );
          // Then execute the query
          QuerySQL( statDB, query )
     }
     
     else
     {
          local query = format( "INSERT INTO Stats (Name, Kills, Deaths, Joins) VALUES ('%s', %i, %i, %i)",  <======  Error On This Line
                                 name, stats[ id ].Kills, stats[ id ].Deaths, stats[ id ].Joins );
          QuerySQL( statDB, query );
     }
     
     stats[ id ] = null;
Title: Re: Stats Problem :-/
Post by: ali_vcmp on Nov 08, 2014, 08:16 PM
Cmd Error   MessagePlayer( "Kills: " + plrStats.Kills + ", Deaths: " + plrStats.Deaths, player ); 

Onplayerpart Error  local query = format( "INSERT INTO Stats (Name, Kills, Deaths, Joins) VALUES ('%s', %i, %i, %i)", 
Title: Re: Stats Problem :-/
Post by: . on Nov 08, 2014, 08:44 PM
Would it kill someone if you people learned to place the code snippets into the proper BB tags? DA FUQ IS WRONG WITH YOU? Any specific error message or you just let that at our discretion? Oh, wait. You think we're some advanced beings that read minds and predict the future. Right? I'm gonna ignore this thread and let someone else waste 5-10 posts just to get an error message from you.
Title: Re: Stats Problem :-/
Post by: Sebastian on Nov 09, 2014, 11:50 AM
I will try: What error you get in server's console ? You can add an image with it. ;)
Title: Re: Stats Problem :-/
Post by: Fjose on Nov 09, 2014, 03:09 PM
Do you have the player class created and defined in onplayerjoin?
Do you have stats <- array( GetMaxPlayers(), null ); in onscriptload?
and what happened with the onplayerkill and onplayerdeath.

in the page, down (in the end) there is a full example with all functions of how you have to do it.
Title: Re: Stats Problem :-/
Post by: ali_vcmp on Nov 10, 2014, 11:22 AM
http://postimg.org/gallery/2rcn32hcy/ Pictures Link Fjose I Add Stats array and pplayercass u can see in this pictures :-(
Title: Re: Stats Problem :-/
Post by: . on Nov 10, 2014, 12:30 PM
In your PlayerStats class you have "kills" (NOTICE: it's all lowercase) and you're asking for "Kills" (NOTICE: "K" is uppercase). If I'm not mistaken Squirrel is case-sensitive. Therefore "kills" and "Kills" are two different things.
Title: Re: Stats Problem :-/
Post by: ali_vcmp on Nov 10, 2014, 12:51 PM
Thanks S.L.C its show me death and kills ;-) But ITs Can't Add stats in Database :/ Pls Help me :-(
Title: Re: Stats Problem :-/
Post by: Honey on Nov 10, 2014, 02:44 PM
Are you sure that you have those tables in the database? You might be getting this error due to lower or upper case issues.
Title: Re: Stats Problem :-/
Post by: ali_vcmp on Nov 10, 2014, 02:58 PM
          QuerySQL( statDB, "CREATE TABLE Stats ( Name VARCHAR(32), Kills INT, Deaths INT, Joins INT )" ); yes i have table
Title: Re: Stats Problem :-/
Post by: . on Nov 10, 2014, 04:23 PM
If you have the table then why do you attempt to create it again.

QuerySQL(statDB, @"CREATE TABLE IF NOT EXISTS [Stats] (
[Name] VARCHAR(32)  NOT NULL,
[Kills] INT DEFAULT '0' NULL,
[Deaths] INT DEFAULT '0' NULL,
[Joins] INT DEFAULT '0' NULL
)");
Title: Re: Stats Problem :-/
Post by: ali_vcmp on Nov 10, 2014, 06:45 PM
not work :/
Title: Re: Stats Problem :-/
Post by: ali_vcmp on Nov 10, 2014, 07:54 PM
now database add My account but  server cant add Kills And Deaths Pls Help me :(
Title: Re: Stats Problem :-/
Post by: Sebastian on Nov 11, 2014, 02:39 PM
I just tested the script (http://liberty-unleashed.co.uk/vicewiki/index.php?title=Scripting/Squirrel/Examples/SQLite&oldid=1046) from wiki, and it works properly. The serverstats.sqlite database was created when I started the server.

Make sure you did:
Title: Re: Stats Problem :-/
Post by: ali_vcmp on Nov 11, 2014, 03:18 PM
dude my problem is ====> http://postimg.org/image/vpqdru4sh/ server create my account 1 time 2 time bla bla bla 100 time :/ You Can see This Pictures
Title: Re: Stats Problem :-/
Post by: Kratos_ on Nov 11, 2014, 04:12 PM
Have you specified somewhere this:-
stats[player.ID].PreviousData = true;
If you haven't, then that's why the record is inserting again & again.
Create the new record in table when the player registers. If something unusual happened then their records will not be created. On Player leave, save the player stats.[ No need to insert at that event ].  In login cmd & in register cmd too , set the above condition.
Title: Re: Stats Problem :-/
Post by: . on Nov 11, 2014, 04:25 PM
That's because your query inserts a new row every time instead of updating the old one.
Title: Re: Stats Problem :-/
Post by: ali_vcmp on Nov 13, 2014, 09:07 AM
Topic Locked My Problem Solved :D Thanks YouAll Thanks s.L.C And Seeby