Author Topic: Error.. error.. error..  (Read 4517 times)

Shadow.

  • Tester
  • Full Member
  • ****
  • Posts: 144
  • Karma: +16/-35
    • View Profile
Error.. error.. error..
« on: July 02, 2012, 06:24:15 pm »
So, I have been thinking about this system that loads up previous player position from SQLite database, and sets you there, but I encounter an error.

Code: [Select]
function PrecachePosition(player)
{
player.Skin = sqlite_column_data(sqlite_query(database, "SELECT Skin FROM LASTLOGIN WHERE Name='"+player.Name.toupper()+"' " ),0);
/* local x = sqlite_column_data(sqlite_query(database, "SELECT * FROM LASTLOGIN WHERE Name='"+player.Name.toupper()+"' " ),1);
local y = sqlite_column_data(sqlite_query(database, "SELECT * FROM LASTLOGIN WHERE Name='"+player.Name.toupper()+"' " ),2);
local z = sqlite_column_data(sqlite_query(database, "SELECT * FROM LASTLOGIN WHERE Name='"+player.Name.toupper()+"' " ),3);*/
local wep = sqlite_column_data(sqlite_query(database, "SELECT Wep FROM LASTLOGIN WHERE Name='"+player.Name.toupper()+"' " ),0);
local ammo = sqlite_column_data(sqlite_query(database, "SELECT Ammo FROM LASTLOGIN WHERE Name='"+player.Name.toupper()+"' " ),0);
player.SetWeapon( wep, ammo );
player.Frozen = false;
player.Pos = Vector( sqlite_column_data(sqlite_query(database, "SELECT X FROM LASTLOGIN WHERE Name='"+player.Name.toupper()+"' " ),0), sqlite_column_data(sqlite_query(database, "SELECT Y FROM LASTLOGIN WHERE Name='"+player.Name.toupper()+"' " ),0), sqlite_column_data(sqlite_query(database, "SELECT Z FROM LASTLOGIN WHERE Name='"+player.Name.toupper()+"' " ),0) );
}



1.YES the data exists
2.YES the data is in FLOAT format
3.YES the data is valid
4.YES the data is in NUMERIC.NUMERIC format ( FLOAT )
5.YES the data is saved at onPlayerPart(player,partreason)
6.YES I tried to get the exact data and put '.tofloat()' after it
7.The line with the error is surprisingly
Code: [Select]
player.Pos = Vector( sqlite_column_data(sqlite_query(database, "SELECT X FROM LASTLOGIN WHERE Name='"+player.Name.toupper()+"' " ),0), sqlite_column_data(sqlite_query(database, "SELECT Y FROM LASTLOGIN WHERE Name='"+player.Name.toupper()+"' " ),0), sqlite_column_data(sqlite_query(database, "SELECT Z FROM LASTLOGIN WHERE Name='"+player.Name.toupper()+"' " ),0) );


Yes I also tried this code
Code: [Select]
local x = sqlite_column_data(sqlite_query(database, "SELECT X FROM LASTLOGIN WHERE Name='"+player.Name.toupper()+"' " ),0);
local y = sqlite_column_data(sqlite_query(database, "SELECT Y FROM LASTLOGIN WHERE Name='"+player.Name.toupper()+"' " ),0);
local z = sqlite_column_data(sqlite_query(database, "SELECT Z FROM LASTLOGIN WHERE Name='"+player.Name.toupper()+"' " ),0);
player.Pos = Vector( x.tofloat(), y.tofloat(), z.tofloat() );



also, when I make a class and default all the datas to null, then try to set them to 1, I receive a '' trying to set 'null ''



DO NOT COPY THIS CODE PLEASE
« Last Edit: July 02, 2012, 07:06:59 pm by Shadow. »

Knucis

  • Jr. Member
  • **
  • Posts: 50
  • Karma: +2/-2
    • View Profile
Re: Error.. error.. error..
« Reply #1 on: July 02, 2012, 07:10:20 pm »
DO NOT COPY THIS CODE, NEITHER THE IDEA
Sorry, but I had to post about this notice here. It's your fault if you are sharing your code, as long as they script the code themselves they are free to use it. And you are posting as that code is something new and revolutionary! lol, It has been present in every RP script afaik. (Including GameSparks  :P)

Shadow.

  • Tester
  • Full Member
  • ****
  • Posts: 144
  • Karma: +16/-35
    • View Profile
Re: Error.. error.. error..
« Reply #2 on: July 02, 2012, 07:17:04 pm »
Thanks for the help, appreciated (NOT)

Shadow.

  • Tester
  • Full Member
  • ****
  • Posts: 144
  • Karma: +16/-35
    • View Profile
Re: Error.. error.. error..
« Reply #3 on: July 02, 2012, 11:11:06 pm »
Look at the code and the pic

Quote
      local x = sqlite_column_data(sqlite_query(database, "SELECT X FROM LASTLOGIN WHERE Name='"+player.Name.toupper()+"' " ),0);
      local y = sqlite_column_data(sqlite_query(database, "SELECT Y FROM LASTLOGIN WHERE Name='"+player.Name.toupper()+"' " ),0);
      local z = sqlite_column_data(sqlite_query(database, "SELECT Z FROM LASTLOGIN WHERE Name='"+player.Name.toupper()+"' " ),0);
      //local hp = sqlite_column_data(sqlite_query(database, "SELECT Health FROM LASTLOGIN WHERE Name='"+player.Name.toupper()+"' "),0);
      //local ar = sqlite_column_data(sqlite_query(database, "SELECT Armour FROM LASTLOGIN WHERE Name='"+player.Name.toupper()+"' "),0);
      //player.Health = hp.tointeger();
      //player.Armour = ar.tointeger();
      print( "Vector(" + x + "," + y + "," + z + ");" );
      player.Pos = Vector( x, y, z );


« Last Edit: July 02, 2012, 11:12:47 pm by Shadow. »

VRocker

  • Liberty Unleashed Developer
  • Administrator
  • Full Member
  • ******
  • Posts: 342
  • Karma: +43/-15
    • View Profile
    • Madnight Software
Re: Error.. error.. error..
« Reply #4 on: July 03, 2012, 01:45:30 pm »
Just looked this up in the lu code, seems the error message is misleading because somebody forgot to throw a return afer an if.
It should say that the type passed to it is not a vector (which once again, makes no sense). Try loading the vector into a local, printing that then setting it. See what happens


Thijn

  • Tester
  • Sr. Member
  • ****
  • Posts: 531
  • Karma: +27/-16
    • View Profile
Re: Error.. error.. error..
« Reply #5 on: July 03, 2012, 02:59:37 pm »
Also, Your usage of sqlite is the worst I've ever seen. Querying the database for every x,y,z is as bad as it can get...
Just query once, and get all the data you need from it...

Shadow.

  • Tester
  • Full Member
  • ****
  • Posts: 144
  • Karma: +16/-35
    • View Profile
Re: Error.. error.. error..
« Reply #6 on: July 03, 2012, 05:19:00 pm »
Also, Your usage of sqlite is the worst I've ever seen. Querying the database for every x,y,z is as bad as it can get...
Just query once, and get all the data you need from it...
@ Thijn: Hey mr obvious, it is not. It's the SINGLE query that is supposed to return a float, and there is not a point to put it in a class, because ( obvious ) I use it just once.

passwords, admin level, LCPD Sub-divisions level & other things are obviously stored in a class.

But, of course you just come on and spit it, no point to actually ask.

@VRocker: tried, same thing
@VetalYA: tried, same thing

Thanks for the help, I will try few tweaks to see if I can do it.
« Last Edit: July 03, 2012, 05:20:41 pm by Shadow. »

stormeus

  • No-Lifer
  • Developer
  • Full Member
  • *****
  • Posts: 112
  • Karma: +13/-2
    • View Profile
Re: Error.. error.. error..
« Reply #7 on: July 03, 2012, 06:59:29 pm »
@ Thijn: Hey mr obvious, it is not. It's the SINGLE query that is supposed to return a float, and there is not a point to put it in a class, because ( obvious ) I use it just once.

passwords, admin level, LCPD Sub-divisions level & other things are obviously stored in a class.

It's still pretty bad when you can just put it all in one query like so:
Code: [Select]
local q = sqlite_query( database, "SELECT X, Y, Z, Skin, Wep, Ammo FROM LASTLOGIN WHERE Name='" + player.Name.toupper() + "' LIMIT 1" );

// x - Column 0
// y - Column 1
// z - Column 2
// etc.

Performing so many queries that could be done in one query could be detrimental to performance down the road. Not only that, but I'll never understand what the hell this is:

Code: [Select]
player.Pos = Vector( sqlite_column_data(sqlite_query(database, "SELECT X FROM LASTLOGIN WHERE Name='"+player.Name.toupper()+"' " ),0), sqlite_column_data(sqlite_query(database, "SELECT Y FROM LASTLOGIN WHERE Name='"+player.Name.toupper()+"' " ),0), sqlite_column_data(sqlite_query(database, "SELECT Z FROM LASTLOGIN WHERE Name='"+player.Name.toupper()+"' " ),0) );

When you could've simply done:
Code: [Select]
local q = sqlite_query( database, "SELECT X, Y, Z FROM LASTLOGIN WHERE Name = '" + player.Name.toupper() + "' LIMIT 1" );

local x = sqlite_column_data( q, 0 ).tofloat();
local y = sqlite_column_data( q, 1 ).tofloat();
local z = sqlite_column_data( q, 2 ).tofloat();

Anyways, if you're still having problems, simply try this code:
Code: [Select]
player.Pos = Vector( 0.0, 0.0, 0.0 );

And see if it still complains about it not being a vector. If that one line works, then I'm going to guess that your problem is that you're performing too many goddamn operations on a single Vector constructor. In that case, try the code further above that deals with the database.
Quote
Morphine says:
    them LU devs ranting about how LU doesn't have client pickups
    while us VC:MPers don't have client anything
    ;_;

Stormeus Argo says:
    we have client crashes though
    ohohohohoho

Morphine says:
    LU DOESN'T HAVE THAT

Stormeus Argo says:
    LU - 0
    VC:MP - 1

Shadow.

  • Tester
  • Full Member
  • ****
  • Posts: 144
  • Karma: +16/-35
    • View Profile
Re: Error.. error.. error..
« Reply #8 on: July 03, 2012, 07:34:40 pm »
Same thing for ^^^ code.

stormeus

  • No-Lifer
  • Developer
  • Full Member
  • *****
  • Posts: 112
  • Karma: +13/-2
    • View Profile
Re: Error.. error.. error..
« Reply #9 on: July 03, 2012, 07:35:51 pm »
Same thing for ^^^ code.

Code: [Select]
print( typeof( player ) );
print( typeof( player.Pos ) );
Quote
Morphine says:
    them LU devs ranting about how LU doesn't have client pickups
    while us VC:MPers don't have client anything
    ;_;

Stormeus Argo says:
    we have client crashes though
    ohohohohoho

Morphine says:
    LU DOESN'T HAVE THAT

Stormeus Argo says:
    LU - 0
    VC:MP - 1

Shadow.

  • Tester
  • Full Member
  • ****
  • Posts: 144
  • Karma: +16/-35
    • View Profile
Re: Error.. error.. error..
« Reply #10 on: July 03, 2012, 07:38:58 pm »
1st : print( typeof( player ) ); = Player
2nd : print( typeof( player.Pos ) ); = string

EDIT 1st: if I /exec the 2nd, it returns Vector. lol...
EDIT 2nd: I printed player.Pos at onplayerspawn, it prints " Pos " LOL
« Last Edit: July 03, 2012, 07:52:55 pm by Shadow. »

stormeus

  • No-Lifer
  • Developer
  • Full Member
  • *****
  • Posts: 112
  • Karma: +13/-2
    • View Profile
Re: Error.. error.. error..
« Reply #11 on: July 03, 2012, 07:48:00 pm »
print( typeof( player.Pos ) ); = string

In that case, try print( player.Pos ), because that just doesn't look right.
Quote
Morphine says:
    them LU devs ranting about how LU doesn't have client pickups
    while us VC:MPers don't have client anything
    ;_;

Stormeus Argo says:
    we have client crashes though
    ohohohohoho

Morphine says:
    LU DOESN'T HAVE THAT

Stormeus Argo says:
    LU - 0
    VC:MP - 1

LisKa

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Error.. error.. error..
« Reply #12 on: July 03, 2012, 08:59:42 pm »
Player.Pos = string.   Why do you even use "type of" if it's already working with the simple one!...? And then arguing about that!

Shadow.

  • Tester
  • Full Member
  • ****
  • Posts: 144
  • Karma: +16/-35
    • View Profile
Re: Error.. error.. error..
« Reply #13 on: July 03, 2012, 09:49:07 pm »

Player.Pos = string.   Why do you even use "type of" if it's already working with the simple one!...? And then arguing about that!
I wonder if you ever know what you are talking  ::)


Also, I solved it. NVM, put it on top of the script then changed 30 queries into 10 :p

VetalYA

  • Guest
Re: Error.. error.. error..
« Reply #14 on: July 03, 2012, 10:09:06 pm »
Also, I solved it
Can you write, how ?

 

© Liberty Unleashed Team.