Sunshine Auto's - by rulk

Started by rulk, Sep 10, 2015, 07:00 PM

Previous topic - Next topic

Kewun

also, when i saved custom vehicles, in sql browser, their names are null(0x0000000000) ;c

KAKAN

Quote from: Kewun on Aug 30, 2016, 05:01 AMalso, when i saved custom vehicles, in sql browser, their names are null(0x0000000000) ;c
That's because GetVehicleModel doesn't return custom vehicle's name. You need to create your own function and modify the script.
oh no

Shovon^

dont we need the functionOnplayerEnterVehicle ??
Iam the best and i only believe in Allah

Conatact me here on IRC:  #shovon^ @LUnet

Kewun

anyone knows how to add a vehicle to sunshine database when the vehicle is new and not in database?

i would need a command for this, because im adding new vehicles to server. so that i dont have to remove the sunshine.db and readingg and players losing cars

KAKAN

if( cmd == "newveh" ){
//Your work...
MyVehicles.push( SunshineAutos(
VehicleID = vehicle.ID,
VehicleModel = vehicle.Model,
VehicleCat = GetVehicleType( vehicle.Model ),
VehiclePrice = 1,
IsPurchased = false,
IsShared = null,
Update = true
);
//Update the database using SunshineAutos.SaveDatabase("sunshine/sunshine.db"); to save the changes.
}
Be sure to check his script before using this. I made this just to give an example. This won't work unless you make the necessary changes.
oh no

Kewun

yeah i ve tested this and im getting VehicleID index does not exist
ill try repair this

Kewun

if ( cmd == "add" )
{
if (!ReadIniBool("stats.ini","admin",player.UID2))
{
PM("nope",player)
return false;
}
if(!player.Vehicle)
{
PM("[#ff0000]You must be in car without stats in /car to add it",player)
return false;
}
SunshineAutos.LoadDatabase("sunshine/sunshine.db");    // getting error here!!!!!!!!!!
MyVehicles.push( SunshineAutos(
VehicleID = player.Vehicle.ID,
VehicleModel = player.Vehicle.Model,
VehicleCat = GetVehicleType( player.Vehicle.Model ),
VehiclePrice = rand()%100000,
IsPurchased = false,
IsShared = null,
Update = true
));
SunshineAutos.SaveDatabase("sunshine/sunshine.db");
PM("[#00ff00]Vehicle ID: "+player.Vehicle.ID+" pushed to database",player)
}

after this im getting

AN ERROR HAS OCCURED [trying to modify a class that has already been instantiated]
on line sunshineautos.loaddatabase
i commented it on code
and car doesnt get added to databse
note im noob in sqlite things

.

#82
Quote from: Kewun on Oct 28, 2016, 08:32 PM...

after this im getting

AN ERROR HAS OCCURED [trying to modify a class that has already been instantiated]
on line sunshineautos.loaddatabase
i commented it on code
and car doesnt get added to databse
note im noob in sqlite things


class Test
{
    var0 = 24
}

// Ok. No instance of Test exists so far
test.rawnewmember("var1", 82);

// Make an instance of Test
local t = Test()

// Error. I've already created instances of Test. I can't modify it now
test.rawnewmember("var2", 127);

You're probably modifying a class in LoadDatabase() function based on the information from the database. Such behavior is not allowed.
.

KAKAN

From your command:-
SunshineAutos.LoadDatabase("sunshine/sunshine.db");    // getting error here!!!!!!!!!!The database is already loaded. You can't do it again. Remove that line, its no longer needed. you can use SaveDatabase instead( you must do it after creating the vehicle, not before. )
@. , he probably won't understand you( I guess so. )
oh no

Kewun

yea but when i add vehicle ussing this
https://forum.vc-mp.org/?topic=1177.0

It gets in the sunshine db some how oor bugged and the database messes up, car names are messed, pcj is sanchez etc and random prices
i dont know how to fix it

MatheuS

Quote from: Kewun on Oct 29, 2016, 07:12 AMyea but when i add vehicle ussing this
https://forum.vc-mp.org/?topic=1177.0

It gets in the sunshine db some how oor bugged and the database messes up, car names are messed, pcj is sanchez etc and random prices
i dont know how to fix it

You are saving the vehicle with different structure between the two databases. The database used in "Sunshine's Auto" is different from that used in another script.
if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

Kewun

so how can I fix this? Putting
SaveDatabase("sunshine/sunshine.db")
Before
MyVehicles.push( SunshineAutos(
   VehicleID = player.Vehicle.ID,
   VehicleModel = player.Vehicle.Model,
   VehicleCat = GetVehicleType( player.Vehicle.Model ),
   VehiclePrice = rand()%100000,
   IsPurchased = false,
   IsShared = null,
   Update = true
  ));

KAKAN

#87
Put it after that. Atleast think of it before posting. Why are you saving the database before you've edited it?
Its like, opening your script, saving it( with no edits done yet. ) and then editing and closing. See? You saved nothing? That thing is the same.
oh no

Kewun

fuck, i cant fix it, too hard for me, im getting the index VehicleID doesnt exist error
can you fix this for me and give me the full command please?

Cool

simply u didnt defined VehicleID