SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts

Reply
 
Thread Tools Display Modes
Old 04/04/2016, 10:36 PM   #1
Private200
High-roller
 
Private200's Avatar
 
Join Date: May 2012
Posts: 1,176
Reputation: 211
Default Dynamic Vehicle & Dealership system [SQL]

DYNAMIC
Vehicle & Dealership



_________________________________________________

Introduction

I started this project as one of my first dynamic systems. I had given this one a try long time before, using Y_INI, however, it didn't work out as expected. It was wasting way too many resources for something that could've been done easily using MySQL. As I am not an professional MySQL programmer, thought of giving SQL a try. I'd really like to give a big shout and thank to Gammix, this project would not be as cool as it is if it wouldn't be for him.

Credits

Gammix: The project was pretty plain before I used his dialogs. There wasn't anything special other than an old school MSGBOX dialog. Thanks to his dialogs include (included in the package), I could give 'style' to the dialog, making it have this awesome design it currently has. He has also helped me with code snippets, so yeah, a big shout to him! Shall not forget about his easyDB include![/B]
ZCMD: Command processing
Incognito: Streamer for dynamic checkpoints
******: Sscanf
SAMP: Pawno


Explanations and examples

RCON COMMANDS:

/createdealership [dealership name] - Creates a dealership, you name it.
/addvehicle [model] [price] [dealership name] - Creates a vehicle, adding it into the dealership using the model for the car and the price to buy. ONLY ONE CAR OF THE SAME MODEL CAN BE ADDED PER DEALERSHIP!
/deletevehicle [model] [dealership name] - deletes a vehicle (reference: model) from a specific dealership
/dealershipcars [dealership name] - checks all the cars in a dealership (MAX 24 cars per dealership!)

PLAYER COMMANDS:

/buypark - Chooses a new parking spot for the vehicle
/park - parks the vehicle and makes it disappear after
/mycars - shows a list of all the cars you have (max. of a 5 vehicles can be bought)
/buycar - allows you to buy a vehicle while in range of a dealership

IMPORTANT NOTE
HOW TO ADD A DEALERSHIP


As there will be multiple dealerships, it is not right for the script to have a specific location for the dealership, therefore I've added an option that allows the user to chose the dealership and configure it himself. I've already made an example using "Grotti", dealership created and used in the video below as well:

pawn Code:
new DealershipLocations[][DealershipInfo] =
{
    {542.9274,-1292.7112,17.2422, 526.5967,-1284.5935,16.9692, "Grotti"}
};

What each of those coordinates means is already explained in the script as well, however, here we go again:

Code:
PosX ( Range of point for player to buy car)
PosY
PosZ
___________________________________________

SpawnX ( Positions where cars will spawn after buying )
SpawnY
SpawnZ
___________________________________________

Dealership name (describes itself || MUST BE DEALERSHIP DATABASE NAME!)
NOTE: You must be using the name you used for the dealership in the database as that's how the script connects the enum with the database and retrieves the vehicles from the table. If the dealership name in the script is not the same with the dealership name in the database, server issues and problems may show up! YOU HAVE BEEN WARNED.

Video & pictures

Sorry for the noise in the background, including breathing. Forgot to mute mic.
Dealership buying menu isn't shown, but it's same as /mycars.

[ame]http://www.youtube.com/watch?v=2RKB8JVxv8k[/ame]


Download and virustotal

PasteBin: http://pastebin.com/t1APeCX1

Mega.NZ Mirror [RAR PACKAGE]: https://mega.nz/#!211wyQIL!HMVKoPiMI...9tDSCpuzJM8AP8

RAR: http://www.solidfiles.com/v/BqWxM8eZVXx66
(easyDB is included as it is modified to fit my needs)

VirusTotal: https://virustotal.com/en/file/a69d3...is/1459804445/
(for some reasons my chrome marked the file as malicious when downloading, so I added this to make sure there's nothing wrong with it)
__________________
just a signature

Last edited by Private200; 04/05/2016 at 10:43 PM.
Private200 is offline   Reply With Quote
Old 04/04/2016, 11:00 PM   #2
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,772
Reputation: 854
Default Re: Dynamic Vehicle & Dealership system [SQL]

You don't seem to use EasyDB well. There are lot of areas where you still are performing DB::Query where it could be easily done with EasyDB functions.

Example
Your code:
pawn Code:
stock UpdatePlayerVehicle(playerid, vehicleid)
{
    new query[256], dbid = vInfo[vehicleid][dbID];
    format(query, sizeof query, "UPDATE `Vehicles` SET PosX = '%f', PosY = '%f',PosZ = '%f', Angle='%f' WHERE id='%d'",
    vInfo[vehicleid][vPos_X], vInfo[vehicleid][vPos_Y], vInfo[vehicleid][vPos_Z], vInfo[vehicleid][vAngle], dbid);
    DB::Query(query, false);
    printf("Vehicle ID %d has been saved. [%s vehicle]", vehicleid, GetName(playerid));
    return 1;
}

My code:
pawn Code:
stock UpdatePlayerVehicle(playerid, vehicleid)
{
    DB::MultiSet(vTable, vInfo[vehicleid][dbID], "ffff", "PosX", vInfo[vehicleid][vPos_X], "PosY", vInfo[vehicleid][vPos_Y], "PosZ", vInfo[vehicleid][vPos_Z], "Angle", vInfo[vehicleid][vAngle]);
   
    printf("Vehicle ID %d has been saved. [%s vehicle]", vehicleid, GetName(playerid));
    return 1;
}
__________________

Follow me on Github: Follow me on Spotify: Donate on Paypal:

Gammix is offline   Reply With Quote
Old 04/04/2016, 11:03 PM   #3
oMa37
Gangsta
 
Join Date: Feb 2016
Posts: 968
Reputation: 155
Default Re: Dynamic Vehicle & Dealership system [SQL]

Nice one!
oMa37 is offline   Reply With Quote
Old 04/04/2016, 11:10 PM   #4
iKevin
Gangsta
 
iKevin's Avatar
 
Join Date: Nov 2015
Location: In my throne
Posts: 565
Reputation: 71
Default Re: Dynamic Vehicle & Dealership system [SQL]

Dope stuff man.
iKevin is offline   Reply With Quote
Old 04/04/2016, 11:50 PM   #5
Stev
Big Clucker
 
Join Date: Oct 2013
Location: United Kingdom
Posts: 150
Reputation: 17
Default Re: Dynamic Vehicle & Dealership system [SQL]

Very pretty looking!
Stev is offline   Reply With Quote
Old 05/04/2016, 10:07 AM   #6
Private200
High-roller
 
Private200's Avatar
 
Join Date: May 2012
Posts: 1,176
Reputation: 211
Default Re: Dynamic Vehicle & Dealership system [SQL]

Quote:
Originally Posted by Gammix View Post
You don't seem to use EasyDB well. There are lot of areas where you still are performing DB::Query where it could be easily done with EasyDB functions.

Example
Your code:
pawn Code:
stock UpdatePlayerVehicle(playerid, vehicleid)
{
    new query[256], dbid = vInfo[vehicleid][dbID];
    format(query, sizeof query, "UPDATE `Vehicles` SET PosX = '%f', PosY = '%f',PosZ = '%f', Angle='%f' WHERE id='%d'",
    vInfo[vehicleid][vPos_X], vInfo[vehicleid][vPos_Y], vInfo[vehicleid][vPos_Z], vInfo[vehicleid][vAngle], dbid);
    DB::Query(query, false);
    printf("Vehicle ID %d has been saved. [%s vehicle]", vehicleid, GetName(playerid));
    return 1;
}

My code:
pawn Code:
stock UpdatePlayerVehicle(playerid, vehicleid)
{
    DB::MultiSet(vTable, vInfo[vehicleid][dbID], "ffff", "PosX", vInfo[vehicleid][vPos_X], "PosY", vInfo[vehicleid][vPos_Y], "PosZ", vInfo[vehicleid][vPos_Z], "Angle", vInfo[vehicleid][vAngle]);
   
    printf("Vehicle ID %d has been saved. [%s vehicle]", vehicleid, GetName(playerid));
    return 1;
}
I will check for speed enhancement once I will be home. It's my first time touching easydb so am not familiar with all the features, however I guess both functions do the job.

EDIT: Ran a speed check and yeah, yours is being executed faster.
__________________
just a signature

Last edited by Private200; 05/04/2016 at 07:48 PM.
Private200 is offline   Reply With Quote
Old 05/04/2016, 02:19 PM   #7
Airblog
Huge Clucker
 
Airblog's Avatar
 
Join Date: Sep 2014
Location: IR
Posts: 270
Reputation: 30
Default Re: Dynamic Vehicle & Dealership system [SQL]

Nice idea like it
Airblog is offline   Reply With Quote
Old 05/04/2016, 11:56 PM   #8
OmegaKiller72
Big Clucker
 
Join Date: Sep 2013
Location: Ukraine
Posts: 92
Reputation: 0
Default Re: Dynamic Vehicle & Dealership system [SQL]

What samp version it use? clear 0.3.7 dont work...
OmegaKiller72 is offline   Reply With Quote
Old 06/04/2016, 06:00 AM   #9
Private200
High-roller
 
Private200's Avatar
 
Join Date: May 2012
Posts: 1,176
Reputation: 211
Default Re: Dynamic Vehicle & Dealership system [SQL]

Quote:
Originally Posted by OmegaKiller72 View Post
What samp version it use? clear 0.3.7 dont work...
Try 0.3.7 R2-1. I will check into the problem as soon as I get home.
__________________
just a signature
Private200 is offline   Reply With Quote
Old 06/04/2016, 06:22 AM   #10
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,251
Reputation: 525
Default Re: Dynamic Vehicle & Dealership system [SQL]

Quote:
Originally Posted by Private200 View Post
(for some reasons my chrome marked the file as malicious when downloading, so I added this to make sure there's nothing wrong with it)
Solidfiles is terrible for this. Totally terrible.
Sew_Sumi is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Dynamic Dealership System SlashQ Filterscripts 35 30/07/2015 11:26 AM
[FilterScript] Dynamic Vehicle System - h-Dealership; 0.3z HY Filterscripts 17 20/06/2015 07:47 AM
Looking for a Vehicle Dealership System, someone help? Gregaaa Scripting Help 2 01/09/2013 03:24 PM
Totally dynamic vehicle dealership DRIFT_HUNTER Scripting Help 1 21/07/2013 05:31 AM


All times are GMT. The time now is 07:02 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.