« [ GameMode ] ADM Script v1.0
Sunshine Auto's - by rulk
[ #D~ Tools ] Textdraw & Sprite Editor! »

Kewun

  • Hero Member
  • Posts: 785
Re: Sunshine Auto's - by rulk
« Reply #75, on August 30th, 2016, 06:01 AM »
also, when i saved custom vehicles, in sql browser, their names are null(0x0000000000) ;c

KAKAN

  • Wiki Contributor
  • Posts: 3,343
Re: Sunshine Auto's - by rulk
« Reply #76, on August 30th, 2016, 09:25 AM »
Quote from Kewun on August 30th, 2016, 06:01 AM
also, 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.
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN

Shovon^

  • Jr. Member
  • yay Ahnaf is my friend.....
  • Posts: 84
Iam the best and i only believe in Allah

Conatact me here on IRC:  #shovon^ @LUnet

Kewun

  • Hero Member
  • Posts: 785
Re: Sunshine Auto's - by rulk
« Reply #78, on October 27th, 2016, 08:32 PM »
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

  • Wiki Contributor
  • Posts: 3,343
Re: Sunshine Auto's - by rulk
« Reply #79, on October 28th, 2016, 10:20 AM »
Code: [Select]
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.
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN

Kewun

  • Hero Member
  • Posts: 785
Re: Sunshine Auto's - by rulk
« Reply #80, on October 28th, 2016, 09:25 PM »
yeah i ve tested this and im getting VehicleID index does not exist
ill try repair this
Re: Sunshine Auto's - by rulk
« Reply #81, on October 28th, 2016, 09:32 PM »
Code: [Select]
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

.

  • VC:MP Beta Tester
  • .
  • Posts: 1,806
Re: Sunshine Auto's - by rulk
« Reply #82, on October 28th, 2016, 11:40 PM »Last edited on October 28th, 2016, 11:42 PM
Quote from Kewun on October 28th, 2016, 09: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
Code: [Select]
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

  • Wiki Contributor
  • Posts: 3,343
Re: Sunshine Auto's - by rulk
« Reply #83, on October 29th, 2016, 05:03 AM »
From your command:-
Code: [Select]
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. )
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN

Kewun

  • Hero Member
  • Posts: 785

MatheuS

  • Wiki Contributor
  • LBR | Co-Leader & Brasil Real RPG | Developer
  • Posts: 469
Re: Sunshine Auto's - by rulk
« Reply #85, on October 29th, 2016, 01:37 PM »
Quote from Kewun on October 29th, 2016, 08:12 AM
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
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.
Code: [Select]
if( !sucess ) tryAgain();

Kewun

  • Hero Member
  • Posts: 785
Re: Sunshine Auto's - by rulk
« Reply #86, on November 1st, 2016, 10:24 AM »
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

  • Wiki Contributor
  • Posts: 3,343
Re: Sunshine Auto's - by rulk
« Reply #87, on November 1st, 2016, 12:20 PM »Last edited on November 1st, 2016, 12:22 PM
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.
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN

Kewun

  • Hero Member
  • Posts: 785
Re: Sunshine Auto's - by rulk
« Reply #88, on November 1st, 2016, 02:29 PM »
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

  • Hero Member
  • Posts: 719

« [ GameMode ] ADM Script v1.0
[ #D~ Tools ] Textdraw & Sprite Editor! »