:-[
hi everyone.
you can see im here with another problem.
(https://i.ibb.co/ZxZDsCs/ggfg.png) (https://ibb.co/DQq2XnX)
error in LoadVehicle..
193th Line:while( GetSQLColumnData( q, 0 ) )
180thLine:LoadVehicles();
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.
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
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 )" );
Groovy, put an if statement before while( GetSQLColumnData( q, 0 ) )
i.e.if( q )
{
while( GetSQLColumnData( q, 0 ) )
{
.........
i++;
}
}
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;
}
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;
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 );
}
}
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 );
}
}
}
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:
Groovy, it is simple,
local q = QuerySQL( Vehicles, "SELECT * FROM Sale WHERE ID="+text);
if( ! q ) return;
local owner = GetSQLColumnData( q, 2 );
thanks for your help - but it didn't worked. ;(
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
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+"]" );
}
}
}
}
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.
Ok, it got fixed. bro but the whole vehicle system is bugged i tried every command every command had a bug :( i fixed 7-8 bugs.
but some bugs i can't fix so im asking for help here...
else if ( (cmd == "carforsale") || (cmd == "carsforsale") )
{
local V2="";
local V=false;
for( local VehicleID = 0; VehicleID <= 1000; VehicleID++ )
{
local q = QuerySQL( Vehicles, "SELECT * FROM Sale WHERE ID='"+VehicleID+"'" );
local owner = GetSQLColumnData( q, 2 );
if("Unowned" == owner)
{
V=true;
V2+=""+VehicleID+",";
}
}
if (V==true) MessagePlayer("Vehicles ID: "+V2+"",player)
if (V==false) MessagePlayer( "No cars for sale.", player );
}
:'( :-\ :-X :-[ :( >:(
else if ( (cmd == "carforsale") || (cmd == "carsforsale") )
{
local V2="";
local V=false;
for( local VehicleID = 0; VehicleID <= 1000; VehicleID++ )
{
local q = QuerySQL( Vehicles, "SELECT * FROM Sale WHERE ID="+VehicleID);
if( !q )continue;
local owner = GetSQLColumnData( q, 2 );
if("Unowned" == owner)
{
V=true;
V2+=""+VehicleID+",";
}
}
if (V==true) MessagePlayer("Vehicles ID: "+V2+"",player)
if (V==false) MessagePlayer( "No cars for sale.", player );
}
Note, Sale WHERE ID="+VehicleID);
@habi thanks for your help, i understood the logic xD. ;D
I suggest you to make new vehicle system because the last vehicle system is bugged.
Thanks 8)