Liberty Unleashed
Scripting => Script Help => Topic started by: Merkel on December 28, 2013, 09:59:43 pm
-
Hi,
I have a problem getting the position and spawn the pickups for the properties. When the server call the function, the pickups in the server doesn't spawn. It does not give me any errors.
Here the function:
function LoadProps()
{
if ( CountProps() != 0 )
{
local q = sqlite_query( db, "SELECT * FROM Properties WHERE ID='%'" ), pos;
while ( sqlite_column_data( q, 0 ) )
{
local coords = sqlite_column_data( q, 5 );
CreatePickup( 1361, Vector( GetTok( coords, " ", 1 ).tofloat(), GetTok( coords, " ", 2 ).tofloat(), GetTok( coords, " ", 3 ).tofloat() ) );
sqlite_next_row( q );
}
sqlite_free( q );
}
}
I'm newbie in SQLite...
-
Without an error, it's harder to determine the source.
However, I think your query might not be right. The WHERE clause shouldn't exist if you are trying to pull all the records from a table. Also, you may need to include field names in your query to help manage what is selected. Just use something like this:
"SELECT ID,Coords FROM Properties"
And column data 0 will be your ID, and column data 1 will be your coordinates.
EDIT: I messed up the bold thing in my original post.
-
Without an error, it's harder to determine the source.
However, I think your query might not be right. The WHERE clause shouldn't exist if you are trying to pull all the records from a table. Also, you may need to include field names in your query to help manage what is selected. Just use something like this:
"SELECT ID,Coords FROM Properties"
And column data 0 will be your ID, and column data 1 will be your coordinates.
The problem is not in this function, is in "CountProps"...
When the server call this function (CountProps), fails,I have seen with "print", the server does not come over there
function CountProps()
{
local a = 0, q = sqlite_query( db, "SELECT ID FROM Properties" );
while ( sqlite_column_data( q, 0 ) )
{
a++;
sqlite_next_row( q );
}
return a;
sqlite_free( q );
}
ADMIN EDIT: Stop insulting!
USER EDIT: Insulting what ? LOL
-
If the problem is in a different function, why didn't you post that function in the first place?
Also, try this query instead:
SELECT count(*) FROM Properties
That should give you a number of rows. Use this data like any other query, like so:
sqlite_column_data( q , 0 )
-
-- Topic closed --
Thanks to Vortrex to help me.