Skip to content

Commit

Permalink
Moved setammo to server
Browse files Browse the repository at this point in the history
  • Loading branch information
GhzGarage committed Nov 3, 2023
1 parent 46b9c05 commit 42a2bf8
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 132 deletions.
90 changes: 36 additions & 54 deletions client/events.lua
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
-- Variables

local blockedPeds = {
"mp_m_freemode_01",
"mp_f_freemode_01",
"tony",
"g_m_m_chigoon_02_m",
"u_m_m_jesus_01",
"a_m_y_stbla_m",
"ig_terry_m",
"a_m_m_ktown_m",
"a_m_y_skater_m",
"u_m_y_coop",
"ig_car3guy1_m",
'mp_m_freemode_01',
'mp_f_freemode_01',
'tony',
'g_m_m_chigoon_02_m',
'u_m_m_jesus_01',
'a_m_y_stbla_m',
'ig_terry_m',
'a_m_m_ktown_m',
'a_m_y_skater_m',
'u_m_y_coop',
'ig_car3guy1_m',
}

local lastSpectateCoord = nil
Expand All @@ -20,7 +20,7 @@ local isSpectating = false
-- Events

RegisterNetEvent('qb-admin:client:inventory', function(targetPed)
TriggerServerEvent("inventory:server:OpenInventory", "otherplayer", targetPed)
TriggerServerEvent('inventory:server:OpenInventory', 'otherplayer', targetPed)
end)

RegisterNetEvent('qb-admin:client:spectate', function(targetPed)
Expand All @@ -29,21 +29,21 @@ RegisterNetEvent('qb-admin:client:spectate', function(targetPed)
local target = GetPlayerPed(targetplayer)
if not isSpectating then
isSpectating = true
SetEntityVisible(myPed, false) -- Set invisible
SetEntityCollision(myPed, false, false) -- Set collision
SetEntityInvincible(myPed, true) -- Set invincible
SetEntityVisible(myPed, false) -- Set invisible
SetEntityCollision(myPed, false, false) -- Set collision
SetEntityInvincible(myPed, true) -- Set invincible
NetworkSetEntityInvisibleToNetwork(myPed, true) -- Set invisibility
lastSpectateCoord = GetEntityCoords(myPed) -- save my last coords
NetworkSetInSpectatorMode(true, target) -- Enter Spectate Mode
lastSpectateCoord = GetEntityCoords(myPed) -- save my last coords
NetworkSetInSpectatorMode(true, target) -- Enter Spectate Mode
else
isSpectating = false
NetworkSetInSpectatorMode(false, target) -- Remove From Spectate Mode
NetworkSetInSpectatorMode(false, target) -- Remove From Spectate Mode
NetworkSetEntityInvisibleToNetwork(myPed, false) -- Set Visible
SetEntityCollision(myPed, true, true) -- Set collision
SetEntityCoords(myPed, lastSpectateCoord) -- Return Me To My Coords
SetEntityVisible(myPed, true) -- Remove invisible
SetEntityInvincible(myPed, false) -- Remove godmode
lastSpectateCoord = nil -- Reset Last Saved Coords
SetEntityCollision(myPed, true, true) -- Set collision
SetEntityCoords(myPed, lastSpectateCoord) -- Return Me To My Coords
SetEntityVisible(myPed, true) -- Remove invisible
SetEntityInvincible(myPed, false) -- Remove godmode
lastSpectateCoord = nil -- Reset Last Saved Coords
end
end)

Expand All @@ -52,11 +52,11 @@ RegisterNetEvent('qb-admin:client:SendReport', function(name, src, msg)
end)

local function getVehicleFromVehList(hash)
for _, v in pairs(QBCore.Shared.Vehicles) do
if hash == v.hash then
return v.model
end
end
for _, v in pairs(QBCore.Shared.Vehicles) do
if hash == v.hash then
return v.model
end
end
end


Expand All @@ -73,17 +73,17 @@ RegisterNetEvent('qb-admin:client:SaveCar', function()
if QBCore.Shared.Vehicles[vehname] ~= nil and next(QBCore.Shared.Vehicles[vehname]) ~= nil then
TriggerServerEvent('qb-admin:server:SaveCar', props, QBCore.Shared.Vehicles[vehname], GetHashKey(veh), plate)
else
QBCore.Functions.Notify(Lang:t("error.no_store_vehicle_garage"), 'error')
QBCore.Functions.Notify(Lang:t('error.no_store_vehicle_garage'), 'error')
end
else
QBCore.Functions.Notify(Lang:t("error.no_vehicle"), 'error')
QBCore.Functions.Notify(Lang:t('error.no_vehicle'), 'error')
end
end)

local function LoadPlayerModel(skin)
RequestModel(skin)
while not HasModelLoaded(skin) do
Wait(0)
Wait(0)
end
end

Expand All @@ -110,14 +110,14 @@ RegisterNetEvent('qb-admin:client:SetModel', function(skin)
SetPedRandomComponentVariation(ped, true)
end

SetModelAsNoLongerNeeded(model)
end
SetEntityInvincible(ped, false)
SetModelAsNoLongerNeeded(model)
end
SetEntityInvincible(ped, false)
end)

RegisterNetEvent('qb-admin:client:SetSpeed', function(speed)
local ped = PlayerId()
if speed == "fast" then
if speed == 'fast' then
SetRunSprintMultiplierForPlayer(ped, 1.49)
SetSwimMultiplierForPlayer(ped, 1.49)
else
Expand All @@ -126,23 +126,6 @@ RegisterNetEvent('qb-admin:client:SetSpeed', function(speed)
end
end)

RegisterNetEvent('qb-weapons:client:SetWeaponAmmoManual', function(weapon, ammo)
local ped = PlayerPedId()
if weapon ~= "current" then
weapon = weapon:upper()
SetPedAmmo(ped, GetHashKey(weapon), ammo)
QBCore.Functions.Notify(Lang:t("info.ammoforthe", {value = ammo, weapon = QBCore.Shared.Weapons[weapon]["label"]}), 'success')
else
weapon = GetSelectedPedWeapon(ped)
if weapon ~= nil then
SetPedAmmo(ped, weapon, ammo)
QBCore.Functions.Notify(Lang:t("info.ammoforthe", {value = ammo, weapon = QBCore.Shared.Weapons[weapon]["label"]}), 'success')
else
QBCore.Functions.Notify(Lang:t("error.no_weapon"), 'error')
end
end
end)

RegisterNetEvent('qb-admin:client:GiveNuiFocus', function(focus, mouse)
SetNuiFocus(focus, mouse)
end)
Expand All @@ -158,12 +141,11 @@ function PerformanceUpgradeVehicle(vehicle, customWheels)
SetVehicleMod(vehicle, modType, max, customWheels)
end
ToggleVehicleMod(vehicle, 18, true) -- Turbo
SetVehicleFixed(vehicle)
SetVehicleFixed(vehicle)
end
end

RegisterNetEvent('qb-admin:client:maxmodVehicle', function()
local vehicle = GetVehiclePedIsIn(PlayerPedId())
PerformanceUpgradeVehicle(vehicle)
end)

Loading

0 comments on commit 42a2bf8

Please sign in to comment.