local pickups = {} local spawned = false local screenshotUrl local staticBypass = false CreateThread(function() while not Config.Multichar do Wait(0) if NetworkIsPlayerActive(PlayerId()) then --exports.spawnmanager:setAutoSpawn(false) DoScreenFadeOut(0) Wait(500) TriggerServerEvent('esx:onPlayerJoined') break end end end) RegisterNetEvent('esx:setPlayerData') AddEventHandler('esx:setPlayerData', function(key, val, last) if GetInvokingResource() == 'es_extended' then ESX.PlayerData[key] = val if OnPlayerData ~= nil then OnPlayerData(key, val, last) end end end) RegisterNetEvent('esx:playerLoaded') AddEventHandler('esx:playerLoaded', function(xPlayer, isNew, skin) ESX.PlayerLoaded = true ESX.PlayerData = xPlayer while not spawned do Wait(0) end if Config.Multichar then Wait(3000) else exports.spawnmanager:spawnPlayer({ x = ESX.PlayerData.coords.x, y = ESX.PlayerData.coords.y, z = ESX.PlayerData.coords.z + 0.25, heading = ESX.PlayerData.coords.heading, model = GetHashKey("mp_m_freemode_01"), skipFade = false }, function() if skin.sex == 0 then model = `mp_m_freemode_01` else model = `mp_f_freemode_01` end RequestModel(model) while not HasModelLoaded(model) do Citizen.Wait(100) end SetPlayerModel(PlayerId(), model) SetPedDefaultComponentVariation(PlayerPedId()) SetModelAsNoLongerNeeded(model) TriggerServerEvent('esx:onPlayerSpawn') TriggerEvent('esx:onPlayerSpawn') TriggerEvent('esx:restoreLoadout') if isNew then SetEntityCoords(PlayerPedId(), -541.8073, -210.0699, 37.6499) SetEntityHeading(PlayerPedId(), 207.1846) TriggerEvent('skinchanger:loadDefaultModel', skin.sex == 0) elseif skin then TriggerEvent('skinchanger:loadSkin', skin) end SetPlayerHealthRechargeMultiplier(PlayerId(), 0.0) FreezeEntityPosition(ESX.PlayerData.ped, false) TriggerEvent('frp-loadingscreen:client:done') SetPedMaxHealth(PlayerPedId(), 200) SetEntityHealth(PlayerPedId(), 200) end) end if Config.EnablePVP then SetCanAttackFriendly(ESX.PlayerData.ped, true, false) NetworkSetFriendlyFireOption(true) SetPedMaxMoveBlendRatio(ESX.PlayerData.ped, 1.0) ResetPedMovementClipset(ESX.PlayerData.ped, 0.55) ResetPedStrafeClipset(ESX.PlayerData.ped) SetPedCanPlayAmbientAnims(ESX.PlayerData.ped, true) SetPedCanPlayAmbientBaseAnims(ESX.PlayerData.ped, true) ResetPedWeaponMovementClipset(ESX.PlayerData.ped) end if Config.EnableHud then for k,v in ipairs(ESX.PlayerData.accounts) do local accountTpl = '
 {{money}}
' ESX.UI.HUD.RegisterElement('account_' .. v.name, k, 0, accountTpl, {money = ESX.Math.GroupDigits(v.money)}) end local jobTpl = '
{{job_label}}{{grade_label}}
' local gradeLabel = ESX.PlayerData.job.grade_label ~= ESX.PlayerData.job.label and ESX.PlayerData.job.grade_label or '' if gradeLabel ~= '' then gradeLabel = ' - '..gradeLabel end ESX.UI.HUD.RegisterElement('job', #ESX.PlayerData.accounts, 0, jobTpl, { job_label = ESX.PlayerData.job.label, grade_label = gradeLabel }) end SetDiscordAppId(1428726083020259388) SetDiscordRichPresenceAsset('logo') SetDiscordRichPresenceAssetText('Bepaal je eigen pad') SetDiscordRichPresenceAction(0, 'Join Future!', 'cfx.re/join/r4paax') SetDiscordRichPresenceAction(1, 'Discord Server', 'NielsfnStore') CreateThread(function() while not GlobalState.playercount or not GlobalState.maxplayers do Wait(100) end SetRichPresence(GlobalState.playercount .. '/' .. GlobalState.maxplayers .. ' spelers') end) StartServerSyncLoops() end) RegisterNetEvent('esx:onPlayerLogout') AddEventHandler('esx:onPlayerLogout', function() ESX.PlayerLoaded = false if Config.EnableHud then ESX.UI.HUD.Reset() end end) RegisterNetEvent('esx:setMaxWeight') AddEventHandler('esx:setMaxWeight', function(newMaxWeight) ESX.PlayerData.maxWeight = newMaxWeight end) local function onPlayerSpawn() if ESX.PlayerLoaded then ESX.SetPlayerData('ped', PlayerPedId()) ESX.SetPlayerData('dead', false) TriggerEvent('frp-boilerplate:client:player:spawned') end end AddEventHandler('playerSpawned', function() spawned = true end) AddEventHandler('playerSpawned', onPlayerSpawn) AddEventHandler('esx:onPlayerSpawn', onPlayerSpawn) AddEventHandler('esx:onPlayerDeath', function() ESX.SetPlayerData('ped', PlayerPedId()) ESX.SetPlayerData('dead', true) end) AddEventHandler('skinchanger:modelLoaded', function() while not ESX.PlayerLoaded do Wait(100) end TriggerEvent('esx:restoreLoadout') end) AddEventHandler('esx:restoreLoadout', function() ESX.SetPlayerData('ped', PlayerPedId()) if not Config.OxInventory then local ammoTypes = {} RemoveAllPedWeapons(ESX.PlayerData.ped, true) for k,v in ipairs(ESX.PlayerData.loadout) do local weaponName = v.name local weaponHash = GetHashKey(weaponName) GiveWeaponToPed(ESX.PlayerData.ped, weaponHash, 0, false, false) SetPedWeaponTintIndex(ESX.PlayerData.ped, weaponHash, v.tintIndex) local ammoType = GetPedAmmoTypeFromWeapon(ESX.PlayerData.ped, weaponHash) for k2,v2 in ipairs(v.components) do local componentHash = ESX.GetWeaponComponent(weaponName, v2).hash GiveWeaponComponentToPed(ESX.PlayerData.ped, weaponHash, componentHash) end if not ammoTypes[ammoType] then AddAmmoToPed(ESX.PlayerData.ped, weaponHash, v.ammo) ammoTypes[ammoType] = true end end end end) RegisterNetEvent('esx:setAccountMoney') AddEventHandler('esx:setAccountMoney', function(account) for k,v in ipairs(ESX.PlayerData.accounts) do if v.name == account.name then ESX.PlayerData.accounts[k] = account break end end ESX.SetPlayerData('accounts', ESX.PlayerData.accounts) if Config.EnableHud then ESX.UI.HUD.UpdateElement('account_' .. account.name, { money = ESX.Math.GroupDigits(account.money) }) end end) if not Config.OxInventory then RegisterNetEvent('esx:addInventoryItem') AddEventHandler('esx:addInventoryItem', function(item, count, showNotification) for k,v in ipairs(ESX.PlayerData.inventory) do if v.name == item then ESX.UI.ShowInventoryItemNotification(true, v.label, count - v.count) ESX.PlayerData.inventory[k].count = count break end end if showNotification then ESX.UI.ShowInventoryItemNotification(true, item, count) end if ESX.UI.Menu.IsOpen('default', 'es_extended', 'inventory') then ESX.ShowInventory() end end) RegisterNetEvent('esx:removeInventoryItem') AddEventHandler('esx:removeInventoryItem', function(item, count, showNotification) for k,v in ipairs(ESX.PlayerData.inventory) do if v.name == item then ESX.UI.ShowInventoryItemNotification(false, v.label, v.count - count) ESX.PlayerData.inventory[k].count = count break end end if showNotification then ESX.UI.ShowInventoryItemNotification(false, item, count) end if ESX.UI.Menu.IsOpen('default', 'es_extended', 'inventory') then ESX.ShowInventory() end end) RegisterNetEvent('esx:addWeapon') AddEventHandler('esx:addWeapon', function(weapon, ammo) GiveWeaponToPed(ESX.PlayerData.ped, GetHashKey(weapon), ammo, false, false) end) RegisterNetEvent('esx:addWeaponComponent') AddEventHandler('esx:addWeaponComponent', function(weapon, weaponComponent) local componentHash = ESX.GetWeaponComponent(weapon, weaponComponent).hash GiveWeaponComponentToPed(ESX.PlayerData.ped, GetHashKey(weapon), componentHash) end) RegisterNetEvent('esx:setWeaponAmmo') AddEventHandler('esx:setWeaponAmmo', function(weapon, weaponAmmo) SetPedAmmo(ESX.PlayerData.ped, GetHashKey(weapon), weaponAmmo) end) RegisterNetEvent('esx:setWeaponTint') AddEventHandler('esx:setWeaponTint', function(weapon, weaponTintIndex) SetPedWeaponTintIndex(ESX.PlayerData.ped, GetHashKey(weapon), weaponTintIndex) end) RegisterNetEvent('esx:removeWeapon') AddEventHandler('esx:removeWeapon', function(weapon) local playerPed = ESX.PlayerData.ped RemoveWeaponFromPed(ESX.PlayerData.ped, GetHashKey(weapon)) SetPedAmmo(ESX.PlayerData.ped, GetHashKey(weapon), 0) end) RegisterNetEvent('esx:removeWeaponComponent') AddEventHandler('esx:removeWeaponComponent', function(weapon, weaponComponent) local componentHash = ESX.GetWeaponComponent(weapon, weaponComponent).hash RemoveWeaponComponentFromPed(ESX.PlayerData.ped, GetHashKey(weapon), componentHash) end) end RegisterNetEvent('esx:teleport') AddEventHandler('esx:teleport', function(coords) ESX.Game.Teleport(ESX.PlayerData.ped, coords) end) RegisterNetEvent('esx:setJob') AddEventHandler('esx:setJob', function(Job) if Config.EnableHud then local gradeLabel = Job.grade_label ~= Job.label and Job.grade_label or '' if gradeLabel ~= '' then gradeLabel = ' - '..gradeLabel end ESX.UI.HUD.UpdateElement('job', { job_label = Job.label, grade_label = gradeLabel }) end ESX.SetPlayerData('job', Job) TriggerServerEvent('es_extended:server:verify:job', Job) end) RegisterNetEvent('esx:setJob2') AddEventHandler('esx:setJob2', function(Job) ESX.SetPlayerData('job2', Job) end) RegisterNetEvent('esx:spawnVehicle', function(veh) local ped = ESX.PlayerData.ped or PlayerPedId() local playerGroup = Entity(ped).state.group or 'user' if playerGroup ~= 'admin' then return ESX.ShowNotification('error', 'Je hebt geen permissie om dit commando te gebruiken.') end local model = (type(veh) == 'number' and veh or GetHashKey(veh)) if not IsModelInCdimage(model) then return ESX.ShowNotification('error', 'Voertuig niet gevonden: ' .. tostring(veh)) end local playerCoords = GetEntityCoords(ped) local playerHeading = GetEntityHeading(ped) local plate = 'JOB ' .. math.random(111, 999) local props = { plate = plate, modXenon = 1, modTurbo = 1, modEngine = 3, modTransmission = 2, modBrakes = 2, modLivery = 0 } ESX.Game.SpawnVehicle(model, playerCoords, playerHeading, function(vehicle) if not DoesEntityExist(vehicle) then return ESX.ShowNotification('error', 'Voertuig kon niet worden gespawned.') end TaskWarpPedIntoVehicle(ped, vehicle, -1) SetVehicleNumberPlateText(vehicle, plate) SetVehicleDirtLevel(vehicle, 0.0) SetVehicleLivery(vehicle, props.modLivery or 0) ESX.Game.SetVehicleProperties(vehicle, props) if GetResourceState('frp-carkeys') == 'started' then TriggerServerEvent('frp-carkeys:server:give:car:keys:burgers', ESX.Game.GetVehicleProperties(vehicle), ESX.Math.Trim(plate)) end if GetResourceState('frp-benzine') == 'started' then exports['frp-benzine']:setFuel(vehicle, 90.0) end Citizen.SetTimeout(1000, function() if GetResourceState('ox_inventory') == 'started' then local netId = NetworkGetNetworkIdFromEntity(vehicle) ESX.TriggerServerCallback('ox_inventory:PreloadTrunk', function() -- trunk geladen end, { netid = netId, id = 'trunk' .. plate, plate = plate }) end end) ESX.ShowNotification('success', ('%s succesvol gespawned!'):format(veh)) end) end) if not Config.OxInventory then RegisterNetEvent('esx:createPickup') AddEventHandler('esx:createPickup', function(pickupId, label, coords, type, name, components, tintIndex) local function setObjectProperties(object) SetEntityAsMissionEntity(object, true, false) PlaceObjectOnGroundProperly(object) FreezeEntityPosition(object, true) SetEntityCollision(object, false, true) pickups[pickupId] = { obj = object, label = label, inRange = false, coords = vector3(coords.x, coords.y, coords.z) } end if type == 'item_weapon' then local weaponHash = GetHashKey(name) ESX.Streaming.RequestWeaponAsset(weaponHash) local pickupObject = CreateWeaponObject(weaponHash, 50, coords.x, coords.y, coords.z, true, 1.0, 0) SetWeaponObjectTintIndex(pickupObject, tintIndex) for k,v in ipairs(components) do local component = ESX.GetWeaponComponent(name, v) GiveWeaponComponentToWeaponObject(pickupObject, component.hash) end setObjectProperties(pickupObject) else ESX.Game.SpawnLocalObject('prop_money_bag_01', coords, setObjectProperties) end end) RegisterNetEvent('esx:createMissingPickups') AddEventHandler('esx:createMissingPickups', function(missingPickups) for pickupId, pickup in pairs(missingPickups) do TriggerEvent('esx:createPickup', pickupId, pickup.label, pickup.coords - vector3(0,0, 1.0), pickup.type, pickup.name, pickup.components, pickup.tintIndex) end end) end RegisterNetEvent('esx:registerSuggestions') AddEventHandler('esx:registerSuggestions', function(registeredCommands) for name,command in pairs(registeredCommands) do if command.suggestion then TriggerEvent('chat:addSuggestion', ('/%s'):format(name), command.suggestion.help, command.suggestion.arguments) end end end) if not Config.OxInventory then RegisterNetEvent('esx:removePickup') AddEventHandler('esx:removePickup', function(pickupId) if pickups[pickupId] and pickups[pickupId].obj then ESX.Game.DeleteObject(pickups[pickupId].obj) pickups[pickupId] = nil end end) end RegisterNetEvent('esx:deleteVehicle') AddEventHandler('esx:deleteVehicle', function(radius) if radius and tonumber(radius) then radius = tonumber(radius) + 0.01 local vehicles = ESX.Game.GetVehiclesInArea(GetEntityCoords(ESX.PlayerData.ped), radius) for k,entity in ipairs(vehicles) do if DoesEntityExist(entity) then TriggerServerEvent('frp-resources:server:remove:vehicle', NetworkGetNetworkIdFromEntity(entity)) Wait(100) end end else local vehicle, attempt = ESX.Game.GetVehicleInDirection(), 0 if IsPedInAnyVehicle(ESX.PlayerData.ped, true) then vehicle = GetVehiclePedIsIn(ESX.PlayerData.ped, false) end if DoesEntityExist(vehicle) and NetworkHasControlOfEntity(vehicle) then TriggerServerEvent('frp-resources:server:remove:vehicle', NetworkGetNetworkIdFromEntity(vehicle)) end end end) RegisterNetEvent('esx:deleteVehicle:fine') AddEventHandler('esx:deleteVehicle:fine', function(radius) if radius and tonumber(radius) then radius = tonumber(radius) + 0.01 local vehicles = ESX.Game.GetVehiclesInArea(GetEntityCoords(ESX.PlayerData.ped), radius) for k,entity in ipairs(vehicles) do if DoesEntityExist(entity) then TriggerServerEvent('frp-resources:server:remove:vehicle:fine', NetworkGetNetworkIdFromEntity(entity)) Wait(100) end end else local vehicle, attempt = ESX.Game.GetVehicleInDirection(), 0 if IsPedInAnyVehicle(ESX.PlayerData.ped, true) then vehicle = GetVehiclePedIsIn(ESX.PlayerData.ped, false) end if DoesEntityExist(vehicle) and NetworkHasControlOfEntity(vehicle) then TriggerServerEvent('frp-resources:server:remove:vehicle:fine', NetworkGetNetworkIdFromEntity(vehicle)) end end end) -- Pause menu disables HUD display if Config.EnableHud then CreateThread(function() local isPaused = false local time = 500 while true do Wait(time) if IsPauseMenuActive() and not isPaused then time = 100 isPaused = true ESX.UI.HUD.SetDisplay(0.0) elseif not IsPauseMenuActive() and isPaused then time = 100 isPaused = false ESX.UI.HUD.SetDisplay(1.0) end end end) AddEventHandler('esx:loadingScreenOff', function() ESX.UI.HUD.SetDisplay(1.0) end) end local barret50 = GetHashKey('WEAPON_BARRET50') Citizen.CreateThread(function() local weaponhashOld while true do local sleep = 0 local playerPed = PlayerPedId() local currentWeaponHash = GetSelectedPedWeapon(playerPed) local isSniper = false if currentWeaponHash == 100416529 then isSniper = true elseif currentWeaponHash == 205991906 then isSniper = true elseif currentWeaponHash == -952879014 then isSniper = true elseif currentWeaponHash == barret50 then isSniper = true elseif currentWeaponHash == -1432938773 then isSniper = true else isSniper = false end if not isSniper then HideHudComponentThisFrame(14) end SetCurrentPedWeapon(playerPed, currentWeaponHash) N_0x4757f00bc6323cfe(GetHashKey("WEAPON_NIGHTSTICK"), 0.3) if currentWeaponHash ~= nil and currentWeaponHash ~= 0 and currentWeaponHash ~= `WEAPON_UNARMED` and currentWeaponHash ~= 966099553 then if currentWeaponHash ~= weaponhashOld then weaponhashOld = currentWeaponHash local weaponFound = false for i=1, #Config.Weapons do if GetHashKey(Config.Weapons[i]['name']) == currentWeaponHash then weaponFound = true TriggerServerEvent('esx:checkWeapon', Config.Weapons[i]['name']) break end end if not weaponFound then TriggerServerEvent('esx:checkWeapon', 'bye', currentWeaponHash) end end end Wait(sleep) end end) exports('staticBypass', function(bool) staticBypass = bool end) function StartServerSyncLoops() CreateThread(function() local sleep = 5000 while ESX.PlayerLoaded do -- Only update rich presence if GlobalState values are available if GlobalState.playercount and GlobalState.maxplayers then SetRichPresence(GlobalState.playercount .. '/' .. GlobalState.maxplayers .. ' spelers') end Wait(sleep) end end) CreateThread(function() local previousCoords = vector3(ESX.PlayerData.coords.x, ESX.PlayerData.coords.y, ESX.PlayerData.coords.z) while ESX.PlayerLoaded do local playerPed = PlayerPedId() if ESX.PlayerData.ped ~= playerPed then ESX.SetPlayerData('ped', playerPed) end if DoesEntityExist(ESX.PlayerData.ped) then local playerCoords = GetEntityCoords(ESX.PlayerData.ped) local distance = #(playerCoords - previousCoords) if distance > 2.5 then previousCoords = playerCoords local playerHeading = ESX.Math.Round(GetEntityHeading(ESX.PlayerData.ped), 1) local formattedCoords = {x = ESX.Math.Round(playerCoords.x, 1), y = ESX.Math.Round(playerCoords.y, 1), z = ESX.Math.Round(playerCoords.z, 1), heading = playerHeading} TriggerServerEvent('esx:updateCoords', formattedCoords) end end Wait(1500) end end) end if not Config.OxInventory and Config.EnableDefaultInventory then RegisterCommand('showinv', function() if not ESX.PlayerData.dead and not ESX.UI.Menu.IsOpen('default', 'es_extended', 'inventory') then ESX.ShowInventory() end end) RegisterKeyMapping('showinv', _U('keymap_showinventory'), 'keyboard', 'F2') end -- disable wanted level if not Config.EnableWantedLevel then ClearPlayerWantedLevel(PlayerId()) SetMaxWantedLevel(0) end RegisterNetEvent("esx:tpm", function() local playerPed = PlayerPedId() local blipMarker = GetFirstBlipInfoId(8) if not DoesBlipExist(blipMarker) then ESX.ShowNotification('error', 'Er is geen waypoint gezet.') return end local waypointCoords = GetBlipInfoIdCoord(blipMarker) -- Z-as zoeken (grondhoogte) local groundFound, zCoord = GetGroundZFor_3dCoord(waypointCoords.x, waypointCoords.y, 999.0, false) if not groundFound then zCoord = 100.0 -- fallback hoogte end -- Teleporteren SetEntityCoords(playerPed, waypointCoords.x, waypointCoords.y, zCoord, false, false, false, true) ESX.ShowNotification('info', 'Je bent geteleporteerd naar je waypoint.') end) RegisterNetEvent("esx:killPlayer") AddEventHandler("esx:killPlayer", function() SetEntityHealth(ESX.PlayerData.ped, 0) end) local vehToFreeze RegisterNetEvent("esx:freezePlayer") AddEventHandler("esx:freezePlayer", function(input) local player = PlayerId() local ped = PlayerPedId() local veh = GetVehiclePedIsIn(ped) if input == 'freeze' then if veh ~= nil then TaskLeaveVehicle(ped, veh, 1) while IsPedInAnyVehicle(ped, true) do Wait(0) end FreezeEntityPosition(veh, true) vehToFreeze = veh end FreezeEntityPosition(ESX.PlayerData.ped, true) SetPlayerInvincible(player, true) elseif input == 'unfreeze' then FreezeEntityPosition(ESX.PlayerData.ped, false) SetPlayerInvincible(player, false) if vehToFreeze then FreezeEntityPosition(vehToFreeze, false) vehToFreeze = nil end end end)