Neler yeni

Foruma hoş geldin, Ziyaretçi

Forum içeriğine ve tüm hizmetlerimize erişim sağlamak için foruma kayıt olmalı ya da giriş yapmalısınız. Foruma üye olmak tamamen ücretsizdir.

Türkiye'nin İlk ve tek FiveM forum adresi

Forum adresimize hoş geldin FiveMTürk olarak amacımız siz değerli kullanıcılarımıza en aktif fikir ve paylaşım platformu sunmak bir yana en güvenilir şekilde alışveriş yapabileceğiniz bir platform sunmaktır.
DF DF
DF DF
DF DF

Script ESX_Vechileshop İsteği

  • Konbuyu başlatan cvgri
  • Başlangıç tarihi
  • Cevaplar 1
  • Görüntüleme 535

cvgri

Üye
FT Kullanıcı
Katılım
2 yıl 4 ay 25 gün
Mesajlar
31
Arkadaşlar iyi akşamlar. Bir scripte sahibim
Bu scriptte galerici oyunda olduğunda NPC'yi siliyor. Galerici oyunda olmadığında NPC belirlenen kordinatlara geri geliyor.
Fakat scriptte mi hata var anlamadım Galerici şehirde olsa da olmasa da NPC Gözükmüyor.

Aşağıda verdiğim kodu,
Galerici şehirde olduğunda " Şehirde galerici mevcut! " yazsın.
Şehirde olduğunda NPC'nin silinmesini istemiyorum. Yardımcı olabilecek misiniz.
Teşekkür ederim..

Client Dosyası
C#:
local Keys = {
    ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
    ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
    ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
    ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
    ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
    ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
    ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
    ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
    ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
  }
 
  local HasAlreadyEnteredMarker = false
  local LastZone                = nil
  local CurrentAction           = nil
  local CurrentActionMsg        = ''
  local CurrentActionData       = {}
  local IsInShopMenu            = false
  local Categories              = {}
  local Vehicles                = {}
  local LastVehicles            = {}
  local CurrentVehicleData      = nil
 
  ESX                           = nil
 
  Citizen.CreateThread(function ()
      while ESX == nil do
          TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
          Citizen.Wait(0)
      end
 
      Citizen.Wait(10000)
 
      ESX.TriggerServerCallback('esx_vehicleshop:getCategories', function (categories)
          Categories = categories
      end)
 
      ESX.TriggerServerCallback('esx_vehicleshop:getVehicles', function (vehicles)
          Vehicles = vehicles
      end)
  end)
 
  RegisterNetEvent('esx:playerLoaded')
  AddEventHandler('esx:playerLoaded', function(xPlayer)
      ESX.PlayerData = xPlayer
 
      if Config.EnablePlayerManagement then
          if ESX.PlayerData.job.name == 'cardealer' then
              Config.Zones.ShopEntering.Type = 36
 
              if ESX.PlayerData.job.grade_name == 'boss' then
                  Config.Zones.BossActions.Type = 2
              end
 
          else
              Config.Zones.ShopEntering.Type = -1
              Config.Zones.BossActions.Type  = -1
          end
      end
  end)
 
  RegisterNetEvent('esx_vehicleshop:sendCategories')
  AddEventHandler('esx_vehicleshop:sendCategories', function (categories)
      Categories = categories
  end)
 
  RegisterNetEvent('esx_vehicleshop:sendVehicles')
  AddEventHandler('esx_vehicleshop:sendVehicles', function (vehicles)
      Vehicles = vehicles
  end)
 
  function DeleteShopInsideVehicles()
      while #LastVehicles > 0 do
          local vehicle = LastVehicles[1]
 
          ESX.Game.DeleteVehicle(vehicle)
          table.remove(LastVehicles, 1)
      end
  end
 
  function StartShopRestriction()
      Citizen.CreateThread(function()
          while IsInShopMenu do
              Citizen.Wait(1)
 
              DisableControlAction(0, 75,  true) -- Disable exit vehicle
              DisableControlAction(27, 75, true) -- Disable exit vehicle
              DisableControlAction(0, 288, true) --f1
              DisableControlAction(0, 289, true) --f2
              DisableControlAction(0, 170, true) --f3
          end
      end)
  end
 
  function OpenShopMenu()
      IsInShopMenu = true
 
      StartShopRestriction()
      ESX.UI.Menu.CloseAll()
 
      local playerPed = PlayerPedId()
 
      FreezeEntityPosition(playerPed, true)
      SetEntityVisible(playerPed, false)
      SetEntityCoords(playerPed, Config.Zones.ShopInside.Pos.x, Config.Zones.ShopInside.Pos.y, Config.Zones.ShopInside.Pos.z)
 
      local vehiclesByCategory = {}
      local elements           = {}
      local firstVehicleData   = nil
 
      for i=1, #Categories, 1 do
          vehiclesByCategory[Categories[i].name] = {}
      end
 
      for i=1, #Vehicles, 1 do
          if IsModelInCdimage(GetHashKey(Vehicles[i].model)) then
              table.insert(vehiclesByCategory[Vehicles[i].category], Vehicles[i])
          else
              print(('esx_vehicleshop: vehicle "%s" does not exist'):format(Vehicles[i].model))
          end
      end
 
      for i=1, #Categories, 1 do
          local category         = Categories[i]
          local categoryVehicles = vehiclesByCategory[category.name]
          local options          = {}
 
          for j=1, #categoryVehicles, 1 do
              local vehicle = categoryVehicles[j]
 
              if i == 1 and j == 1 then
                  firstVehicleData = vehicle
              end
 
              table.insert(options, ('%s %s'):format(vehicle.name, _U('generic_shopitem', ESX.Math.GroupDigits(vehicle.price)))) -- <span style="color:green;"> -- </span>
          end
 
          table.insert(elements, {
              name    = category.name,
              label   = category.label,
              value   = 0,
              type    = 'slider',
              max     = #Categories[i],
              options = options
          })
      end
 
      ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_shop', {
          title    = _U('car_dealer'),
          align    = 'right',
          elements = elements
      }, function (data, menu)
          local vehicleData = vehiclesByCategory[data.current.name][data.current.value + 1]
 
          ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop_confirm', {
              title = _U('buy_vehicle_shop', vehicleData.name, ESX.Math.GroupDigits(vehicleData.price)),
              align    = 'right',
              elements = {
                  {label = _U('no'),  value = 'no'},
                  {label = _U('yes'), value = 'yes'}
              }
          }, function(data2, menu2)
              if data2.current.value == 'yes' then
                  local playerData = ESX.GetPlayerData()
                    ESX.TriggerServerCallback('esx_vehicleshop:buyVehicle', function (hasEnoughMoney)
                    if hasEnoughMoney then
                        IsInShopMenu = false
                        menu2.close()
                        menu.close()
                        DeleteShopInsideVehicles()

                        ESX.Game.SpawnVehicle(vehicleData.model, Config.Zones.ShopOutside.Pos, Config.Zones.ShopOutside.Heading, function (vehicle)
                            TaskWarpPedIntoVehicle(playerPed, vehicle, -1)

                            local newPlate     = GeneratePlate()
                            local vehicleProps = ESX.Game.GetVehicleProperties(vehicle)
                            vehicleProps.plate = newPlate
                            SetVehicleNumberPlateText(vehicle, newPlate)

                            if Config.EnableOwnedVehicles then
                                TriggerServerEvent('esx_vehicleshop:setVehicleOwned', vehicleProps)
                            end

                            TriggerEvent('mythic_notify:client:SendAlert', { type = 'inform', text = _U('vehicle_purchased')})
                            TriggerServerEvent('vusca:vehiclelock:plateRegister', newPlate)
                        end)

                        FreezeEntityPosition(playerPed, false)
                        SetEntityVisible(playerPed, true)
                    else
                        TriggerEvent('mythic_notify:client:SendAlert', { type = 'error', text = 'Şirket kasasında yeterli para yok!'})
                    end
                end, vehicleData.model)
              elseif data2.current.value == 'no' then
                  menu2.close()
              end
          end, function (data2, menu2)
              menu2.close()
              DeleteShopInsideVehicles()
              local playerPed = PlayerPedId()
 
              CurrentAction     = 'shop_menu'
              CurrentActionMsg  = _U('shop_menu')
              CurrentActionData = {}
 
              FreezeEntityPosition(playerPed, false)
              SetEntityVisible(playerPed, true)
              SetEntityCoords(playerPed, Config.Zones.ShopEntering.Pos.x, Config.Zones.ShopEntering.Pos.y, Config.Zones.ShopEntering.Pos.z)
 
              IsInShopMenu = false
          end)
      end, function (data, menu)
          menu.close()
          DeleteShopInsideVehicles()
          local playerPed = PlayerPedId()
 
          CurrentAction     = 'shop_menu'
          CurrentActionMsg  = _U('shop_menu')
          CurrentActionData = {}
 
          FreezeEntityPosition(playerPed, false)
          SetEntityVisible(playerPed, true)
          SetEntityCoords(playerPed, Config.Zones.ShopEntering.Pos.x, Config.Zones.ShopEntering.Pos.y, Config.Zones.ShopEntering.Pos.z)
 
          IsInShopMenu = false
      end, function (data, menu)
          local vehicleData = vehiclesByCategory[data.current.name][data.current.value + 1]
          local playerPed   = PlayerPedId()
 
          DeleteShopInsideVehicles()
          WaitForVehicleToLoad(vehicleData.model)
 
          ESX.Game.SpawnLocalVehicle(vehicleData.model, Config.Zones.ShopInside.Pos, Config.Zones.ShopInside.Heading, function (vehicle)
              table.insert(LastVehicles, vehicle)
              TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
              FreezeEntityPosition(vehicle, true)
              SetModelAsNoLongerNeeded(vehicleData.model)
          end)
      end)
 
      DeleteShopInsideVehicles()
      WaitForVehicleToLoad(firstVehicleData.model)
 
      ESX.Game.SpawnLocalVehicle(firstVehicleData.model, Config.Zones.ShopInside.Pos, Config.Zones.ShopInside.Heading, function (vehicle)
          table.insert(LastVehicles, vehicle)
          TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
          FreezeEntityPosition(vehicle, true)
          SetModelAsNoLongerNeeded(firstVehicleData.model)
      end)
 
  end
 
  function WaitForVehicleToLoad(modelHash)
      modelHash = (type(modelHash) == 'number' and modelHash or GetHashKey(modelHash))
 
      if not HasModelLoaded(modelHash) then
          RequestModel(modelHash)
 
          BeginTextCommandBusyString('STRING')
          AddTextComponentSubstringPlayerName(_U('shop_awaiting_model'))
          EndTextCommandBusyString(4)
 
          while not HasModelLoaded(modelHash) do
              Citizen.Wait(1)
              DisableAllControlActions(0)
          end
 
          RemoveLoadingPrompt()
      end
  end
 
  function OpenBossActionsMenu()
      ESX.UI.Menu.CloseAll()
 
      TriggerEvent('esx_society:openBossMenu', 'cardealer')
  end
 
  function OpenGetStocksMenu()
      ESX.TriggerServerCallback('esx_vehicleshop:getStockItems', function (items)
          local elements = {}
 
          for i=1, #items, 1 do
              table.insert(elements, {
                  label = 'x' .. items[i].count .. ' ' .. items[i].label,
                  value = items[i].name
              })
          end
 
          ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'stocks_menu', {
              title    = _U('dealership_stock'),
              align    = 'right',
              elements = elements
          }, function (data, menu)
              local itemName = data.current.value
 
              ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'stocks_menu_get_item_count', {
                  title = _U('amount')
              }, function (data2, menu2)
                  local count = tonumber(data2.value)
 
                  if count == nil then
                      TriggerEvent('mythic_notify:client:SendAlert', { type = 'error', text = _U('quantity_invalid')})
                  else
                      TriggerServerEvent('esx_vehicleshop:getStockItem', itemName, count)
                      menu2.close()
                      menu.close()
                      OpenGetStocksMenu()
                  end
              end, function (data2, menu2)
                  menu2.close()
              end)
 
          end, function (data, menu)
              menu.close()
          end)
      end)
  end

function OpenPutStocksMenu()
    ESX.TriggerServerCallback('esx_vehicleshop:getPlayerInventory', function (inventory)
        local elements = {}

        for i=1, #inventory.items, 1 do
            local item = inventory.items[i]

            if item.count > 0 then
                table.insert(elements, {
                    label = item.label .. ' x' .. item.count,
                    type = 'item_standard',
                    value = item.name
                })
            end
        end

        ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'stocks_menu', {
            title    = _U('inventory'),
            align    = 'right',
            elements = elements
        }, function (data, menu)
            local itemName = data.current.value

            ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'stocks_menu_put_item_count', {
                title = _U('amount')
            }, function (data2, menu2)
                local count = tonumber(data2.value)

                if count == nil then
                    TriggerEvent('mythic_notify:client:SendAlert', { type = 'error', text = _U('quantity_invalid')})
                else
                    TriggerServerEvent('esx_vehicleshop:putStockItems', itemName, count)
                    menu2.close()
                    menu.close()
                    OpenPutStocksMenu()
                end
            end, function (data2, menu2)
                menu2.close()
            end)
        end, function (data, menu)
            menu.close()
        end)
    end)
end

RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function (job)
    ESX.PlayerData.job = job

    if Config.EnablePlayerManagement then
        if ESX.PlayerData.job.name == 'cardealer' then
            Config.Zones.ShopEntering.Type = 36

            if ESX.PlayerData.job.grade_name == 'boss' then
                Config.Zones.BossActions.Type = 2
            end
        else
            Config.Zones.ShopEntering.Type = -1
            Config.Zones.BossActions.Type  = -1
        end
    end
end)

AddEventHandler('esx_vehicleshop:hasEnteredMarker', function (zone)
    if zone == 'ShopEntering' and ESX.PlayerData.job ~= nil and ESX.PlayerData.job.name == 'cardealer' then

        CurrentAction     = 'shop_menu'
        CurrentActionMsg  = _U('shop_menu')
        CurrentActionData = {}

    elseif zone == 'BossActions' and Config.EnablePlayerManagement and ESX.PlayerData.job ~= nil and ESX.PlayerData.job.name == 'cardealer' and ESX.PlayerData.job.grade_name == 'boss' then

        CurrentAction     = 'boss_actions_menu'
        CurrentActionMsg  = 'Patron işlemleri için ~INPUT_CONTEXT~ tuşuna basınız.'
        CurrentActionData = {}
    end
end)

AddEventHandler('esx_vehicleshop:hasExitedMarker', function (zone)
    if not IsInShopMenu then
        ESX.UI.Menu.CloseAll()
    end

    CurrentAction = nil
end)

AddEventHandler('onResourceStop', function(resource)
    if resource == GetCurrentResourceName() then
        if IsInShopMenu then
            ESX.UI.Menu.CloseAll()

            DeleteShopInsideVehicles()
            local playerPed = PlayerPedId()

            FreezeEntityPosition(playerPed, false)
            SetEntityVisible(playerPed, true)
            SetEntityCoords(playerPed, Config.Zones.ShopEntering.Pos.x, Config.Zones.ShopEntering.Pos.y, Config.Zones.ShopEntering.Pos.z)
        end
    end
end)

if Config.EnablePlayerManagement then
    RegisterNetEvent('esx_phone:loaded')
    AddEventHandler('esx_phone:loaded', function (phoneNumber, contacts)
        local specialContact = {
            name       = _U('dealership'),
            number     = 'cardealer',
            base64Icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAMAAABrrFhUAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAMAUExURQAAADMzMzszM0M0M0w0M1Q1M101M2U2M242M3Y3M383Moc4MpA4Mpg5MqE5Mqk6MrI6Mro7Mrw8Mr89M71DML5EO8I+NMU/NcBMLshANctBNs5CN8RULMddKsheKs9YLtBCONZEOdlFOtxGO99HPNhMNsplKM1nKM1uJtRhLddiLt5kMNJwJ9B2JNR/IeNIPeVJPehKPuRQOuhSO+lZOOlhNuloM+p3Lep/KupwMMFORsVYUcplXc1waNJ7delUSepgVexrYe12bdeHH9iIH9qQHd2YG+udH+OEJeuGJ+uOJeuVIuChGeSpF+aqGOykHOysGeeyFeuzFuyzFuq6E+27FO+Cee3CEdaGgdqTjvCNhfKYkvOkngAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJezdycAAAEAdFJOU////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wBT9wclAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAGHRFWHRTb2Z0d2FyZQBwYWludC5uZXQgNC4xLjb9TgnoAAAQGElEQVR4Xt2d+WMUtxXHbS6bEGMPMcQQ04aEUnqYo9xJWvC6kAKmQLM2rdn//9+g0uir2Tl0PElPszP7+cnH7Fj6rPTeG2lmvfKld2azk8lk/36L/cnkZDbDIT3Sp4DZ8QS9dTI57tNDTwJOOu+4j/0TvDQz+QXMSG+7mUn+sZBZQELnNROcKhMZBXx+gS4k8+IzTpmBXAJOnqPxTDzPFRKyCODuvSKPgwwC2EZ+lxf4E4xwCzhBU7PBPQx4BWR88+fwDgNGAbMsM9/Ec8bygE3A5966L3nOlhiZBGSf+l2YggGLgBna1DMsE4FBQH9zvw1HLEgX0Evkt5GeEVIFMFztpJF6rZQm4DNasVDSEkKSgIVN/ibP0ZwoEgQsfPTPSZgH8QIG8vYr4gdBrIABvf2K2EEQKWBQb78ichBECRhE8O8SlQ5iBAQvcffFPhoYQoSAAQ5/TcQ0CBYw0OGvCZ4GoQIGF/3bhGaDQAELvfKhERgIwgQMePrPCQsEQQLwFwYPmksiQMCC1n1iCFgooQtYwLJfPPQFQ7KAUfU/wABVwMj6TzdAFDDY6tcOMR3SBIyw/1QDJAGj7D/RAEXA6Oa/hhIHCAJG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6DQSU+S+hCuAx0F8goPafLoDJQE+BgNz/AAEsNWFPgcBb/80JEMBxXSDoIRCguSSCBDBcHUsyBwLP9W+LMAE86TBvICCmP02ggPRVspKMgYBU/tUIFZC+UlqSLRC41j+NBAsYdCAIm/4lEQKGGwgCp39JjACmacAeCIKHvyRKANM04A0EEcNfEimAKRswBoK/o2GhxApgGgRcgSDy7RfEC+AZBDyBIDT510gQwDMIGAJB/NsvSBLAkw5SA0FU8K9IE8AzD5ICQcLoL0kVEP2ERR3zZzRR6Dz/EEy6gC+z9FBwL24D9XLAwocNBgEsa0URj11xdJ9JAMeCYfBjV/RlPydMAkRCSJ0IQYGA592XsAlIjwX0QMDXfVYBgsSMQAsE6ZG/Dq+A1GBACARMU7+CW4AgZRh4AgHvm1+SQYAYBvHRwBEILnO/+SVZBAjiHZgDQZ7eC3IJEHyOnAvdQPBT2vWOk4wCJFHXSs1AkHq14yGzAMEsXEIVCH5hTPgW8gsoOQlcSr9W/Jxr0rfoSUDJ7Jg0GCbHM7ygD/oUAGazk8mkMyL2J5OTWZ89L/ny5f+yiDXCPYKoAQAAAABJRU5ErkJggg==',
        }

        TriggerEvent('esx_phone:addSpecialContact', specialContact.name, specialContact.number, specialContact.base64Icon)
    end)
end

-- Create Blips
Citizen.CreateThread(function()
    local blip = AddBlipForCoord(Config.Zones.ShopEntering.Pos.x, Config.Zones.ShopEntering.Pos.y, Config.Zones.ShopEntering.Pos.z)

    SetBlipSprite (blip, 326)
    SetBlipDisplay(blip, 4)
    SetBlipScale  (blip, 0.7)
    SetBlipAsShortRange(blip, true)

    BeginTextCommandSetBlipName("STRING")
    AddTextComponentString(_U('car_dealer'))
    EndTextCommandSetBlipName(blip)
end)

-- Display markers
Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)

        local coords = GetEntityCoords(PlayerPedId())

        if ESX.PlayerData.job ~= nil and ESX.PlayerData.job.name == 'cardealer' then
            for k,v in pairs(Config.Zones) do
                if(v.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.DrawDistance) then
                    DrawMarker(v.Type, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, v.Size.x, v.Size.y, v.Size.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false)
                end
            end
        end
    end
end)

-- Enter / Exit marker events
Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)

        local coords      = GetEntityCoords(PlayerPedId())
        local isInMarker  = false
        local currentZone = nil

        for k,v in pairs(Config.Zones) do
            if(GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < v.Size.x) then
                isInMarker  = true
                currentZone = k
            end
        end

        if (isInMarker and not HasAlreadyEnteredMarker) or (isInMarker and LastZone ~= currentZone) then
            HasAlreadyEnteredMarker = true
            LastZone                = currentZone
            TriggerEvent('esx_vehicleshop:hasEnteredMarker', currentZone)
        end

        if not isInMarker and HasAlreadyEnteredMarker then
            HasAlreadyEnteredMarker = false
            TriggerEvent('esx_vehicleshop:hasExitedMarker', LastZone)
        end
    end
end)

-- Key controls
Citizen.CreateThread(function()
    while true do
        Citizen.Wait(5)

        if CurrentAction == nil then
        else
            ESX.ShowHelpNotification(CurrentActionMsg)

            if IsControlJustReleased(0, Keys['E']) then
                if CurrentAction == 'shop_menu' then
                    if Config.LicenseEnable then
                        ESX.TriggerServerCallback('esx_license:checkLicense', function(hasDriversLicense)
                            if hasDriversLicense then
                                if ESX.PlayerData.job ~= nil and ESX.PlayerData.job.name == 'cardealer' then
                                    OpenShopMenu()
                                else
                                    TriggerEvent('mythic_notify:client:SendAlert', { type = 'error', text = 'Menuye erişiminiz yok!'})
                                end
                            else
                                TriggerEvent('mythic_notify:client:SendAlert', { type = 'error', text = _U('license_missing')})
                            end
                        end, GetPlayerServerId(PlayerId()), 'drive')
                    else
                        if ESX.PlayerData.job ~= nil and ESX.PlayerData.job.name == 'cardealer' then
                            OpenShopMenu()
                        else
                            TriggerEvent('mythic_notify:client:SendAlert', { type = 'error', text = 'Menuye erişiminiz yok!'})
                        end
                    end
                elseif CurrentAction == 'boss_actions_menu' then
                    OpenBossActionsMenu()
                elseif CurrentAction == 'fakedealer' then
                    ESX.TriggerServerCallback('esx_vehicleshop:cdCount', function(cdConnected)
                        if cdConnected < 1 then
                            fakeDealer()
                        else
                            ESX.ShowNotification('Şehirde galerici mevcut!')
                        end
                    end)
                end

                CurrentAction = nil
            end
        end
    end
end)

local fakeDealer = {x = -56.92, y = -1099.3, z = 25.42, h = 34.51}

Server Dosyası
C#:
ESX              = nil
local Categories = {}
local Vehicles   = {}
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
TriggerEvent('esx_phone:registerNumber', 'cardealer', _U('dealer_customers'), false, false)
TriggerEvent('esx_society:registerSociety', 'cardealer', _U('car_dealer'), 'society_cardealer', 'society_cardealer', 'society_cardealer', {type = 'private'})
ESX.RegisterServerCallback('esx_vehicleshop:cdCount', function(source, cb)
    local xPlayers = ESX.GetPlayers()
 
     cdConnected = 0
 
     for i=1, #xPlayers, 1 do
         local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
         if xPlayer.job.name == 'cardealer' then
             cdConnected = cdConnected + 1
         end
     end
    cb(cdConnected)
 end)
Citizen.CreateThread(function()
    local char = Config.PlateLetters
    char = char + Config.PlateNumbers
    if Config.PlateUseSpace then char = char + 1 end
    if char > 8 then
        print(('esx_vehicleshop: ^1WARNING^7 plate character count reached, %s/8 characters.'):format(char))
    end
end)
function RemoveOwnedVehicle(plate)
    MySQL.Async.execute('DELETE FROM owned_vehicles WHERE plate = @plate', {
        ['@plate'] = plate
    })
end
MySQL.ready(function()
    Categories     = MySQL.Sync.fetchAll('SELECT * FROM vehicle_categories')
    local vehicles = MySQL.Sync.fetchAll('SELECT * FROM vehicles')
    for i=1, #vehicles, 1 do
        local vehicle = vehicles[i]
        for j=1, #Categories, 1 do
            if Categories[j].name == vehicle.category then
                vehicle.categoryLabel = Categories[j].label
                break
            end
        end
        table.insert(Vehicles, vehicle)
    end
    -- send information after db has loaded, making sure everyone gets vehicle information
    TriggerClientEvent('esx_vehicleshop:sendCategories', -1, Categories)
    TriggerClientEvent('esx_vehicleshop:sendVehicles', -1, Vehicles)
end)
RegisterServerEvent('esx_vehicleshop:setVehicleOwned')
AddEventHandler('esx_vehicleshop:setVehicleOwned', function (vehicleProps)
    local _source = source
    local xPlayer = ESX.GetPlayerFromId(_source)
    MySQL.Async.execute('INSERT INTO owned_vehicles (owner, plate, vehicle, job) VALUES (@owner, @plate, @vehicle, @job)',
    {
        ['@job']   = 'sivil',
        ['@owner']   = xPlayer.identifier,
        ['@plate']   = vehicleProps.plate,
        ['@vehicle'] = json.encode(vehicleProps)
    }, function (rowsChanged)
        TriggerClientEvent('mythic_notify:client:SendAlert', _source, { type = 'inform', text = _U('vehicle_belongs', vehicleProps.plate)})
    end)
end)
RegisterServerEvent('esx_vehicleshop:setVehicleOwnedPlayerId')
AddEventHandler('esx_vehicleshop:setVehicleOwnedPlayerId', function (playerId, vehicleProps)
    local xPlayer = ESX.GetPlayerFromId(playerId)
    MySQL.Async.execute('INSERT INTO owned_vehicles (owner, plate, vehicle, job) VALUES (@owner, @plate, @vehicle, @job)',
    {
        ['@job']   = 'sivil',
        ['@owner']   = xPlayer.identifier,
        ['@plate']   = vehicleProps.plate,
        ['@vehicle'] = json.encode(vehicleProps)
    }, function (rowsChanged)
        TriggerClientEvent('mythic_notify:client:SendAlert', playerId, { type = 'inform', text = _U('vehicle_belongs', vehicleProps.plate)})
    end)
end)
ESX.RegisterServerCallback('esx_vehicleshop:getCategories', function (source, cb)
    cb(Categories)
end)
ESX.RegisterServerCallback('esx_vehicleshop:getVehicles', function (source, cb)
    cb(Vehicles)
end)
ESX.RegisterServerCallback('esx_vehicleshop:buyVehicle', function (source, cb, vehicleModel)
    local xPlayer     = ESX.GetPlayerFromId(source)
    local vehicleData = nil
    for i=1, #Vehicles, 1 do
        if Vehicles[i].model == vehicleModel then
            vehicleData = Vehicles[i]
            break
        end
    end
    
    TriggerEvent('esx_addonaccount:getSharedAccount', 'society_cardealer', function (account)
        if vehicleData and account.money >= vehicleData.price then
            account.removeMoney(vehicleData.price)
            cb(true)
        else
            cb(false)
        end
    end)
end)
ESX.RegisterServerCallback('esx_vehicleshop:buyVehicleFD', function (source, cb, vehicleModel)
    local _source = source
    local xPlayer     = ESX.GetPlayerFromId(_source)
    local vehicleData = nil
    for i=1, #Vehicles, 1 do
        if Vehicles[i].model == vehicleModel then
            vehicleData = Vehicles[i]
            break
        end
    end
    
    if vehicleData and xPlayer.getAccount('bank').money >= (vehicleData.price * 1.5) then
        xPlayer.removeAccountMoney('bank', vehicleData.price * 1.5)
        cb(true)
    else
        cb(false)
    end
end)
ESX.RegisterServerCallback('esx_vehicleshop:getStockItems', function (source, cb)
    TriggerEvent('esx_addoninventory:getSharedInventory', 'society_cardealer', function(inventory)
        cb(inventory.items)
    end)
end)
ESX.RegisterServerCallback('esx_vehicleshop:getPlayerInventory', function (source, cb)
    local xPlayer = ESX.GetPlayerFromId(source)
    local items = xPlayer.inventory
    cb({items = items})
end)
ESX.RegisterServerCallback('esx_vehicleshop:isPlateTaken', function (source, cb, plate)
    MySQL.Async.fetchAll('SELECT 1 FROM owned_vehicles WHERE plate = @plate', {
        ['@plate'] = plate
    }, function (result)
        cb(result[1] ~= nil)
    end)
end)
ESX.RegisterServerCallback('esx_vehicleshop:retrieveJobVehicles', function (source, cb, type)
    local xPlayer = ESX.GetPlayerFromId(source)
    MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND type = @type AND job = @job', {
        ['@owner'] = xPlayer.identifier,
        ['@type'] = type,
        ['@job'] = xPlayer.job.name
    }, function (result)
        cb(result)
    end)
end)
RegisterServerEvent('esx_vehicleshop:setJobVehicleState')
AddEventHandler('esx_vehicleshop:setJobVehicleState', function(plate, state)
    local xPlayer = ESX.GetPlayerFromId(source)
    MySQL.Async.execute('UPDATE owned_vehicles SET `stored` = @stored WHERE plate = @plate AND job = @job', {
        ['@stored'] = state,
        ['@plate'] = plate,
        ['@job'] = xPlayer.job.name
    }, function(rowsChanged)
        if rowsChanged == 0 then
            print(('esx_vehicleshop: %s exploited the garage!'):format(xPlayer.identifier))
        end
    end)
end)
 
DF

Ekli dosyalar

  • esx_vehicleshop.zip
    15.2 KB · Görüntüleme: 245

Forumdan daha fazla yararlanmak için giriş yapın yada üye olun!

Forumdan daha fazla yararlanmak için giriş yapın veya kayıt olun!

Kayıt ol

Forumda bir hesap oluşturmak tamamen ücretsizdir.

Şimdi kayıt ol
Giriş yap

Eğer bir hesabınız var ise lütfen giriş yapın

Giriş yap

Bu konuyu görüntüleyen kullanıcılar

Tema düzenleyici

Tema özelletirmeleri

Granit arka planlar

Lütfen Javascript'i etkinleştirin!Javascript'i etkinleştirin!
// Adblock Kod Start // // Adblock Kod End//