function not working

Started by kokia, Aug 03, 2015, 07:22 AM

Previous topic - Next topic

kokia

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

kokia


Mashreq

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 );
}

Thijn

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;
}

kokia

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

MacTavish

#5
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;
}

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P