Dynamic Vehicle & Dealership system [SQL] -
Private200 - 04.04.2016
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)
Re: Dynamic Vehicle & Dealership system [SQL] -
Gammix - 04.04.2016
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;
}
Re: Dynamic Vehicle & Dealership system [SQL] -
oMa37 - 04.04.2016
Nice one!
Re: Dynamic Vehicle & Dealership system [SQL] -
iKevin - 04.04.2016
Dope stuff man.
Re: Dynamic Vehicle & Dealership system [SQL] -
Stev - 04.04.2016
Very pretty looking!
Re: Dynamic Vehicle & Dealership system [SQL] -
Private200 - 05.04.2016
Quote:
Originally Posted by Gammix
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.
Re: Dynamic Vehicle & Dealership system [SQL] -
Airblog - 05.04.2016
Nice idea like it
Re: Dynamic Vehicle & Dealership system [SQL] -
OmegaKiller72 - 05.04.2016
What samp version it use? clear 0.3.7 dont work...
Re: Dynamic Vehicle & Dealership system [SQL] -
Private200 - 06.04.2016
Quote:
Originally Posted by OmegaKiller72
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.
Re: Dynamic Vehicle & Dealership system [SQL] -
Sew_Sumi - 06.04.2016
Quote:
Originally Posted by Private200
(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.
Re: Dynamic Vehicle & Dealership system [SQL] -
Private200 - 06.04.2016
Quote:
Originally Posted by Sew_Sumi
Solidfiles is terrible for this. Totally terrible.
|
Mirrors are appreciated, pastebin added as well.
Re: Dynamic Vehicle & Dealership system [SQL] -
Sew_Sumi - 06.04.2016
Seen that you used pastebin... Very good move.
Re: Dynamic Vehicle & Dealership system [SQL] -
Private200 - 07.04.2016
Quote:
Originally Posted by Sew_Sumi
Seen that you used pastebin... Very good move. 
|
Always for the best.
MEGA.NZ Link:
https://mega.nz/#!211wyQIL!HMVKoPiMI...9tDSCpuzJM8AP8
Re: Dynamic Vehicle & Dealership system [SQL] -
BlueBaron - 15.08.2016
Good script. Also if you need a mirror:
http://*******/88t0O6 (Direct .rar)
Re: Dynamic Vehicle & Dealership system [SQL] -
AndreiWow - 27.08.2016
Code:
D:\Basic RP Script Scratch FIX\pawno\include\easydb.inc(510) : error 017: undefined symbol "db_get_field_int"
D:\Basic RP Script Scratch FIX\pawno\include\easydb.inc(523) : error 017: undefined symbol "db_get_field_int"
D:\Basic RP Script Scratch FIX\pawno\include\easydb.inc(563) : error 017: undefined symbol "db_get_field_int"
D:\Basic RP Script Scratch FIX\pawno\include\easydb.inc(576) : error 017: undefined symbol "db_get_field_int"
D:\Basic RP Script Scratch FIX\pawno\include\easydb.inc(655) : error 017: undefined symbol "db_get_field_int"
D:\Basic RP Script Scratch FIX\filterscripts\dealership.pwn(121) : error 017: undefined symbol "db_get_field_int"
D:\Basic RP Script Scratch FIX\filterscripts\dealership.pwn(123) : error 017: undefined symbol "db_get_field_float"
D:\Basic RP Script Scratch FIX\filterscripts\dealership.pwn(438) : error 017: undefined symbol "db_get_field_int"
D:\Basic RP Script Scratch FIX\filterscripts\dealership.pwn(439) : error 017: undefined symbol "db_get_field_int"
D:\Basic RP Script Scratch FIX\filterscripts\dealership.pwn(440) : error 017: undefined symbol "db_get_field_int"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
10 Errors.
Re: Dynamic Vehicle & Dealership system [SQL] -
Tass007 - 28.08.2016
Quote:
Originally Posted by AndreiWow
Code:
D:\Basic RP Script Scratch FIX\pawno\include\easydb.inc(510) : error 017: undefined symbol "db_get_field_int"
D:\Basic RP Script Scratch FIX\pawno\include\easydb.inc(523) : error 017: undefined symbol "db_get_field_int"
D:\Basic RP Script Scratch FIX\pawno\include\easydb.inc(563) : error 017: undefined symbol "db_get_field_int"
D:\Basic RP Script Scratch FIX\pawno\include\easydb.inc(576) : error 017: undefined symbol "db_get_field_int"
D:\Basic RP Script Scratch FIX\pawno\include\easydb.inc(655) : error 017: undefined symbol "db_get_field_int"
D:\Basic RP Script Scratch FIX\filterscripts\dealership.pwn(121) : error 017: undefined symbol "db_get_field_int"
D:\Basic RP Script Scratch FIX\filterscripts\dealership.pwn(123) : error 017: undefined symbol "db_get_field_float"
D:\Basic RP Script Scratch FIX\filterscripts\dealership.pwn(438) : error 017: undefined symbol "db_get_field_int"
D:\Basic RP Script Scratch FIX\filterscripts\dealership.pwn(439) : error 017: undefined symbol "db_get_field_int"
D:\Basic RP Script Scratch FIX\filterscripts\dealership.pwn(440) : error 017: undefined symbol "db_get_field_int"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
10 Errors.
|
You need to download the included easyDB as it has been modified.
Quote:
Originally Posted by Private200
|
Re: Dynamic Vehicle & Dealership system [SQL] -
axellech - 01.11.2016
Wrong session
Re: Dynamic Vehicle & Dealership system [SQL] -
fonia5 - 01.11.2016
Really nice job.
maybe some ideas for the next update i know it's not hard to do X Y Z codes for dealerships but i would like to see that being dynamic. or maybe someone can edit it +REP
Re: Dynamic Vehicle & Dealership system [SQL] -
DeLeTs - 05.12.2017
Please data base connect problem
Re: Dynamic Vehicle & Dealership system [SQL] -
JesusChrysler - 09.12.2017
Nice job.