Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Contract system for the resale of vehicles #873

Merged
merged 4 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@ INSERT INTO `bpt_items` (`name`, `label`) VALUES
('medikit', 'Medikit'),
('salmon_fillet', 'Salmon Fillet'),
('armour', 'armour'),
('WEAPON_FLASHLIGHT', 'WEAPON FLASHLIGHT')
('WEAPON_FLASHLIGHT', 'WEAPON FLASHLIGHT'),
('contract', 'Contract')
;
16 changes: 16 additions & 0 deletions server-data/resources/[bpt_addons]/bpt_crafting/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,21 @@ Config = {
["plastic_bag"] = 1,
},
},

["contract"] = {
Level = 0,
Category = "manufacturing",
isGun = false,
Jobs = { "import" },
JobGrades = {},
Amount = 2,
SuccessRate = 100,
requireBlueprint = false,
Time = 30,
Ingredients = {
["recycled_paper"] = 2,
},
},
},

Workbenches = { -- Every workbench location, leave {} for jobs if you want everybody to access
Expand All @@ -584,6 +599,7 @@ Config = {
"recycled_plastic",
"iron",
"diamond_tip",
"contract",
},
radius = 1.0,
},
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@ INSERT INTO `bpt_items` (`name`, `label`) VALUES
('medikit', 'Medikit'),
('salmon_fillet', 'Filetto di salmone'),
('armour', 'giubbotto antiproiettile'),
('WEAPON_FLASHLIGHT', 'Torcia')
('WEAPON_FLASHLIGHT', 'Torcia'),
('contract', 'Contratto per auto')
;
21 changes: 21 additions & 0 deletions server-data/resources/[esx_addons]/esx_contract/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Fred Richter

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 4 additions & 0 deletions server-data/resources/[esx_addons]/esx_contract/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# esx_contract
With this script you can sell a vehicle to another person. You just need a contract in your inventory.
There is no moneytransaction included.
It´s just a simple script to change the owner of a vehicle
38 changes: 38 additions & 0 deletions server-data/resources/[esx_addons]/esx_contract/client/main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
ESX = exports["es_extended"]:getSharedObject()

RegisterNetEvent("esx_contract:getVehicle")
AddEventHandler("esx_contract:getVehicle", function()
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
local closestPlayer, playerDistance = ESX.Game.GetClosestPlayer()

if closestPlayer ~= -1 and playerDistance <= 3.0 then
local vehicle = ESX.Game.GetClosestVehicle(coords)
local vehiclecoords = GetEntityCoords(vehicle)
local vehDistance = GetDistanceBetweenCoords(coords, vehiclecoords, true)
if DoesEntityExist(vehicle) and (vehDistance <= 3) then
local vehProps = ESX.Game.GetVehicleProperties(vehicle)
ESX.ShowNotification(TranslateCap("writingcontract", vehProps.plate))
TriggerServerEvent("esx_clothes:sellVehicle", GetPlayerServerId(closestPlayer), vehProps.plate)
else
ESX.ShowNotification(TranslateCap("nonearby"))
end
else
ESX.ShowNotification(TranslateCap("nonearbybuyer"))
end
end)

RegisterNetEvent("esx_contract:showAnim")
AddEventHandler("esx_contract:showAnim", function(player)
LoadAnimDict("anim@amb@nightclub@peds@")
TaskStartScenarioInPlace(PlayerPedId(), "WORLD_HUMAN_CLIPBOARD", 0, false)
Citizen.Wait(20000)
ClearPedTasks(PlayerPedId())
end)

function LoadAnimDict(dict)
while not HasAnimDictLoaded(dict) do
RequestAnimDict(dict)
Citizen.Wait(0)
end
end
3 changes: 3 additions & 0 deletions server-data/resources/[esx_addons]/esx_contract/config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Config = {}

Config.Locale = "en"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO `items` (`name`, `label`, `limit`, `rare`, `can_remove`) VALUES
('contract', 'Contract', '5', '0', '1');
24 changes: 24 additions & 0 deletions server-data/resources/[esx_addons]/esx_contract/fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
fx_version("adamant")

game("gta5")

description("esx_contract")

version("1.0.1")

shared_script("@es_extended/imports.lua")

server_scripts({
"@mysql-async/lib/MySQL.lua",
"@es_extended/locale.lua",
"locales/*.lua",
"config.lua",
"server/*.lua",
})

client_scripts({
"@es_extended/locale.lua",
"locales/*.lua",
"config.lua",
"client/*.lua",
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Locales["br"] = {
["writingcontract"] = "Contrato para a seguinte placa de veículo: %s",
["soldvehicle"] = "Você vendeu o veículo com o número de registro ~r~%s~s~",
["boughtvehicle"] = "Você comprou o veículo com o número de registro ~g~%s~s~",
["notyourcar"] = "Este veículo não é seu",
["nonearby"] = "Nenhum veículo nas proximidades",
["nonearbybuyer"] = "Nenhum comprador nas proximidades",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Locales["de"] = {
["writingcontract"] = "Vertrag für folgendes Kennzeichen: %s",
["soldvehicle"] = "Du hast das Fahrzeug mit dem Kennzeichen ~r~%s~s~ verkauft",
["boughtvehicle"] = "Du hast das Fahrzeug mit dem Kennzeichen ~g~%s~s~ gekauft",
["notyourcar"] = "Das ist nicht dein Fahrzeug",
["nonearby"] = "Kein Fahrzeug in der Nähe",
["nonearbybuyer"] = "Kein Käufer in der Nähe",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Locales["en"] = {
["writingcontract"] = "Contract for the following license plate: %s",
["soldvehicle"] = "You sold the vehicle with the registration number ~r~%s~s~",
["boughtvehicle"] = "You bought the vehicle with the registration number ~g~%s~s~",
["notyourcar"] = "This is not your vehicle",
["nonearby"] = "No vehicle nearby",
["nonearbybuyer"] = "No buyer nearby",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Locales["en"] = {
["writingcontract"] = "%s plakası için kontrat yazılıyor.",
["soldvehicle"] = "Aracı sicil numarasıyla sattınız. ~r~%s~s~",
["boughtvehicle"] = "Aracı sicil numarasıyla satın aldınız. ~g~%s~s~",
["notyourcar"] = "Bu araç senin değil!",
["nonearby"] = "Yakında araç bulunamadı.",
["nonearbybuyer"] = "Yakında alıcı bulunamadı.",
}
38 changes: 38 additions & 0 deletions server-data/resources/[esx_addons]/esx_contract/server/main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
ESX = exports["es_extended"]:getSharedObject()

RegisterServerEvent("esx_clothes:sellVehicle")
AddEventHandler("esx_clothes:sellVehicle", function(target, plate)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local _target = target
local tPlayer = ESX.GetPlayerFromId(_target)
local result = MySQL.Sync.fetchAll("SELECT * FROM owned_vehicles WHERE owner = @identifier AND plate = @plate", {
["@identifier"] = xPlayer.identifier,
["@plate"] = plate,
})
if result[1] ~= nil then
MySQL.Async.execute("UPDATE owned_vehicles SET owner = @target WHERE owner = @owner AND plate = @plate", {
["@owner"] = xPlayer.identifier,
["@plate"] = plate,
["@target"] = tPlayer.identifier,
}, function(rowsChanged)
if rowsChanged ~= 0 then
TriggerClientEvent("esx_contract:showAnim", _source)
Wait(22000)
TriggerClientEvent("esx_contract:showAnim", _target)
Wait(22000)
TriggerClientEvent("esx:showNotification", _source, TranslateCap("soldvehicle", plate))
TriggerClientEvent("esx:showNotification", _target, TranslateCap("boughtvehicle", plate))
xPlayer.removeInventoryItem("contract", 1)
end
end)
else
TriggerClientEvent("esx:showNotification", _source, TranslateCap("notyourcar"))
end
end)

ESX.RegisterUsableItem("contract", function(source)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
TriggerClientEvent("esx_contract:getVehicle", _source)
end)
6 changes: 6 additions & 0 deletions server-data/resources/[ox]/ox_inventory/data/items.lua
Original file line number Diff line number Diff line change
Expand Up @@ -759,4 +759,10 @@ return {
weight = 50,
stack = false,
},

["contract"] = {
label = "Contratto",
weight = 3,
stack = true,
},
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading