Correctly declared functions does not work

Started by NicusorN5, Jan 24, 2018, 09:43 AM

Previous topic - Next topic

NicusorN5

The error occurs when calling CreateFirstCars(string val) function. ''

function onServerStart()
{
if(ReadIniString("general.ini","FirstRun","a") == null)
{
CreateFirstCars("true");
}
else CreateFirstCars("false");
vdb <- ConnectSQL("vehicles.sqlite");
if (vdb) print("Vehicles Database loaded Successfully");
::QuerySQL( vdb, "CREATE TABLE IF NOT EXISTS Vehicles ( Model INT, World INT, PX FLOAT, PY FLOAT, PZ FLOAT, Angle FLOAT, col1 INT, col2 INT)" );
LoadCars();
KillBannedCars();
}
CreateFirstCars() function:

function CreateFirstCars(val);
{
///id car 1
CreateVehicle(175,0,-390.767578,-470.624878,11.132923,Quaternion(0.001950,-0.001911,0.716955,0.697115),1,1);
if(val == "true") WriteIniInteger("CarsProps.ini","Fuel","1",100); //error occurs here for some reason.
if(val == "true") WriteIniString("PlayerStats.ini","Vehicle","1","For Sale");
///car2
CreateVehicle(131,0,-872.189148,-327.710785,10.902105,Quaternion(0.000134,0.000495,-0.056600,0.998397),0,1);
if(val == "true")WriteIniInteger("CarsProps.ini","Fuel","2",100);
if(val == "true")WriteIniString("PlayerStats.ini","Vehicle","2","For Sale");
///car3
CreateVehicle(149,0,-1026.603882,-893.886963,13.419139,Quaternion(-0.031039,0.037877,0.334466,0.941134),1,1);
if(val == "true")WriteIniInteger("CarsProps.ini","Fuel","3",100);
if(val == "true")WriteIniString("PlayerStats.ini","Vehicle","3","For Sale");
//car4
CreateVehicle(6402,0,-1034.992065,-855.320557,12.935251,Quaternion(0.000281,-0.001827,-0.926581,0.376090),107,1);
if(val == "true")WriteIniInteger("CarsProps.ini","Fuel","4",100);
if(val == "true")WriteIniString("PlayerStats.ini","Vehicle","4","For Sale");
//car5
return 1
CreateVehicle(130,0,-872.189148,-327.710785,10.902105,Quaternion(),1,1);
if(val == "true")WriteIniInteger("CarsProps.ini","Fuel","5",100);
if(val == "true")WriteIniString("PlayerStats.ini","Vehicle","5","For Sale");
//car6
CreateVehicle(6404,0,-872.189148,-327.710785,10.902105,Quaternion(),1,1);
if(val == "true")WriteIniInteger("CarsProps.ini","Fuel","6",100);
if(val == "true")WriteIniString("PlayerStats.ini","Vehicle","6","For Sale");
//car7
CreateVehicle(6406,0,-872.189148,-327.710785,10.902105,Quaternion(),1,1);
if(val == "true")WriteIniInteger("CarsProps.ini","Fuel","7",100);
if(val == "true")WriteIniString("PlayerStats.ini","Vehicle","7","For Sale");
//car8
CreateVehicle(6444,0,-872.189148,-327.710785,10.902105,Quaternion(),1,1);
if(val == "true")WriteIniInteger("CarsProps.ini","Fuel","8",100);
if(val == "true")WriteIniString("PlayerStats.ini","Vehicle","8","For Sale");
//car9
CreateVehicle(148,0,-872.189148,-327.710785,10.902105,Quaternion(),1,1);
if(val == "true")WriteIniInteger("CarsProps.ini","Fuel","9",100);
if(val == "true")WriteIniString("PlayerStats.ini","Vehicle","9","For Sale");
//car10
CreateVehicle(213,0,-872.189148,-327.710785,10.902105,Quaternion(),1,1);
if(val == "true")WriteIniInteger("CarsProps.ini","Fuel","10",100);
if(val == "true")WriteIniString("PlayerStats.ini","Vehicle","10","For Sale");
//car11
CreateVehicle(156,0,-872.189148,-327.710785,10.902105,Quaternion(),1,1);
if(val == "true")WriteIniInteger("CarsProps.ini","Fuel","11",100);
if(val == "true")WriteIniString("PlayerStats.ini","Vehicle","11","For Sale");
//car12
CreateVehicle(156,0,-872.189148,-327.710785,10.902105,Quaternion(),1,1);
if(val == "true")WriteIniInteger("CarsProps.ini","Fuel","12",100);
if(val == "true")WriteIniString("PlayerStats.ini","Vehicle","12","For Sale");
//car13
CreateVehicle(6407,0,-872.189148,-327.710785,10.902105,Quaternion(),1,1);
if(val == "true")WriteIniInteger("CarsProps.ini","Fuel","13",100);
if(val == "true")WriteIniString("PlayerStats.ini","Vehicle","13","For Sale");
//car14
CreateVehicle(140,0,-872.189148,-327.710785,10.902105,Quaternion(),1,1);
if(val == "true")WriteIniInteger("CarsProps.ini","Fuel","14",100);
if(val == "true")WriteIniString("PlayerStats.ini","Vehicle","14","For Sale");
//car15
CreateVehicle(6419,0,-872.189148,-327.710785,10.902105,Quaternion(),1,1);
if(val == "true")WriteIniInteger("CarsProps.ini","Fuel","15",100);
if(val == "true")WriteIniString("PlayerStats.ini","Vehicle","15","For Sale");
}

The error is 'the index 'val' DOES NOT EXISTS' . But as you can see, i wrote my function correctly. I double checked all the { } . They are all correct.

NicusorN5

LOL I just fixed it myself again. deleting a ; after the (val) fixed it.