-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: extract financing to it's own table & fix: Finance vehicle menu
* feat: extract financing to it's own table * refactor: update storage functions to use the vehicle_financing table * refactor: use the finance function * feat: migration file * feat: get financed by plate & transfer check * fix: passing the wrong argument * feat: remove unused function * feat: player_vehicles should be in qbx_vehicles, DEFAULT NULL & id as FK * vehicleId as a primary key * Update migrate.sql * fix: a license can have multiple citizenid * fix: finance input & finance menu * Remove citizenId & plate from vehicle_financing * revert old export * use qbx_vehicles API & fix queries * Update storage.lua * use TinyInt * feat: remove storage function in favor of qbx_vehicles export
- Loading branch information
1 parent
557476e
commit 560999d
Showing
6 changed files
with
100 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
CREATE TABLE IF NOT EXISTS `vehicle_financing` ( | ||
`vehicleId` int(11) NOT NULL, | ||
`balance` int(11) DEFAULT NULL, | ||
`paymentamount` int(11) DEFAULT NULL, | ||
`paymentsleft` tinyint(4) DEFAULT NULL, | ||
`financetime` int(11) DEFAULT NULL, | ||
PRIMARY KEY (`vehicleId`), | ||
FOREIGN KEY `vehicleId` (`vehicleId`) REFERENCES `player_vehicles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE | ||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; | ||
|
||
INSERT INTO vehicle_financing (vehicleId, balance, paymentamount, paymentsleft, financetime) | ||
SELECT id, balance, paymentamount, paymentsleft, financetime | ||
FROM player_vehicles | ||
WHERE balance > 0 OR paymentamount > 0 OR paymentsleft > 0 OR financetime > 0; | ||
|
||
ALTER TABLE player_vehicles | ||
DROP COLUMN balance, | ||
DROP COLUMN paymentamount, | ||
DROP COLUMN paymentsleft, | ||
DROP COLUMN financetime; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,9 @@ | ||
CREATE TABLE IF NOT EXISTS `player_vehicles` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
`license` varchar(50) DEFAULT NULL, | ||
`citizenid` varchar(50) DEFAULT NULL, | ||
`vehicle` varchar(50) DEFAULT NULL, | ||
`hash` varchar(50) DEFAULT NULL, | ||
`mods` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, | ||
`plate` varchar(15) NOT NULL, | ||
`fakeplate` varchar(50) DEFAULT NULL, | ||
`garage` varchar(50) DEFAULT 'pillboxgarage', | ||
`fuel` int(11) DEFAULT 100, | ||
`engine` float DEFAULT 1000, | ||
`body` float DEFAULT 1000, | ||
`state` int(11) DEFAULT 1, | ||
`depotprice` int(11) NOT NULL DEFAULT 0, | ||
`drivingdistance` int(50) DEFAULT NULL, | ||
`status` text DEFAULT NULL, | ||
PRIMARY KEY (`id`), | ||
KEY `plate` (`plate`), | ||
KEY `citizenid` (`citizenid`), | ||
KEY `license` (`license`) | ||
) ENGINE=InnoDB AUTO_INCREMENT=1; | ||
|
||
ALTER TABLE `player_vehicles` | ||
ADD UNIQUE INDEX UK_playervehicles_plate (plate); | ||
|
||
ALTER TABLE `player_vehicles` | ||
ADD CONSTRAINT FK_playervehicles_players FOREIGN KEY (citizenid) | ||
REFERENCES `players` (citizenid) ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
ALTER TABLE `player_vehicles` | ||
ADD COLUMN `balance` int(11) NOT NULL DEFAULT 0; | ||
ALTER TABLE `player_vehicles` | ||
ADD COLUMN `paymentamount` int(11) NOT NULL DEFAULT 0; | ||
ALTER TABLE `player_vehicles` | ||
ADD COLUMN `paymentsleft` int(11) NOT NULL DEFAULT 0; | ||
ALTER TABLE `player_vehicles` | ||
ADD COLUMN `financetime` int(11) NOT NULL DEFAULT 0; | ||
CREATE TABLE IF NOT EXISTS `vehicle_financing` ( | ||
`vehicleId` int(11) NOT NULL, | ||
`balance` int(11) DEFAULT NULL, | ||
`paymentamount` int(11) DEFAULT NULL, | ||
`paymentsleft` int(11) DEFAULT NULL, | ||
`financetime` int(11) DEFAULT NULL, | ||
PRIMARY KEY (`vehicleId`), | ||
FOREIGN KEY `vehicleId` (`vehicleId`) REFERENCES `player_vehicles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, | ||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; |