integer expected for the specified format

Started by Mötley, Jul 28, 2016, 02:05 AM

Previous topic - Next topic

Mötley

Error code

[LU]
 
This is very simple and I do not understand why it does not work after using arrays instead of a class.

So I finally gave up on this simple error. Maybe another persons eyes can see my mistake.

QuoteAN ERROR HAS OCCURED [integer expected for the specified format]

CALLSTACK
*FUNCTION [Update()] Scripts/Main/Accounts.nut line [120]
*FUNCTION [onPlayerPart()] Scripts/Main/Accounts.nut line [102]

LOCALS
[sqliteDB] USERPOINTER
[player] INSTANCE
[this] TABLE
[partID] 0
[player] INSTANCE
[this] TABLE



function onPlayerUpdate( player, sqliteDB ) {

// format the update query
local szquery = format( "UPDATE Accounts SET Cash=%i, Bank=%i, Kills=%i, Deaths=%i, Level=%i, User_IP=%s WHERE Name='%s'",
Cash[player.ID], Bank[ player.ID ], Kills[ player.ID ], Deaths[ player.ID ], USER_LEVEL[ player.ID ], USER_IP[ player.ID ], player.Name );

       // execute the query
       ::sqlite_query( sqliteDB, szquery );
}

Any help is appreciated

Thijn

Obviously, any of those contain something else then an integer.
So start by printing all the values, and seeing what each contain.
If that doesn't tell you what value is wrong, type printing the type and see which one isn't an int.

Mötley

#2
Quote from: Thijn on Jul 28, 2016, 05:52 AMObviously, any of those contain something else then an integer.
So start by printing all the values, and seeing what each contain.
If that doesn't tell you what value is wrong, type printing the type and see which one isn't an int.

Oddly neither of this worked. I am beginning to think I should do a re-build of the sq-lite system as something is not right, Either from the arrays to whatever. I think it would be much easier.

I did not have any issues with this build until last week I began getting all of these odd error codes that were never even there in the first place. So something is not right and I could fix this faster doing a re-build than to do a fix. As something is not right in the system itself

KAKAN

Try using this:-
function onPlayerUpdate( player, sqliteDB ) {
 
  // format the update query
  local szquery = format( "UPDATE Accounts SET Cash=%i, Bank=%i, Kills=%i, Deaths=%i, Level=%i, User_IP='%s' WHERE Name='%s'",
  Cash[player.ID].tointeger(),
  Bank[ player.ID ].tointeger(),
  Kills[ player.ID ].tointeger(),
  Deaths[ player.ID ].tointeger(),
  USER_LEVEL[ player.ID ].tointeger(),
  USER_IP[ player.ID ].tostring(),
  player.Name.tostring()
  );

       // execute the query
       ::sqlite_query( sqliteDB, szquery );
}
If that doesn't work, get the line which shows the error, and then, do print( the_thing );
for ex, is USER_LEVEL is the error line, do, print( USER_LEVEL[ player.ID ] );
oh no

Mötley

QuoteAN ERROR HAS OCCURED [the index 'tointeger' does not exist]

CALLSTACK
*FUNCTION [Update()] Scripts/Main/Accounts.nut line [120]
*FUNCTION [onPlayerPart()] Scripts/Main/Accounts.nut line [102]

LOCALS
[sqliteDB] USERPOINTER
[player] INSTANCE
[this] TABLE
[partID] 0
[player] INSTANCE
[this] TABLE

  local szquery = format( "UPDATE Accounts SET Cash=%i, Bank=%i, Kills=%i, Deaths=%i, Level=%i, User_IP='%s' WHERE Name='%s'",
The error is located in the table. I do not understand. hear are my arrays

//---------------------------------------------------------------------------------
              /* ACCOUNTING ARRAYS*/
USER_LEVEL <- array(GetMaxPlayers(), 0);

LOGIN_ATTEMPTS <- array(GetMaxPlayers(), 0);

AUTO_LOGIN <- array(GetMaxPlayers(), null);

USER_IP <- array(GetMaxPlayers(), "");

USER_PASSWORD <- array(GetMaxPlayers(), 0);

LOGGED <- array(GetMaxPlayers(), false);

Kills <- array(GetMaxPlayers(), null);

Deaths <- array(GetMaxPlayers(), null);

Cash <- array(GetMaxPlayers(), null);

Bank <- array(GetMaxPlayers(), null);

//---------------------------------------------------------------------------------

Thijn

Well there's your problem. You can't say to a null value to become an integer.
Either change your default values for kills etc. to 0, or check them for nulls beforehand.

Shadow

I am not really in touch with squirrel scripting anymore but, wouldn't it be easier to keep all this information in a class instead of having hundreds of arrays?

Anyway, try printing values and show us what you get.
QuotePS:is trash is ur home language??

Mötley

I've had a crazy day at work and I appreciate the responses. Power has been on and off in this storm so I prefer not to turn the PC on.
Also apologize as my English is off.

@Thijn the values automatically change after login. Every value is set to integer"what ever your account values are" then after saving the values the arrays are cleared.

@Shadow I used arrays as I wanted to be different.

I really don't want a class as well.
Many arrays were a lot of fun in the beginning of my scripting experience. As well super simple to work with.

I think my issue is I could of done a better job with my sq lite accounting.
I just plan to do a rebuild as it should cure everything.

I'm just going to create a new server with only what I need once finished just replace my old system with the new system.

KAKAN

Quote from: Mötley on Jul 29, 2016, 03:28 AMMany arrays were a lot of fun in the beginning of my scripting experience. As well super simple to work with.
Sure, I remember my old funny days, I was having like 250 arrays lol
oh no

Mötley

Well I'm going to start this Sunday as I'm off from work. Went ahead and created a new table that fit's my needs. This should only take two hours to perfect. I just mainly need to validate Auto-login as I do not want others stealing accounts in bugs

sqlite_query( statDB, "CREATE TABLE Stats ( Name VARCHAR(32), Password VARCHAR(32), Players_IP VARCHAR(32), Player_UID INT, Auto_Login INT, Level INT, Kills INT, Deaths INT, Money INT, Bank INT, Skin INT, Wanted_Level INT, Health INT, Armour INT )" );

Let me know if you see anything wrong in this table :)