Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: kokia on Aug 03, 2015, 07:22 AM

Title: function not working
Post by: kokia on Aug 03, 2015, 07:22 AM
function GetVehicleCount( player )
{
QuerySQL( db, "SELECT Vehicles FROM CountVehicle WHERE Name='" + player.Name + "'")
}
this is function and error is on line 43 of functions and    QuerySQL( db, "SELECT Vehicles FROM CountVehicle WHERE Name='" + player.Name + "'")
 is line 43 error is wrong number of parameters
Title: Re: function not working
Post by: kokia on Aug 03, 2015, 07:54 AM
plz help
Title: Re: function not working
Post by: Mashreq on Aug 03, 2015, 09:45 AM
You are trying to return the vehicles in your table countvehicles?
If yes try using this one:
function GetVehicleCount( player )
{
 local q = QuerySQL( db, "SELECT Vehicles FROM CountVehicle WHERE Name='" + player.Name + "'" )
 return GetSQLColumnData( q, 0 );
}
Title: Re: function not working
Post by: Thijn on Aug 03, 2015, 10:07 AM
Always free your result:
function GetVehicleCount( player )
{
 local q = QuerySQL( db, "SELECT Vehicles FROM CountVehicle WHERE Name='" + player.Name + "'" )
 local count = GetSQLColumnData( q, 0 );
 FreeSQLQuery( q );
 return count;
}
Title: Re: function not working
Post by: kokia on Aug 03, 2015, 10:39 AM
Quote from: Thijn on Aug 03, 2015, 10:07 AMAlways free your result:
function GetVehicleCount( player )
{
 local q = QuerySQL( db, "SELECT Vehicles FROM CountVehicle WHERE Name='" + player.Name + "'" )
 local count = GetSQLColumnData( q, 0 );
 FreeSQLQuery( q );
 return count;
}
Quote from: Mashreq on Aug 03, 2015, 09:45 AMYou are trying to return the vehicles in your table countvehicles?
If yes try using this one:
function GetVehicleCount( player )
{
 local q = QuerySQL( db, "SELECT Vehicles FROM CountVehicle WHERE Name='" + player.Name + "'" )
 return GetSQLColumnData( q, 0 );
}
Quote from: Mashreq on Aug 03, 2015, 09:45 AMYou are trying to return the vehicles in your table countvehicles?
If yes try using this one:
function GetVehicleCount( player )
{
 local q = QuerySQL( db, "SELECT Vehicles FROM CountVehicle WHERE Name='" + player.Name + "'" )
 return GetSQLColumnData( q, 0 );
}
@Mashreq
@Thijn
the code is not working still error is wrong number of parameters
Title: Re: function not working
Post by: MacTavish on Aug 03, 2015, 10:56 AM
Why using SQLite query when you can count vehice by GetVehicleCount()

Example
onScriptLoad
{
print("Counted Vehicles: "+GetVehicleCount());
}

I noticed that you using GetVehicleCount to get something from db since its an squirrel function, to avoid that error

Change your GetVehicleCount to just VehicleCount
 Do

function VehicleCount( player )
{
 local q = QuerySQL( db, "SELECT Vehicles FROM CountVehicle WHERE Name='" + player.Name + "'" )
 local count = GetSQLColumnData( q, 0 );
 FreeSQLQuery( q );
 return count;
}