Skip to content

Commit

Permalink
Update v1.5
Browse files Browse the repository at this point in the history
Added spawnveh Command
  • Loading branch information
Musiker15 committed Feb 24, 2023
1 parent 9607b5c commit f22165f
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 2 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ Give Vehicles with Command or Item and Delete Vehicles with Command

> Example: /delveh "LS 1234"
```
```lua
-- Spawns a owned vehicle at PlayerID coords
/spawnveh <playerID> <plate>

> Example: /spawnveh 1 "LS 1234"
```

## Console Command Usage ##
```lua
Expand Down Expand Up @@ -56,6 +62,12 @@ _delveh <plate>

> Example: _delveh "LS 1234"
```
```lua
-- Spawns a owned vehicle at PlayerID coords
spawnveh <playerID> <plate>

> Example: spawnveh 1 "LS 1234"
```
## Requirements ##
* [ESX 1.2 and above](https://github.com/esx-framework/esx_core)
* [oxmysql](https://github.com/overextended/oxmysql)
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4
1.5
12 changes: 12 additions & 0 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ for i = 48, 57 do table.insert(Charset, string.char(i)) end
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_givevehicle:spawnVehicle')
AddEventHandler('msk_givevehicle:spawnVehicle', function(props)
local playerPed = PlayerPedId()

ESX.Game.SpawnVehicle(props.model, GetEntityCoords(playerPed), GetEntityHeading(playerPed), function(vehicle)
if DoesEntityExist(vehicle) then
ESX.Game.SetVehicleProperties(vehicle, props)
Config.FuelSystem(vehicle, props.fuelLevel)
end
end)
end)

RegisterNetEvent('msk_givevehicle:giveVehicle')
AddEventHandler('msk_givevehicle:giveVehicle', function(item, veh)
local playerPed = PlayerPedId()
Expand Down
9 changes: 9 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,21 @@ Config.AdminGroups = {'superadmin', 'admin'} -- You can set multiple groups
Config.Command = 'giveveh' -- Read the Readme.md for Command Usage
Config.Command2 = 'delveh' -- Read the Readme.md for Command Usage
Config.Command3 = 'givejobveh' -- Read the Readme.md for Command Usage
Config.Command4 = 'spawnveh' -- Read the Readme.md for Command Usage // You can use this at the console too

-- Console Commands
Config.ConsoleCommand = '_giveveh' -- Read the Readme.md for Command Usage
Config.ConsoleCommand2 = '_delveh' -- Read the Readme.md for Command Usage
Config.ConsoleCommand3 = '_givejobveh' -- Read the Readme.md for Command Usage
----------------------------------------------------------------
Config.FuelSystem = function(vehicle, fuelLevel) -- Only for Command4: spawnveh
-- LegacyFuel
exports['LegacyFuel']:SetFuel(vehicle, fuelLevel)

-- FiveM Native
-- SetVehicleFuelLevel(vehicle, fuelLevel)
end

Config.Plate = {
format = 'XXX XXX', -- 'XXX XXX' or 'XX XXXX'

Expand Down
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ games { 'gta5' }
author 'Musiker15 - MSK Scripts'
name 'msk_givevehicle'
description 'Give or Delete Vehicles with Command or Item'
version '1.4'
version '1.5'

shared_scripts {
'config.lua',
Expand Down
15 changes: 15 additions & 0 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,21 @@ ESX.RegisterCommand(Config.Command3, Config.AdminGroups, function(xPlayer, args,
{name = 'plate', help = '"Plate" (optional)', type = 'string'}
}})

-- You can use this command at the console too
ESX.RegisterCommand(Config.Command4, Config.AdminGroups, function(xPlayer, args, showError) -- /spawnveh <playerID> <plate>
MySQL.query("SELECT * FROM owned_vehicles WHERE plate = @plate", {
['@plate'] = args.plate
}, function(result)
if result and result[1] then
args.player.triggerEvent('msk_givevehicle:spawnVehicle', json.decode(result[1].vehicle))
MySQL.query("UPDATE owned_vehicles SET stored = 0 WHERE plate = @plate", {['@plate'] = args.plate})
end
end)
end, true, {help = 'Spawn Owned Vehicle by Plate', arguments = {
{name = 'player', help = 'PlayerID', type = 'player'},
{name = 'plate', help = '"Plate"', type = 'string'}
}})

-- Console Commands
RegisterCommand(Config.ConsoleCommand, function(source, args, rawCommand) -- _giveveh <playerID> <categorie> <carModel> <plate>
if (source == 0) then
Expand Down

0 comments on commit f22165f

Please sign in to comment.