Stats Problem :-/

Started by ali_vcmp, Nov 08, 2014, 08:12 PM

Previous topic - Next topic

ali_vcmp

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;

ali_vcmp

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)", 

.

#2
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.
.

Sebastian

I will try: What error you get in server's console ? You can add an image with it. ;)

Fjose

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.

ali_vcmp

http://postimg.org/gallery/2rcn32hcy/ Pictures Link Fjose I Add Stats array and pplayercass u can see in this pictures :-(

.

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.
.

ali_vcmp

Thanks S.L.C its show me death and kills ;-) But ITs Can't Add stats in Database :/ Pls Help me :-(

Honey

Are you sure that you have those tables in the database? You might be getting this error due to lower or upper case issues.

ali_vcmp

          QuerySQL( statDB, "CREATE TABLE Stats ( Name VARCHAR(32), Kills INT, Deaths INT, Joins INT )" ); yes i have table

.

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
)");
.

ali_vcmp


ali_vcmp

now database add My account but  server cant add Kills And Deaths Pls Help me :(

Sebastian

I just tested the script from wiki, and it works properly. The serverstats.sqlite database was created when I started the server.

Make sure you did:
  • copy every line in the correct event
  • load sqlite04rel32/64.dll module in server.cfg

ali_vcmp

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