Problem with KrLozZ's Vehicle System.

Started by Groovy, Apr 14, 2020, 05:32 PM

Previous topic - Next topic

Groovy

:-[
hi everyone.
you can see im here with another problem.


error in LoadVehicle..

193th Line:while( GetSQLColumnData( q, 0 ) )180thLine:LoadVehicles();

habi

a bit late.. if the problem is still not solved,
Groovy, you posted the error line. Good, but we need more of the codes around the line '193' above and below. to see where the problem is. why don't you post the entire LoadVehicles() function.

umar4911

Check the database if it has values in it or you might have problems in the query. I guess since you're using krlozz vehicle system, you might problems in the database, the table must be empty
I am gamer, programmer and hacker. Try to find me!
xD

Groovy

function LoadVehicles()
{
local q = QuerySQL( Vehicles, "SELECT * FROM Creation" ), i = 0;
while( GetSQLColumnData( q, 0 ) )
{
local
Model= GetSQLColumnData( q, 1 ),
X= GetSQLColumnData( q, 2 ),
Y= GetSQLColumnData( q, 3 ),
Z= GetSQLColumnData( q, 4 ),
Col1= GetSQLColumnData( q, 5 ),
Col2= GetSQLColumnData( q, 6 ),
World= GetSQLColumnData( q, 7 ),
Angle= GetSQLColumnData( q, 8 );
CreateVehicle( Model, World, Vector(X, Y, Z), Angle, Col1, Col2 );
GetSQLNextRow( q );
i++;
}
print("Vehicles Count ("+i+")");
return 0;
}

Database:
Vehicles <- ConnectSQL( "Databases/Vehicles.db" );

QuerySQL(Vehicles, "CREATE TABLE IF NOT EXISTS Creation ( id NUMERIC, model NUMERIC, x NUMERIC, y NUMERIC, z NUMERIC, col1 NUMERIC, col2 NUMERIC, world NUMERIC, angle NUMERIC)" );
QuerySQL(Vehicles, "CREATE TABLE IF NOT EXISTS Sale ( ID NUMERIC, Cost NUMERIC, Owner TEXT, Shared TEXT, Shared2 TEXT )" );

habi

Groovy, put an if statement before while( GetSQLColumnData( q, 0 ) )
i.e.if( q )
{
      while( GetSQLColumnData( q, 0 ) )
      {
           .........
           i++;
       }
}

Groovy

 i did this but still same error 8)
function LoadVehicles()
{
local q = QuerySQL( Vehicles, "SELECT * FROM Creation" ), i = 0;
if( q )
{
      while( GetSQLColumnData( q, 0 ) )
      {
           i++;
      }
}
local
Model= GetSQLColumnData( q, 1 ),
X= GetSQLColumnData( q, 2 ),
Y= GetSQLColumnData( q, 3 ),
Z= GetSQLColumnData( q, 4 ),
Col1= GetSQLColumnData( q, 5 ),
Col2= GetSQLColumnData( q, 6 ),
World= GetSQLColumnData( q, 7 ),
Angle= GetSQLColumnData( q, 8 );
CreateVehicle( Model, World, Vector(X, Y, Z), Angle, Col1, Col2 );
GetSQLNextRow( q );
i++;
print("Vehicles Count ("+i+")");
return 0;
}

habi

not like that Groovy. You need to put the entire code inside if. that is
local q = QuerySQL( Vehicles, "SELECT * FROM Creation" ), i = 0;
if( q )
{
while( GetSQLColumnData( q, 0 ) )
{
local
Model= GetSQLColumnData( q, 1 ),
X= GetSQLColumnData( q, 2 ),
Y= GetSQLColumnData( q, 3 ),
Z= GetSQLColumnData( q, 4 ),
Col1= GetSQLColumnData( q, 5 ),
Col2= GetSQLColumnData( q, 6 ),
World= GetSQLColumnData( q, 7 ),
Angle= GetSQLColumnData( q, 8 );
CreateVehicle( Model, World, Vector(X, Y, Z), Angle, Col1, Col2 );
GetSQLNextRow( q );
i++;
}
}
print("Vehicles Count ("+i+")");
return 0;

Groovy

habi this error is fixed but when i enter in vehicle so error show in console:
local
full code
function onPlayerEnterVehicle( player, veh, isPassenger )
{
local VehicleID2 = QuerySQL( Vehicles, "SELECT * FROM Sale" );
if(VehicleID2)
{
local q = QuerySQL( Vehicles, "SELECT * FROM Sale WHERE ID='"+veh.ID+"'" );
local
Cost=GetSQLColumnData( q, 1 ),
Owner=GetSQLColumnData( q, 2 ),
Share=GetSQLColumnData( q, 3 ),
Sharer=GetSQLColumnData( q, 4 );
MessagePlayer( "ID: "+veh.ID+". Cost: "+Cost+".", player );
MessagePlayer( "Owner: "+Owner+". Shares: "+Share+" & "+Sharer+".", player );
}
}

habi

#8
The " ' "+veh.ID+" ' " is  causing the problem, see fixed code below
function onPlayerEnterVehicle( player, veh, isPassenger )
{
local VehicleID2 = QuerySQL( Vehicles, "SELECT * FROM Sale" );
if(VehicleID2)
{
local q = QuerySQL( Vehicles, "SELECT * FROM Sale WHERE ID="+veh.ID );
if ( q )
{
local
Cost=GetSQLColumnData( q, 1 ),
Owner=GetSQLColumnData( q, 2 ),
Share=GetSQLColumnData( q, 3 ),
Sharer=GetSQLColumnData( q, 4 );
MessagePlayer( "ID: "+veh.ID+". Cost: "+Cost+".", player );
MessagePlayer( "Owner: "+Owner+". Shares: "+Share+" & "+Sharer+".", player );
}
}
}

Groovy

habi this worked but the whole vehicle system is bugged. :(

local q = QuerySQL( Vehicles, "SELECT * FROM Sale WHERE ID='"+text+"'" );
local owner = GetSQLColumnData( q, 2 );

error in these line :null parameters:

habi

Groovy, it is simple,
local q = QuerySQL( Vehicles, "SELECT * FROM Sale WHERE ID="+text);
if( ! q ) return;
local owner = GetSQLColumnData( q, 2 );

Groovy

thanks for your help - but it didn't worked. ;(

habi

#12
i think you are fixing cmd "sellcar".
The cars are not added to database. So first go to game and use "addcar" to create a vehicle.
could you post your entire code. the whole main.nut

Groovy

i fixed everything bro's

Now other error:
In this whole code. T_T

else if ( cmd == "setowner" )
{
   
    if ( stats[ player.ID ].Reg == false ) return MessagePlayer( "[#95fcff]WARN > [#E0E0E0]You're not registered.", player );
else if ( stats[ player.ID ].Log == false ) return MessagePlayer( "[#95fcff]WARN > [#E0E0E0]You're not Logged-In", player );
else if ( !text ) MessagePlayer("[#95fcff]WARN > [#E0E0E0]Command: /"+cmd+" <Nick/ID> <Veh/ID>", player);
else if ( !IsOwnerOrSharer( veh, player ) ) MessagePlayer("[#95fcff]WARN > [#E0E0E0]This vehicle is not belong to you", player );
else {
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if ( !plr ) MessagePlayer("[#95fcff]WARN > [#E0E0E0]Unkown Player.", player );
else {
local veh = FindVehicle( GetTok( text, " ", 2 ).tointeger() );
if ( !veh ) MessagePlayer("[#95fcff]WARN > [#E0E0E0]Unkown vehicle ID", player );
else {
local q = QuerySQL( Vehicles, "SELECT * FROM Sale WHERE ID='"+veh.ID+"'" );
QuerySQL( Vehicles, "UPDATE Sale SET Owner='"+player.Name+"' WHERE ID='"+veh.ID+"'" );
Message( "[#95fcff]INFO > [#E0E0E0]Admin ["+player.Name+"] gave, Vehicle ID: "+veh.ID+" New Owner ["+plr.Name+"]" );
}
}
}
}

habi

#14
Quote from: Groovy on Apr 18, 2020, 04:39 PMi fixed everything bro's
Nice to know it.
Is somebody editing KrLozZ's vehicle system for you? I mean, the original codes i checked are a bit different from that you posted.
This time i fix the code for you.
else if ( cmd == "setowner" )
{   
if ( stats[ player.ID ].Reg == false ) return MessagePlayer( "[#95fcff]WARN > [#E0E0E0]You're not registered.", player );
else if ( stats[ player.ID ].Log == false ) return MessagePlayer( "[#95fcff]WARN > [#E0E0E0]You're not Logged-In", player );
else if ( !text ) MessagePlayer("[#95fcff]WARN > [#E0E0E0]Command: /"+cmd+" <Nick/ID> <Veh/ID>", player);
else
{
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if ( !plr ) MessagePlayer("[#95fcff]WARN > [#E0E0E0]Unkown Player.", player );
else
{
local veh = FindVehicle( GetTok( text, " ", 2 ).tointeger() );
if ( !veh ) MessagePlayer("[#95fcff]WARN > [#E0E0E0]Unkown vehicle ID", player );
else if ( !IsOwnerOrSharer( veh, player ) ) MessagePlayer("[#95fcff]WARN > [#E0E0E0]This vehicle is not belong to you", player );
else
{
QuerySQL( Vehicles, "UPDATE Sale SET Owner='"+player.Name+"' WHERE ID="+veh.ID);
Message( "[#95fcff]INFO > [#E0E0E0]Admin ["+player.Name+"] gave, Vehicle ID: "+veh.ID+" New Owner ["+plr.Name+"]" );
}
}
}
}
Next time, if you post any errors, you must include the screenshot of the console.