Vice City: Multiplayer

Server Development => Scripting and Server Management => Script Showroom => Topic started by: rulk on September 10th, 2015, 08:00 PM

Title: Sunshine Auto's - by rulk
Post by: rulk on September 10th, 2015, 08:00 PM
Hya chaps,

Here is a complete Buycar/Sellcar script for public use.

please let me know of any issues you may have. I have fully tested it on both 64 and 32 bit systems.

Commands are used with the '/' prefix and are as follows;

-------------------------
       Included Files:
-------------------------

-------------------------
       How it works:
-------------------------
For example: VehicleID 1, is in array index 1.
VehicleID 2, is in array index 2.
VehicleID 3, is in array index 3.
... etc etc etc ...
Current properties are;
-------------------------
      INSTALL:
-------------------------

** NOTE:
            You must first run 'sql_create.nut' and import the table to your database.
        REMEMBER TO RUN IT AFTER YOU HAVE CREATED YOUR VEHICLES!!

1. Load the class
>> dofile("sunshine.nut");

2. Load the database data into the array.
>> SunshineAutos.LoadDatabase("sunshine.db");

3. We must save the array to the database on a regular basis ( once every 5 hours )
   I reccomend triggering it in an event that is used frequently.
>> SunshineAutos.SaveDatabase("sunshine.db");

** NOTE:
            Put s_cmds.nut in the same directory as you server.exe, or change the file paths.

-------------------------
STEP-BY-STEP INSTALL GUIDES
-------------------------
Method One - Using the old server.conf(https://www.scribd.com/doc/311209876/Sunshine-Autos-Method1)
Method Two - You created your vehicles using CreateVehicle()(https://www.scribd.com/doc/311210090/Sunshine-Autos-Method2)
Using the example Script(https://www.scribd.com/doc/311210125/SUNSHINE-AUTOS-Example-Script)


DOWNLOAD(http://files.thijn.ovh/download/582ed36e512d9f2923bbf88b2b41cf22/sunshine.zip)
Title: Re: Sunshine Auto's - by rulk
Post by: FinchDon on September 11th, 2015, 02:59 AM
Good Work
Title: Re: Sunshine Auto's - by rulk
Post by: Thijn on September 11th, 2015, 06:40 AM
Awesome work.

One thing I noticed is your use of string.find() for comparison. Is there a reason why you wouldn't just use == for comparison?
If someone was called Poop, and the vehicle is owned by PoopHead it will return true wouldn't it?



Mirror: http://vcmp.thijn.ovh/files/sunshine.zip
Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN on September 11th, 2015, 06:41 AM
NICE Work!!
Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN on September 11th, 2015, 06:43 AM
Thanks for the MIRROR, the site he gave was not working
Title: Re: Sunshine Auto's - by rulk
Post by: Thijn on September 11th, 2015, 06:49 AM
Another quick question about your sql_create script. You use "100,000" as price, which isn't an integer.
Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN on September 11th, 2015, 07:02 AM
Hmm, The database is not working
Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN on September 11th, 2015, 07:08 AM
OOps, I haven't executed the SQL file yet, thanks working

EDIT:-
The DB file is empty, and i don't know how to add, so please do tell me
Title: Re: Sunshine Auto's - by rulk
Post by: rulk on September 11th, 2015, 09:43 AM
Quote from Thijn on September 11th, 2015, 06:40 AM
One thing I noticed is your use of string.find() for comparison. Is there a reason why you wouldn't just use == for comparison?
If someone was called Poop, and the vehicle is owned by PoopHead it will return true wouldn't it?

Thank you thijn, I have Just tested and this is not the case. you had me worried for a min hehe
Quote from Thijn on September 11th, 2015, 06:49 AM
Another quick question about your sql_create script. You use "100,000" as price, which isn't an integer.
This is very true, Thank you.  I have updated the default price in sql_create.nut to be an integer. re--download from the link at the top.

Thank you for the mirror thijn.
Title: Re: Sunshine Auto's - by rulk
Post by: rulk on September 11th, 2015, 09:49 AM
Quote from KAKAN on September 11th, 2015, 07:08 AM
OOps, I haven't executed the SQL file yet, thanks working

EDIT:-
The DB file is empty, and i don't know how to add, so please do tell me
Hya KAKAN,

The Database is empty on purpose, you have to run sql_create.nut which gathers all your server vehicles into a sql dump file called blah.sql.

Then using your sql browser, select file -> import from sql file -> blah.sql.

A new table will then be created.

Hope this helps.

rulk
Title: Re: Sunshine Auto's - by rulk
Post by: Drake on September 11th, 2015, 11:16 AM
Hey @rulk ,
go through your private messages please.
Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN on September 11th, 2015, 02:18 PM
I have tried rulk , still then not working
Title: Re: Sunshine Auto's - by rulk
Post by: rulk on September 11th, 2015, 02:21 PM
Quote from KAKAN on September 11th, 2015, 02:18 PM
I have tried rulk , still then not working
whats not working exactly chap ?

1. Put sql_create.nut in the same directory as your server.exe

2. Open server.cfg, and put/change sqgamemode sql_create.nut

3. Run the server and a file named blah.sql is created in that directory

4. Open your sql browser and select 'import from sql file' and select blah.sql

5. A new table is now created containing all your vehicles.

we have now finished with sql_create.nut and blah.sql.

Next, run the example script by doing the following;

1. Put s_cmds.nut in the same directory as your server.exe

2. Open server.cfg, and put/change sqgamemode s_cmds.nut

3. Run the server and jump in-game.


hope this helps,

rulk
Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN on September 11th, 2015, 02:48 PM
I have vehicles using function.nut, how can i use it, I don't have any vehicles using server.conf file.
Title: Re: Sunshine Auto's - by rulk
Post by: rulk on September 11th, 2015, 04:40 PM
Quote from KAKAN on September 11th, 2015, 02:48 PM
I have vehicles using function.nut, how can i use it, I don't have any vehicles using server.conf file.
Thank you @KAKAN for bringing this to my attention.  Yes you can by doing the following.
Code: [Select]

// Create your vehicles
dofile("CreateVehicles.nut");

// Load the sql_create file
dofile("sql_create.nut" );

// Call the main function from that file, to create blah.sql
sql_create();
Title: Re: Sunshine Auto's - by rulk
Post by: rulk on September 11th, 2015, 06:32 PM
OK chaps, I decided to create a complete installation guide for you all - all methods have been fully tested.

Thank you for making me aware of these issues.

Hope this helps,

rulk.


----------------------
Creating the database.
----------------------


Method One - Using the old server.conf

1. Put sql_create.nut in the same directory as your server.exe

2. Open server.cfg, and put/change sqgamemode sql_create.nut

3. Run the server and a file named blah.sql is created in that directory

4. Open your sql browser and select 'import from sql file' and select blah.sql

5. A new table is now created containing all your vehicles.

we have now finished with sql_create.nut and blah.sql.


Method Two - You created your vehicles using CreateVehicle()

1. Put sql_create.nut in the same directory as your server.exe

2. Open up your main script and under OnScriptLoad() add the following;

// First Create your vehicles
dofile( "CreateVehicles.nut" );

// Or maybe you did.....
CreateVehicle( 145, 0, Vector( 0, 0, 0 ), 0, 0, 0 );

// Next, Load the sql_create.nut
dofile( sql_create.nut );

// Finally, call the main function from sql_create to iterate your server vehicles.
sql_create();

3. Run the server and a file named blah.sql is created in that directory

4. Open your sql browser and select 'import from sql file' and select blah.sql

5. A new table is now created containing all your vehicles.

we have now finished with sql_create.nut and blah.sql.



------------------------
Using the example Script
------------------------

Method One - Adding it to your own script

This example assumes your main script is in the same directory as your server.exe


1. Check the file paths...

2. Under onScriptLoad( ), add the following;

// Load the class
dofile("sunshine/sunshine.nut");

// Load into array 'MyVehicles'
SunshineAutos.LoadDatabase("sunshine/sunshine.db");

// Remember to give me credits :-)
print( "=== Loaded Sunshine Auto's v1.1 - By rulk ===" );

3. Copy and paste all of the code under onPlayerCommand() into your own script.

4. Run the server and jump in-game.



Method Two - Using it independently

1. Put s_cmds.nut in the same directory as your server.exe

2. Open server.cfg, and put/change sqgamemode s_cmds.nut

3. Run the server and jump in-game.

Finally....

REMEMBER TO SAVE REGULARY!!
SunshineAutos.SaveDatabase("sunshine/sunshine.db");   
Title: Re: Sunshine Auto's - by rulk
Post by: Thijn on September 11th, 2015, 06:36 PM
Mirror updated.

Your script is very well described rulk, it will definitely help new scripters.
Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN on September 11th, 2015, 06:50 PM
2nd thing,,,
// First Create your vehicles
dofile( "CreateVehicles.nut" );
Now there's a function name LoadVehs();
Which have the CreateVehicle thing, now tell me what shall i do? or the script will do itself
Title: Re: Sunshine Auto's - by rulk
Post by: rulk on September 11th, 2015, 07:00 PM
Quote from KAKAN on September 11th, 2015, 06:50 PM
2nd thing,,,
// First Create your vehicles
dofile( "CreateVehicles.nut" );
Now there's a function name LoadVehs();
Which have the CreateVehicle thing, now tell me what shall i do? or the script will do itself
// Load your vehicles first
LoadVehs();

// Load the script
dofile( "sql_create.nut" );

// Call the main function
sql_create();

@Thijn thank you chap
Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN on September 11th, 2015, 07:02 PM
Oh, Actually I was creating the cars after sql_create, so it wasn't working, THANKS, it working NOW!
Title: Re: Sunshine Auto's - by rulk
Post by: rulk on September 11th, 2015, 07:06 PM
Quote from KAKAN on September 11th, 2015, 07:02 PM
Oh, Actually I was creating the cars after sql_create, so it wasn't working, THANKS, it working NOW!
yay! I'm online for the next hour, so if you need anymore help, just let me know.

rulk
Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN on September 16th, 2015, 07:41 PM
Oye!
1 bug:-
on the buycar system, you do not check the money of the player, so i made it, just don't know if it'll work or not
Here it is:-
Code: [Select]
else if ( cmd == "buycar" )
{
// Lets first establish if your in a vehicle
if ( player.Vehicle == null ) MessagePlayer( ">> Error: you are not in a vehicle.", player );
else
{
// OK, we're in a vehicle, lets get it's instance into a variable.
local vehicle = player.Vehicle;

// Put the IsPurchased property into a variable, so we can access squirrel's VM built in manipulation functions for that data type.
local val = MyVehicles[ vehicle.ID ].IsPurchased;

// First, check its an empty value ( it's available to buy )
if ( ( val == null ) || ( val.len() == 0 ) )
{
if( stats[ player.ID ].Cash >= MyVehicles[ vehicle.ID ].VehiclePrice )
{
// Then Set the value in our array.
MyVehicles[ vehicle.ID ].IsPurchased = player.Name;

// Display whats going on.
MessagePlayer( ">> You have now purchased this vehicle.", player );

//Reduce his money
stats[ player.ID ].Cash -= MyVehicles[ vehicle.ID ].VehiclePrice;
}
else MessagePlayer("You don't have enough money to buy this car.",player);
}

// It's got a value, and is purchased, therefore, not avilable to buy
else MessagePlayer( ">> Error: Vehicle not avilable to purchase.", player );
}
}

Can u check it and tell me the errors?
Title: Re: Sunshine Auto's - by rulk
Post by: Thijn on September 16th, 2015, 08:04 PM
That would work if your cash is stored in that variable, yes.
Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN on September 16th, 2015, 08:13 PM
Thanks, rulk should add this as player.Cash, so it would work with everyone
Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN on September 21st, 2015, 07:14 PM
BUMP*
I want that each user can buy only 2 vehicles, how can i do it?
Any examples pl0x
Title: Re: Sunshine Auto's - by rulk
Post by: MacTavish on September 21st, 2015, 07:26 PM
Quote from KAKAN on September 21st, 2015, 07:14 PM
BUMP*
I want that each user can buy only 2 vehicles, how can i do it?
Any examples pl0x
Just check player vehiles through mycars function that if player already bought the 2 vehicles then throw a message
Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN on September 21st, 2015, 07:39 PM
How? I got no idea of doing it.
Title: Re: Sunshine Auto's - by rulk
Post by: rulk on September 21st, 2015, 08:07 PM
Quote from Kusanagi on September 21st, 2015, 07:26 PM
Quote from KAKAN on September 21st, 2015, 07:14 PM
BUMP*
I want that each user can buy only 2 vehicles, how can i do it?
Any examples pl0x
Just check player vehiles through mycars function that if player already bought the 2 vehicles then throw a message
@kusanagi is right, just alter the MyCars algorithm, like this....

Code: [Select]
function HowManyCars(player)
{
// Empty string for our output.
local output = "";

// Var to count how many vehicles the player ownes.
local count = 0;
 
// Iterate the array, using a foreach loop.
foreach ( obj in this[ MyArray ] )
{
if ( obj != null )
{
            // Add the object properties to a tmp variable, so we can access squirrel's VM built in manipulation functions for that data type.
              local tmp = obj.IsPurchased;

// Check the value is not null or empty
if ( ( tmp != null ) && ( tmp.len() > 0 ) )
{
// Perform a string comparison, if we get a match, increase our counter.
if ( tmp.find( player ) != null ) count++;
}
}
}

// return count as integer.
return count;
}
Title: Re: Sunshine Auto's - by rulk
Post by: Zeeshan.Bhatti on September 21st, 2015, 08:10 PM
Awesome broo..
Title: Re: Sunshine Auto's - by rulk
Post by: FinchDon on September 22nd, 2015, 02:46 AM
@KAKaN First Make A table VC in Which playername and count
on register iñsert into vc values nàme 0
then make GetVC and SetVC functions and add this on Buycar

else if ( GetVC( player ) >= 2  ) PrivMessage( player, "You already have two cars " );
else
{
SetVC( player, GetVC( player ) + 1 );
}

and same in. sell car -1
Title: Re: Sunshine Auto's - by rulk
Post by: MacTavish on September 22nd, 2015, 05:49 AM
Quote from FinchDon on September 22nd, 2015, 02:46 AM
@KAKaN First Make A table VC in Which playername and count
on register iñsert into vc values nàme 0
then make GetVC and SetVC functions and add this on Buycar

else if ( GetVC( player ) >= 2  ) PrivMessage( player, "You already have two cars " );
else
{
SetVC( player, GetVC( player ) + 1 );
}

and same in. sell car -1
@FinchDon  you know @rulk made this system on arrays so why you want someone to use and SQLite query again
Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN on September 22nd, 2015, 06:26 AM
Quote from rulk on September 21st, 2015, 08:07 PM
Quote from Kusanagi on September 21st, 2015, 07:26 PM
Quote from KAKAN on September 21st, 2015, 07:14 PM
BUMP*
I want that each user can buy only 2 vehicles, how can i do it?
Any examples pl0x
Just check player vehiles through mycars function that if player already bought the 2 vehicles then throw a message
@kusanagi is right, just alter the MyCars algorithm, like this....

Code: [Select]
function HowManyCars(player)
{
// Empty string for our output.
local output = "";

// Var to count how many vehicles the player ownes.
local count = 0;
 
// Iterate the array, using a foreach loop.
foreach ( obj in this[ MyArray ] )
{
if ( obj != null )
{
            // Add the object properties to a tmp variable, so we can access squirrel's VM built in manipulation functions for that data type.
              local tmp = obj.IsPurchased;

// Check the value is not null or empty
if ( ( tmp != null ) && ( tmp.len() > 0 ) )
{
// Perform a string comparison, if we get a match, increase our counter.
if ( tmp.find( player ) != null ) count++;
}
}
}

// return count as integer.
return count;
}
So i need to use somthing like this?
Code: [Select]
if( HowManyCars(player) >= 2 ) MessagePlayer("You have enough vehicles",player);
??
Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN on September 22nd, 2015, 06:51 AM
and yes, In the sell car system, I want the IsPurchased variable be null(just like in start)
So is this the correct way to use this?
Code: [Select]
MyVehicle[ vehicle.ID ].IsPurchased = null;

EDIT:-
I used this, but it isn't working :(
Code: [Select]
else if ( cmd == "sellcar" )
{
// A paremeter checks before we can transfer the vehicle.
if ( player.Vehicle == null ) MessagePlayer( ">> Error: you are not in a vehicle.", player );
else
{
// OK, we're in a vehicle, lets get it's instance into a variable.
local vehicle = player.Vehicle;

// Put the IsPurchased property into a variable, so we can access squirrel's VM built in manipulation functions for that data type.
local val = MyVehicles[ vehicle.ID ].IsPurchased;

// First, Check they own that vehicle.
if ( val == player.Name )
{
// OK, now Set the value in our array.
MyVehicles[ vehicle.ID ].IsPurchased == null;

//Return him the money
player.Cash += MyVehicles[ vehicle.ID ].VehiclePrice/2

// Display whats going on.
MessagePlayer( ">> You have now sold this vehicle", player );
}

// They do not own that vehicle.
else MessagePlayer( ">> Error: you do not own this vehicle.", player );
}
}

The problem is:- When i type /sellcar, it shows you have sold this vehicle, my money also increases, but the car is not sold
Title: Re: Sunshine Auto's - by rulk
Post by: rulk on September 22nd, 2015, 10:04 AM
try
Code: [Select]
MyVehicles[ vehicle.ID ].IsPurchased = "";

because VC-MP's null returns nullx0000000 or something similar.

Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN on September 22nd, 2015, 10:10 AM
Hmm, I'll
Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN on September 22nd, 2015, 01:22 PM
Doesn't work, same problem as before
Title: Re: Sunshine Auto's - by rulk
Post by: rulk on September 22nd, 2015, 01:51 PM
you do realise that you've put double "==" in the example you posted ??

It should be,

Code: [Select]
MyVehicles[ vehicle.ID ].IsPurchased = "";

Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN on September 22nd, 2015, 02:35 PM
Thanks, working now!
Title: Re: Sunshine Auto's - by rulk
Post by: rulk on October 27th, 2015, 04:04 PM
Updated to v1.1 -

Now only saves the vehicles you have purchased/Sold/Shared etc from the array to the database.

Thanks to @Thijn for the suggestion and @KAKAN for pointing it out.

Download link is in the first post. ( Example script included. )

Hope you enjoy.

rulk

Updated again
Sorry for any inconvenience
Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN on October 27th, 2015, 04:24 PM
No problem.
Nice work.
Title: Re: Sunshine Auto's - by rulk
Post by: Eva on May 1st, 2016, 11:17 AM
I dont know what i do wrong but i have tried Method One - Using the old server.conf and followed the steps.
My vehicles are in server config like this: <Vehicle model="191" x="-542.1738" y="792.2469" z="97.0344" angle="336.3952" col1="0" col2="0" world="1"/>
on scriptload i have added:  // Load the class
    dofile("scripts/sunshine.nut");
    // Load into array 'MyVehicles'
    SunshineAutos.LoadDatabase("scripts/sunshine.db");
    print( "=== Loaded Sunshine Auto's v1.1 - By rulk ===" );

and the Cmd's are in my main.nut

Everything is working exept after import the Sql.blah the Vehicles are not written to the db. it stays empty.

Did i miss something else?

Title: Re: Sunshine Auto's - by rulk
Post by: rulk on May 1st, 2016, 12:44 PM
hya @Ron
Have you run sql_create.nut to create blah.sql which contains a list of all the vehicles in your server?
Title: Re: Sunshine Auto's - by rulk
Post by: Eva on May 1st, 2016, 03:09 PM
yes i followed the steps of Method 1 and it created this sql.blah. then i imported it into sunshine.db but its emty with no vehicles here a pic.
(http://217.120.23.210/images/database.png)
Title: Re: Sunshine Auto's - by rulk
Post by: rulk on May 1st, 2016, 03:57 PM
Hya @Ron 

Before you start the following, just check blah.sql has all the necessary 'INSERT INTO'  sql statements in it.

assuming it does, try...

1. Delete your existing table, and write changes to the database.

2. Select: file -> import -> database from sql file

3. select blah.sql

4. Answer 'NO' to "Do you want to create a new database file to hold the imported data?"

5. Import complete message box will appear
Title: Re: Sunshine Auto's - by rulk
Post by: kennedyarz on May 1st, 2016, 06:44 PM
Sorry rulk, but I recommend one thing, better make a video tutorial which explains the entire process because there are not many who understand you.
Title: Re: Sunshine Auto's - by rulk
Post by: rulk on May 1st, 2016, 06:58 PM
hya @kennedyarz

He wanted to know how to import the file into his database.  There are hundreds of database viewers out there, i cant make a video for every one.
Title: Re: Sunshine Auto's - by rulk
Post by: kennedyarz on May 1st, 2016, 07:09 PM
just do it your method. so all will have an idea of how to do it, because as explains this very confusing.
Title: Re: Sunshine Auto's - by rulk
Post by: Thijn on May 1st, 2016, 07:25 PM
To be completely honest, if that's confusing you shouldn't be making a server and just stick to playing.
Title: Re: Sunshine Auto's - by rulk
Post by: kennedyarz on May 1st, 2016, 07:36 PM
then you come here to say that it is not confusing? is perfect you? because they think that this topic has both comments and so many questions? of course it is confusing. and by not knowing this I cannot have the knowledge to make a server? There are many experts in the script that are still asking about this method.
Title: Re: Sunshine Auto's - by rulk
Post by: Eva on May 1st, 2016, 08:16 PM
:( again empty, i did exactly as you said the message box appeared import succes but still its emty no vehicles there.
all vehicles are written in server.config and load when the server starts. i have the sql_create.nut in the folder were my server.exe is and the server.config. my other scripts are in the folder scripts.
Title: Re: Sunshine Auto's - by rulk
Post by: Thijn on May 1st, 2016, 09:00 PM
Quote from Ron on May 1st, 2016, 08:16 PM
:( again empty, i did exactly as you said the message box appeared import succes but still its emty no vehicles there.
all vehicles are written in server.config and load when the server starts. i have the sql_create.nut in the folder were my server.exe is and the server.config. my other scripts are in the folder scripts.
Read his post again. What does the sql file actually contain?
Also, do you actually load the sql_create.nut file, and are there any vehicles in your server at the time you're loading it?
Title: Re: Sunshine Auto's - by rulk
Post by: Eva on May 1st, 2016, 10:55 PM
Yes Thijn i have read :) the sql file when its created contains the following:
CREATE TABLE `MyVehicles` (          `VehicleID`   INTEGER,          `VehicleModel`   TEXT,          `VehicleCat`   TEXT,          `VehiclePrice`   INTEGER,          `IsPurchased`   TEXT,          `IsShared`   TEXT       );    

and yes i load the sql_create.nut, ofcourse otherwize i wouldnt have the sql.blah...   and yes when i start the server vehycles are there also in console msg vehicles loaded.

Title: Re: Sunshine Auto's - by rulk
Post by: kennedyarz on May 2nd, 2016, 12:33 AM
as well as thjin said "not if complicated is can not do this without server of the Nations United do surface" my opinion with respect is the truth I don't like the way you expressed.
Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN on May 2nd, 2016, 04:55 AM
Quote from Ron on May 1st, 2016, 10:55 PM
Yes Thijn i have read :) the sql file when its created contains the following:
CREATE TABLE `MyVehicles` (          `VehicleID`   INTEGER,          `VehicleModel`   TEXT,          `VehicleCat`   TEXT,          `VehiclePrice`   INTEGER,          `IsPurchased`   TEXT,          `IsShared`   TEXT       );    

and yes i load the sql_create.nut, ofcourse otherwize i wouldnt have the sql.blah...   and yes when i start the server vehycles are there also in console msg vehicles loaded.
Load it after 5 seconds. Maybe the vehicles were not created yet.
Title: Re: Sunshine Auto's - by rulk
Post by: rulk on May 2nd, 2016, 08:40 AM
Hya @Ron

A complete blah.sql should look like this

http://pastebin.com/raw/nVGTybrW

if it does, the script has worked. the rest is down to you to import it into your database.
Title: Re: Sunshine Auto's - by rulk
Post by: Eva on May 2nd, 2016, 09:10 AM
Thank you @rulk, i will try again. if it doesnt work,, i guess i can do it manualy instead with this blag.sql example then.
Title: Re: Sunshine Auto's - by rulk
Post by: rulk on May 2nd, 2016, 09:13 AM
you can, but is that what your blah.sql looks like ?
Title: Re: Sunshine Auto's - by rulk
Post by: rulk on May 2nd, 2016, 09:18 AM
@Ron

also, in server.cfg Make the xmlconf plugin first in the list.
Title: Re: Sunshine Auto's - by rulk
Post by: Eva on May 2nd, 2016, 09:39 AM
Quote from rulk on May 2nd, 2016, 09:13 AM
you can, but is that what your blah.sql looks like ?
No rulk, only the top part is there, not the vehicleslist like in your example.
And the xmlconf plugin allready was first in list.
but i will give it another shot today :) otherwize ill do it manualy, thanks a lot for you patiencce!
Title: Re: Sunshine Auto's - by rulk
Post by: rulk on May 2nd, 2016, 01:09 PM
I have added step-by-step installation guides with screenshots.  Hopefully it helps.

-------------------------
STEP-BY-STEP INSTALL GUIDES
-------------------------
Method One - Using the old server.conf(https://www.scribd.com/doc/311209876/Sunshine-Autos-Method1)
Method Two - You created your vehicles using CreateVehicle()(https://www.scribd.com/doc/311210090/Sunshine-Autos-Method2)
Using the example Script(https://www.scribd.com/doc/311210125/SUNSHINE-AUTOS-Example-Script)
Title: Re: Sunshine Auto's - by rulk
Post by: Eva on May 2nd, 2016, 06:42 PM
Did it manualy now and it works :) thnx

And rulk i looked at your screenshots manual and i do it exactly the same as you show, but it doesnt load the vehicles in sql.blah

and my vehicles are in server.config (old way).

anyway thanks again it works now :)
Title: Re: Sunshine Auto's - by rulk
Post by: kennedyarz on May 3rd, 2016, 11:33 PM
fucking mother cows do everything as this in the script but when I try to open the database of sunshine with this browser opens it me blank, not is that it happens, but I think it is the browser but other databases if you open them. before this example if it opened. What happened to the old sunshine? This is empty...
Title: Re: Sunshine Auto's - by rulk
Post by: rulk on May 4th, 2016, 08:41 AM
@kennedyarz

I haven't changed the database, It's meant to be empty. You need to populate it yourself using sql_create.nut.

See the documentation...

-------------------------
STEP-BY-STEP INSTALL GUIDES
-------------------------
Method One - Using the old server.conf(https://www.scribd.com/doc/311209876/Sunshine-Autos-Method1)
Method Two - You created your vehicles using CreateVehicle()(https://www.scribd.com/doc/311210090/Sunshine-Autos-Method2)
Using the example Script(https://www.scribd.com/doc/311210125/SUNSHINE-AUTOS-Example-Script)
Title: Re: Sunshine Auto's - by rulk
Post by: kennedyarz on May 4th, 2016, 10:59 PM
Error. When I open the browser I choose Import. then it displays a message and I option of duress in 'NO' then says "BROWSER. EXE STOPPED WORKING"
Title: Re: Sunshine Auto's - by rulk
Post by: Thijn on May 4th, 2016, 11:06 PM
What does your blah.sql contain?
Title: Re: Sunshine Auto's - by rulk
Post by: kennedyarz on May 4th, 2016, 11:08 PM
   CREATE TABLE `MyVehicles` (

         `VehicleID`   INTEGER,

         `VehicleModel`   TEXT,

         `VehicleCat`   TEXT,

         `VehiclePrice`   INTEGER,

         `IsPurchased`   TEXT,

         `IsShared`   TEXT

      );
Title: Re: Sunshine Auto's - by rulk
Post by: Thijn on May 4th, 2016, 11:29 PM
In that case read the install guide.
Title: Re: Sunshine Auto's - by rulk
Post by: kennedyarz on May 4th, 2016, 11:37 PM
help me in line for team views

This does not know that answer. but as he says "it is easy"
Title: Re: Sunshine Auto's - by rulk
Post by: Bob on May 13th, 2016, 01:13 PM
@rulk I haven't used your script but I have taken the time to read threw and I find it very interesting.
As well as your scripting methods,. This is an interesting release.

This is not a support forum,. @kennedyarz
Please respect author's post when needing help. A kind thing to do is create a support forum and message the content owner in PM that you could use there assistance,. and if the PM does not work just add a link to this post instead.

Also kennedyarz this is not something a rookie plays with or someone like myself technically, Yet I have been scripting for quite some time now. I suggest for you to take the time to read the scripts and study them understand how they work. Learn from rulk. This is not something you just add to a server due to either the server you own sucks and you want to be a boss server owner, This is more of a script you add when your server is successful and you want to treat your player base. Technically this script is pointless without a really decent player base.

@rulk I am glad you have taken the time to create this release for other scriptwriters to be capable to read and understand(if they actually will instead of just attempting to add it to a random server work^^^).
Honestly I do not see myself using this at all instead just reading and understanding.
~*Thank You
Title: Re: Sunshine Auto's - by rulk
Post by: Kewun on June 13th, 2016, 04:28 PM
i have a problem with this goddamn script
i have created the sql file thing it has 30 kb
whenever when i enter a car, and type /car nothing happens, and prints a error in to console
i entered a stinger, and typed /car
error:

AN ERROR HAS OCCURED [the index '113' does not exist]

line 33
 its:
Code: [Select]
local output = @"Model: " + MyVehicles[ vehicle.ID ].VehicleModel + " - "  +

i cant get it to working :( i already readed your installation guide, but i cant make it work
Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN on June 14th, 2016, 08:17 AM
Well, dump the .sql file to a database file and load that database. Usually, any SQLite viewer/editor can do this work.
Click on the import option, then select .sql as the option and locate the sql file.
Title: Re: Sunshine Auto's - by rulk
Post by: Kewun on June 14th, 2016, 03:04 PM
still the same error
i mean, how to import and then load to that database file?

nvm, i fixed myself

THX!!!
Title: Re: Sunshine Auto's - by rulk
Post by: Kewun on August 21st, 2016, 05:55 PM
Found a exploit in your script in the /buycar command

Players can buy car, but without money.

Code: [Select]

if ( cmd == "buycar" )
{
// Lets first establish if your in a vehicle
if ( player.Vehicle == null ) MessagePlayer( "[#ff0000]Error: you are not in a vehicle.", player );
else
{
// OK, we're in a vehicle, lets get it's instance into a variable.
local vehicle = player.Vehicle;

// Put the IsPurchased property into a variable, so we can access squirrel's VM built in manipulation functions for that data type.
local val = MyVehicles[ vehicle.ID ].IsPurchased;

// First, check its an empty value ( it's available to buy )
if ( ( val == null ) || ( val.len() == 0 ) )
{
// Then Set the value in our array.
MyVehicles[ vehicle.ID ].IsPurchased = player.Name;

// The array has been updated, so set our value to 'true' so we can save it to the database.
MyVehicles[ vehicle.ID ].Update = true;

// Display whats going on.
MessagePlayer( "[#ff0000]You have now purchased this vehicle.", player );
}

// It's got a value, and is purchased, therefore, not avilable to buy
else MessagePlayer( "[#ff0000]Error: Vehicle not avilable to purchase.", player );
}
}

there isnt any money checks , so a player can buy any car with 0$  in their pocket
Title: Re: Sunshine Auto's - by rulk
Post by: Kewun on August 21st, 2016, 06:48 PM
fixed

Code: [Select]
if ( cmd == "buycar" )
{
// Lets first establish if your in a vehicle
if ( player.Vehicle == null ) MessagePlayer( "[#ff0000]Error: you are not in a vehicle.", player );
else
{
// OK, we're in a vehicle, lets get it's instance into a variable.
local vehicle = player.Vehicle;

// Put the IsPurchased property into a variable, so we can access squirrel's VM built in manipulation functions for that data type.
local val = MyVehicles[ vehicle.ID ].IsPurchased;

// First, check its an empty value ( it's available to buy )
if ( player.Cash < MyVehicles[vehicle.ID].VehiclePrice ) {
PM("[#ff0000]Not enought cash",player)
return false;
}
if ( ( val == null ) || ( val.len() == 0 ) )
{
// Then Set the value in our array.
MyVehicles[ vehicle.ID ].IsPurchased = player.Name;

// The array has been updated, so set our value to 'true' so we can save it to the database.
MyVehicles[ vehicle.ID ].Update = true;
player.Cash -= MyVehicles[vehicle.ID].VehiclePrice;
// Display whats going on.
MessagePlayer( "[#ff0000]You have now purchased this vehicle.", player );
}

// It's got a value, and is purchased, therefore, not avilable to buy
else MessagePlayer( "[#ff0000]Error: Vehicle not avilable to purchase.", player );
}
}
Title: Re: Sunshine Auto's - by rulk
Post by: Kewun on August 28th, 2016, 04:15 PM
Quote from Kewun on August 21st, 2016, 06:48 PM
fixed

Code: [Select]
if ( cmd == "buycar" )
{
// Lets first establish if your in a vehicle
if ( player.Vehicle == null ) MessagePlayer( "[#ff0000]Error: you are not in a vehicle.", player );
else
{
// OK, we're in a vehicle, lets get it's instance into a variable.
local vehicle = player.Vehicle;

// Put the IsPurchased property into a variable, so we can access squirrel's VM built in manipulation functions for that data type.
local val = MyVehicles[ vehicle.ID ].IsPurchased;

// First, check its an empty value ( it's available to buy )
if ( player.Cash < MyVehicles[vehicle.ID].VehiclePrice ) {
PM("[#ff0000]Not enought cash",player)
return false;
}
if ( ( val == null ) || ( val.len() == 0 ) )
{
// Then Set the value in our array.
MyVehicles[ vehicle.ID ].IsPurchased = player.Name;

// The array has been updated, so set our value to 'true' so we can save it to the database.
MyVehicles[ vehicle.ID ].Update = true;
player.Cash -= MyVehicles[vehicle.ID].VehiclePrice;
// Display whats going on.
MessagePlayer( "[#ff0000]You have now purchased this vehicle.", player );
}

// It's got a value, and is purchased, therefore, not avilable to buy
else MessagePlayer( "[#ff0000]Error: Vehicle not avilable to purchase.", player );
}
}
i forgot a little thing, use MessagePlayer instead of PM because in my script i use PM created function.
Title: Re: Sunshine Auto's - by rulk
Post by: Kewun on August 30th, 2016, 06:01 AM
also, when i saved custom vehicles, in sql browser, their names are null(0x0000000000) ;c
Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN 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.
Title: Re: Sunshine Auto's - by rulk
Post by: Shovon^ on September 15th, 2016, 03:09 PM
dont we need the functionOnplayerEnterVehicle ??
Title: Re: Sunshine Auto's - by rulk
Post by: Kewun 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
Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN 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.
Title: Re: Sunshine Auto's - by rulk
Post by: Kewun on October 28th, 2016, 09:25 PM
yeah i ve tested this and im getting VehicleID index does not exist
ill try repair this
Title: Re: Sunshine Auto's - by rulk
Post by: Kewun 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
Title: Re: Sunshine Auto's - by rulk
Post by: . on October 28th, 2016, 11:40 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.
Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN 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. )
Title: Re: Sunshine Auto's - by rulk
Post by: 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
Title: Re: Sunshine Auto's - by rulk
Post by: MatheuS 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.
Title: Re: Sunshine Auto's - by rulk
Post by: Kewun 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
  ));
Title: Re: Sunshine Auto's - by rulk
Post by: KAKAN on November 1st, 2016, 12:20 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.
Title: Re: Sunshine Auto's - by rulk
Post by: Kewun 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?
Title: Re: Sunshine Auto's - by rulk
Post by: Cool on November 1st, 2016, 02:30 PM
simply u didnt defined VehicleID
Title: Re: Sunshine Auto's - by rulk
Post by: Kewun on November 1st, 2016, 05:08 PM
fixed
but another problem popped up
i add a car using /addcar carmodel colr1 colr2
works fine
but when ido /savecar, it saves in sunshine database
server restart - bam
vehicle names messed up, police vehicle is esperanto, some other police vehicle is sanchez, stallion is banshee
how i can fix this?
Title: Re: Sunshine Auto's - by rulk
Post by: Mahmoud Tornado on September 10th, 2017, 08:13 AM
Try This In It Too

Code: [Select]
function onPlayerEnterVehicle( player, veh, isPassenger )
{
local vehicle = player.Vehicle;

local output = @"Model: " + MyVehicles[ vehicle.ID ].VehicleModel + " - "  +
  "ID: " + MyVehicles[ vehicle.ID ].VehicleID + " - "  +
"Type: " + MyVehicles[ vehicle.ID ].VehicleCat    + " - "  +
"Price: " + MyVehicles[ vehicle.ID ].VehiclePrice;


local
      IsPurchased MyVehicles[ vehicle.ID ].IsPurchased.len() > 0 ? MyVehicles[ vehicle.ID ].IsPurchased  : "For Sale",
      IsShared = MyVehicles[ vehicle.ID ].IsShared.len()    > 0 ? MyVehicles[ vehicle.ID ].IsShared     : "Not Shared";


output = output + " - " + "Owner: " + IsPurchased + " - " + "Sharer: " + IsShared;

MessagePlayer( output, player );
}