[FilterScript] Dynamic Vehicle & Dealership system [SQL]
#1

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)
Reply
#2

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;
}
Reply
#3

Nice one!
Reply
#4

Dope stuff man.
Reply
#5

Very pretty looking!
Reply
#6

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.
Reply
#7

Nice idea like it
Reply
#8

What samp version it use? clear 0.3.7 dont work...
Reply
#9

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.
Reply
#10

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.
Reply
#11

Quote:
Originally Posted by Sew_Sumi
View Post
Solidfiles is terrible for this. Totally terrible.
Mirrors are appreciated, pastebin added as well.
Reply
#12

Seen that you used pastebin... Very good move.
Reply
#13

Quote:
Originally Posted by Sew_Sumi
View Post
Seen that you used pastebin... Very good move.
Always for the best.

MEGA.NZ Link: https://mega.nz/#!211wyQIL!HMVKoPiMI...9tDSCpuzJM8AP8
Reply
#14

Good script. Also if you need a mirror: http://*******/88t0O6 (Direct .rar)
Reply
#15

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.
Reply
#16

Quote:
Originally Posted by AndreiWow
View Post
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
View Post
RAR: http://www.solidfiles.com/v/BqWxM8eZVXx66
(easyDB is included as it is modified to fit my needs)
Reply
#17

Wrong session
Reply
#18

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
Reply
#19

Please data base connect problem
Reply
#20

Nice job.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)