-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #821 from bitpredator/dev
feat: [esx_addons]\esx_givevehicle
- Loading branch information
Showing
8 changed files
with
395 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
server-data/resources/[esx_addons]/esx_givevehicle/README.md
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,44 @@ | ||
# **Depiction:** | ||
This plugin you can give vehicle with custom or random plate number into player's garage with command | ||
also you can delete a vehicle by plate | ||
|
||
# **Commands:** | ||
**In game:** (give permission in config) | ||
|
||
Give a car to the target player: ``/givecar [playerID] [vehicle] <plate>`` | ||
Give a plane to the target player: ``/giveplane [playerID] [vehicle] <plate>`` | ||
Give a boat to the target player: ``/giveboat [playerID] [vehicle] <plate>`` | ||
Give a helicopter to the target player: ``/giveheli [playerID] [vehicle] <plate>`` | ||
*Note: If plate is none will randomly generate a new plate* | ||
|
||
Delete a owned car by plate: ``/delcarplate [plate]`` | ||
|
||
**On console:** (prefix need change to "_") | ||
``` | ||
_givecar [playerID] [car] <plate> | ||
_giveplane [playerID] [car] <plate> | ||
_giveboat [playerID] [car] <plate> | ||
_giveheli [playerID] [car] <plate> | ||
_delcarplate [plate] | ||
``` | ||
|
||
# **Config:** | ||
``` | ||
Config = {} | ||
Config.Locale = 'en' | ||
Config.ReceiveMsg = true | ||
-- Allow below identifier player to execute commands | ||
Config.AuthorizedRanks = { | ||
'superadmin', | ||
-- 'admin' | ||
} | ||
``` | ||
|
||
# **Requirements:** | ||
* es_extended | ||
* esx_vehicleshop | ||
|
||
FiveM Forum Release:https://forum.cfx.re/t/release-esx-give-or-delete-car-to-owned-vehicle-database-plate-can-custom-or-random-spawn/1050821 | ||
|
114 changes: 114 additions & 0 deletions
114
server-data/resources/[esx_addons]/esx_givevehicle/client/main.lua
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,114 @@ | ||
ESX = exports["es_extended"]:getSharedObject() | ||
|
||
TriggerEvent("chat:addSuggestion", "/givecar", "Give a car to player", { | ||
{ name = "id", help = "The ID of the player" }, | ||
{ name = "vehicle", help = "Vehicle model" }, | ||
{ name = "<plate>", help = "Vehicle plate, skip if you want random generate plate number" }, | ||
}) | ||
|
||
TriggerEvent("chat:addSuggestion", "/giveplane", "Give an airplane to player", { | ||
{ name = "id", help = "The ID of the player" }, | ||
{ name = "vehicle", help = "Vehicle model" }, | ||
{ name = "<plate>", help = "Vehicle plate, skip if you want random generate plate number" }, | ||
}) | ||
|
||
TriggerEvent("chat:addSuggestion", "/giveboat", "Give a boat to player", { | ||
{ name = "id", help = "The ID of the player" }, | ||
{ name = "vehicle", help = "Vehicle model" }, | ||
{ name = "<plate>", help = "Vehicle plate, skip if you want random generate plate number" }, | ||
}) | ||
|
||
TriggerEvent("chat:addSuggestion", "/giveheli", "Give a helicopter to player", { | ||
{ name = "id", help = "The ID of the player" }, | ||
{ name = "vehicle", help = "Vehicle model" }, | ||
{ name = "<plate>", help = "Vehicle plate, skip if you want random generate plate number" }, | ||
}) | ||
|
||
TriggerEvent("chat:addSuggestion", "/delcarplate", "Delete a owned vehicle by plate number", { | ||
{ name = "plate", help = "Vehicle's plate number" }, | ||
}) | ||
|
||
RegisterNetEvent("esx_giveownedcar:spawnVehicle") | ||
AddEventHandler("esx_giveownedcar:spawnVehicle", function(playerID, model, playerName, type, vehicleType) | ||
local playerPed = GetPlayerPed(-1) | ||
local coords = GetEntityCoords(playerPed) | ||
local carExist = false | ||
|
||
ESX.Game.SpawnVehicle(model, coords, 0.0, function(vehicle) --get vehicle info | ||
if DoesEntityExist(vehicle) then | ||
carExist = true | ||
SetEntityVisible(vehicle, false, false) | ||
SetEntityCollision(vehicle, false) | ||
|
||
local newPlate = exports.esx_vehicleshop:GeneratePlate() | ||
local vehicleProps = ESX.Game.GetVehicleProperties(vehicle) | ||
vehicleProps.plate = newPlate | ||
TriggerServerEvent("esx_giveownedcar:setVehicle", vehicleProps, playerID, vehicleType) | ||
ESX.Game.DeleteVehicle(vehicle) | ||
if type ~= "console" then | ||
ESX.ShowNotification(_U("gived_car", model, newPlate, playerName)) | ||
else | ||
local msg = ("addCar: " .. model .. ", plate: " .. newPlate .. ", toPlayer: " .. playerName) | ||
TriggerServerEvent("esx_giveownedcar:printToConsole", msg) | ||
end | ||
end | ||
end) | ||
|
||
Wait(2000) | ||
if not carExist then | ||
if type ~= "console" then | ||
ESX.ShowNotification(_U("unknown_car", model)) | ||
else | ||
TriggerServerEvent("esx_giveownedcar:printToConsole", "ERROR: " .. model .. " is an unknown vehicle model") | ||
end | ||
end | ||
end) | ||
|
||
RegisterNetEvent("esx_giveownedcar:spawnVehiclePlate") | ||
AddEventHandler("esx_giveownedcar:spawnVehiclePlate", function(playerID, model, plate, playerName, type, vehicleType) | ||
local playerPed = GetPlayerPed(-1) | ||
local coords = GetEntityCoords(playerPed) | ||
local generatedPlate = string.upper(plate) | ||
local carExist = false | ||
|
||
ESX.TriggerServerCallback("esx_vehicleshop:isPlateTaken", function(isPlateTaken) | ||
if not isPlateTaken then | ||
ESX.Game.SpawnVehicle(model, coords, 0.0, function(vehicle) --get vehicle info | ||
if DoesEntityExist(vehicle) then | ||
carExist = true | ||
SetEntityVisible(vehicle, false, false) | ||
SetEntityCollision(vehicle, false) | ||
|
||
local newPlate = string.upper(plate) | ||
local vehicleProps = ESX.Game.GetVehicleProperties(vehicle) | ||
vehicleProps.plate = newPlate | ||
TriggerServerEvent("esx_giveownedcar:setVehicle", vehicleProps, playerID, vehicleType) | ||
ESX.Game.DeleteVehicle(vehicle) | ||
if type ~= "console" then | ||
ESX.ShowNotification(_U("gived_car", model, newPlate, playerName)) | ||
else | ||
local msg = ("addCar: " .. model .. ", plate: " .. newPlate .. ", toPlayer: " .. playerName) | ||
TriggerServerEvent("esx_giveownedcar:printToConsole", msg) | ||
end | ||
end | ||
end) | ||
else | ||
carExist = true | ||
if type ~= "console" then | ||
ESX.ShowNotification(_U("plate_already_have")) | ||
else | ||
local msg = "ERROR: this plate is already been used on another vehicle" | ||
TriggerServerEvent("esx_giveownedcar:printToConsole", msg) | ||
end | ||
end | ||
end, generatedPlate) | ||
|
||
Wait(2000) | ||
if not carExist then | ||
if type ~= "console" then | ||
ESX.ShowNotification(_U("unknown_car", model)) | ||
else | ||
TriggerServerEvent("esx_giveownedcar:printToConsole", "ERROR: " .. model .. " is an unknown vehicle model") | ||
end | ||
end | ||
end) |
9 changes: 9 additions & 0 deletions
9
server-data/resources/[esx_addons]/esx_givevehicle/config.lua
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,9 @@ | ||
Config = {} | ||
Config.Locale = "en" | ||
|
||
Config.ReceiveMsg = true | ||
|
||
-- Allow below identifier player to execute commands | ||
Config.AuthorizedRanks = { | ||
"admin", | ||
} |
27 changes: 27 additions & 0 deletions
27
server-data/resources/[esx_addons]/esx_givevehicle/fxmanifest.lua
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,27 @@ | ||
fx_version("cerulean") | ||
game("gta5") | ||
|
||
author("MEENO") | ||
description("assign or remove the vehicle to a player via chat") | ||
|
||
version("1.0.2") | ||
server_scripts({ | ||
"@oxmysql/lib/MySQL.lua", | ||
"server/main.lua", | ||
}) | ||
|
||
shared_scripts({ | ||
"@es_extended/imports.lua", | ||
"@es_extended/locale.lua", | ||
"locales/*.lua", | ||
"config.lua", | ||
}) | ||
|
||
client_scripts({ | ||
"client/main.lua", | ||
}) | ||
|
||
dependency({ | ||
"es_extended", | ||
"esx_vehicleshop", | ||
}) |
8 changes: 8 additions & 0 deletions
8
server-data/resources/[esx_addons]/esx_givevehicle/locales/de.lua
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,8 @@ | ||
Locales["de"] = { | ||
["gived_car"] = "Fahrzeug ~y~%s~s~ mit dem Nummernschild ~y~%s~s~ wurde in ~g~%s~s~'s Garage gestellt.", | ||
["received_car"] = "Dein Fahrzeug mit dem Nummernschild ~y~%s~s~ wurde in Deine Garage gestellt.", | ||
["del_car"] = "Fahrzeug mit dem Kennzeichen ~y~%s~s~ gelöscht.", | ||
["none_plate"] = "Nummernschild Angabe fehlt.", | ||
["unknown_car"] = "Unbekanntes Fahrzeug", | ||
["plate_already_have"] = "Nummernschild bereits vergeben.", | ||
} |
8 changes: 8 additions & 0 deletions
8
server-data/resources/[esx_addons]/esx_givevehicle/locales/en.lua
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,8 @@ | ||
Locales["en"] = { | ||
["gived_car"] = "Vehicle ~y~%s ~s~with plate number ~y~ %s ~s~has been park into ~g~%s~s~'s garage", | ||
["received_car"] = "You received a vehicle with plate number ~y~%s", | ||
["del_car"] = "Has deleted a vehicle with plate number ~y~%s", | ||
["del_car_error"] = "Can't find vehicle with plate is ~y~%s", | ||
["unknown_car"] = "~r~Unknown vehicle model ~y~%s", | ||
["plate_already_have"] = "~r~This plate is already been used on another vehicle", | ||
} |
8 changes: 8 additions & 0 deletions
8
server-data/resources/[esx_addons]/esx_givevehicle/locales/tw.lua
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,8 @@ | ||
Locales["tw"] = { | ||
["gived_car"] = "已將 ~y~%s ~s~車牌為~y~ %s ~s~的車分配給 ~g~%s", | ||
["received_car"] = "你已收到一台車牌為 ~y~%s ~s~的車, 快去車庫看看吧!", | ||
["del_car"] = "已刪除一台車牌為 ~y~%s ~s~的車", | ||
["del_car_error"] = "~r~找不到車牌為 ~y~%s ~r~的車", | ||
["unknown_car"] = "~r~未知的車輛", | ||
["plate_already_have"] = "~r~此車牌已經有車輛擁有了, 請換一個車牌", | ||
} |
Oops, something went wrong.