-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
463 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,36 @@ | ||
# msk_vehicleItems | ||
Give or Delete Vehicles with Command or Item | ||
Give or Delete Vehicles with Command or Item | ||
|
||
**PLATE is OPTIONAL** | ||
|
||
## Ingame Command Usage ## | ||
|
||
/giveveh <playerID> <categorie> <carModel> <plate> | ||
/giveveh <playerID> <categorie> <carModel> <plate> | ||
/giveveh <playerID> <categorie> <carModel> <plate> | ||
/giveveh <playerID> <categorie> <carModel> <plate> | ||
|
||
> Example: /giveveh 1 car zentorno "LS 1234" | ||
> Example: /giveveh 1 boat zentorno "LS 1234" | ||
> Example: /giveveh 1 aircraft zentorno "LS 1234" | ||
> Example: /giveveh 1 helicopter zentorno "LS 1234" | ||
/delveh <plate> | ||
|
||
> Example: /delveh "LS 1234" | ||
## Console Command Usage ## | ||
|
||
_giveveh <playerID> <categorie> <carModel> <plate> | ||
_giveveh <playerID> <categorie> <carModel> <plate> | ||
_giveveh <playerID> <categorie> <carModel> <plate> | ||
_giveveh <playerID> <categorie> <carModel> <plate> | ||
|
||
> Example: _giveveh 1 car zentorno LS 1234 | ||
> Example: _giveveh 1 boat zentorno LS 1234 | ||
> Example: _giveveh 1 aircraft zentorno LS 1234 | ||
> Example: _giveveh 1 helicopter zentorno LS 1234 | ||
_delveh <plate> | ||
|
||
> Example: _delveh LS 1234 |
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 @@ | ||
1.0 |
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,102 @@ | ||
ESX = nil | ||
if Config.ESX.version:match('1.2') then | ||
Citizen.CreateThread(function() | ||
while ESX == nil do | ||
TriggerEvent(Config.ESX.getSharedObject, function(obj) ESX = obj end) | ||
Citizen.Wait(0) | ||
end | ||
end) | ||
elseif Config.ESX.version:match('legacy') then | ||
ESX = exports["es_extended"]:getSharedObject() | ||
end | ||
|
||
local Charset = {} | ||
for i = 65, 90 do table.insert(Charset, string.char(i)) end | ||
for i = 97, 122 do table.insert(Charset, string.char(i)) end | ||
|
||
RegisterNetEvent('msk_vehicleItems:giveVehicle') | ||
AddEventHandler('msk_vehicleItems:giveVehicle', function(item, veh) | ||
local playerPed = PlayerPedId() | ||
local playerCoords = GetEntityCoords(playerPed) | ||
|
||
ESX.Game.SpawnVehicle(veh.model, playerCoords, 0.0, function(vehicle) | ||
if DoesEntityExist(vehicle) then | ||
SetEntityVisible(vehicle, false, false) | ||
SetEntityCollision(vehicle, false) | ||
|
||
local vehicleProps = ESX.Game.GetVehicleProperties(vehicle) | ||
vehicleProps.plate = genPlate() | ||
TriggerServerEvent('msk_vehicleItems:setVehicle', item, vehicleProps, veh.categorie) | ||
ESX.Game.DeleteVehicle(vehicle) | ||
end | ||
end) | ||
end) | ||
|
||
RegisterNetEvent('msk_vehicleItems:giveVehicleCommand') | ||
AddEventHandler('msk_vehicleItems:giveVehicleCommand', function(target, categorie, model, plate, console) | ||
local playerPed = PlayerPedId() | ||
local playerCoords = GetEntityCoords(playerPed) | ||
local newPlate | ||
local carExist = false | ||
|
||
if plate then | ||
newPlate = plate | ||
else | ||
newPlate = genPlate() | ||
end | ||
|
||
ESX.Game.SpawnVehicle(model, playerCoords, 0.0, function(vehicle) | ||
if DoesEntityExist(vehicle) then | ||
carExist = true | ||
SetEntityVisible(vehicle, false, false) | ||
SetEntityCollision(vehicle, false) | ||
|
||
local vehicleProps = ESX.Game.GetVehicleProperties(vehicle) | ||
vehicleProps.plate = newPlate | ||
TriggerServerEvent('msk_vehicleItems:setVehicleCommand', target, categorie, model, newPlate, vehicleProps, console) | ||
ESX.Game.DeleteVehicle(vehicle) | ||
debug('Vehicle registered') | ||
end | ||
end) | ||
|
||
Wait(2000) | ||
if not carExist then | ||
Config.Notification(source, 'client', nil, Translation[Config.Locale]['clientCommand'] .. model .. Translation[Config.Locale]['clientCommand2']) | ||
end | ||
end) | ||
|
||
function genPlate() | ||
local plate | ||
if Config.Plate.format:match('XXX XXX') then | ||
plate = string.upper(GetRandomLetter(3)) .. ' ' .. math.random(001, 999) | ||
elseif Config.Plate.format:match('XX XXXX') then | ||
if Config.Plate.enablePrefix then | ||
plate = Config.Plate.prefix .. ' ' .. math.random(0001, 9999) | ||
else | ||
plate = string.upper(GetRandomLetter(2)) .. ' ' .. math.random(0001, 9999) | ||
end | ||
end | ||
|
||
return plate | ||
end | ||
|
||
function GetRandomLetter(length) | ||
Wait(0) | ||
if length > 0 then | ||
return GetRandomLetter(length - 1) .. Charset[math.random(1, #Charset)] | ||
else | ||
return '' | ||
end | ||
end | ||
|
||
function debug(msg, msg2, msg3) | ||
if Config.Debug then | ||
if msg3 then | ||
print(msg, msg2, msg3) | ||
elseif not msg3 and msg2 then | ||
print(msg, msg2) | ||
else | ||
print(msg) | ||
end | ||
end | ||
end |
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,52 @@ | ||
Config = {} | ||
---------------------------------------------------------------- | ||
Config.Locale = 'de' | ||
Config.VersionChecker = false | ||
Config.Debug = true | ||
|
||
Config.ESX = { | ||
version = 'legacy', -- Set '1.2' or 'legacy' | ||
getSharedObject = 'esx:getSharedObject' -- Only needed if version set to '1.2' | ||
} | ||
---------------------------------------------------------------- | ||
-- !!! This function is clientside AND serverside !!! | ||
-- Look for type == 'client' and type == 'server' | ||
Config.Notification = function(src, type, xPlayer, message) -- xPlayer = ESX.GetPlayerFromId(src) | ||
if type == 'client' then -- clientside | ||
ESX.ShowNotification(message) -- replace this with your Notify | ||
elseif type == 'server' then -- serverside | ||
xPlayer.showNotification(message) -- replace this with your Notify | ||
end | ||
end | ||
---------------------------------------------------------------- | ||
Config.MySQL = { | ||
type = 'type', -- Type Column | ||
stored = 'stored', -- Stored Column | ||
} | ||
|
||
Config.AdminGroups = {'superadmin', 'admin'} -- You can set multiple groups | ||
-- Ingame Commands | ||
Config.Command = 'giveveh' -- Read the Readme.md for Command Usage | ||
Config.Command2 = 'delveh' -- Read the Readme.md for Command Usage | ||
-- Console Commands | ||
Config.ConsoleCommand = '_giveveh' -- Read the Readme.md for Command Usage | ||
Config.ConsoleCommand2 = '_delveh' -- Read the Readme.md for Command Usage | ||
|
||
Config.Plate = { | ||
format = 'XXX XXX', -- 'XXX XXX' or 'XX XXXX' | ||
|
||
enablePrefix = true, -- Set to false if you want Random Letters | ||
prefix = 'PX' -- Only if format = 'XX XXXX' // Looks like 'PX 1234' | ||
} | ||
---------------------------------------------------------------- | ||
-- You can give Player an Item and they can use the Item to get a Vehicle | ||
Config.Vehicles = { | ||
["zentorno"] = { -- Item Name | ||
model = 'zentorno', -- Vehicle Name | ||
categorie = 'car' -- Vehicle Categorie | ||
}, | ||
["seashark"] = { -- Item Name | ||
model = 'seashark', -- Vehicle Name | ||
categorie = 'boat' -- Vehicle Categorie | ||
}, | ||
} |
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 'adamant' | ||
games { 'gta5' } | ||
|
||
author 'Musiker15 - MSK Scripts' | ||
name 'msk_vehicleItems' | ||
description 'Give or Delete Vehicles with Command or Item' | ||
version '1.0' | ||
|
||
lua54 'yes' | ||
|
||
escrow_ignore { | ||
'config.lua', | ||
} | ||
|
||
shared_scripts { | ||
'config.lua', | ||
'translation.lua' | ||
} | ||
|
||
client_scripts { | ||
'client.lua', | ||
} | ||
|
||
server_scripts { | ||
'@mysql-async/lib/MySQL.lua', | ||
'server.lua' | ||
} |
Oops, something went wrong.