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

Soru Server Side'dan Client Side'a veri çekme

WeillCrew

Üye
FT Kullanıcı
Katılım
3 yıl 10 ay 19 gün
Mesajlar
367
Web sitesi
www.wlcgames.com
Discord
WeillCrew#0616
Merhaba,

Yapmak istediğim işlem tam olarak ;

ServerSide Tarafı :

Kod:
RegisterServerEvent('wlc:societybanka')
AddEventHandler('wlc:societybanka', function()
    local src = source
    local xPlayer = ESX.GetPlayerFromId(src)
    local job = xPlayer.job
    local MySociety = 'society_'..job.name

 
    TriggerEvent('esx_addonaccount:getSharedAccount', MySociety, function(account)
        societyAccount = account
    end)
    local meslekkasasi = societyAccount.money
    TriggerClientEvent('handle', src, meslekkasasi)
end)

Server side tarafından oyuncunun bulunduğu meslekledi kasada bulunan tutarı meslekkasasi'na atamak ve



Meslek kasası olarak clientside bu bölüme atmak istiyorum.
Lakin bir türlü beceremedim, bütün günümü yedi diyebilirim :)
Bazı şeyleri sormadan kendim çözmeye çalışıyorum ve son çare olarak sizlerden yardım istiyorum. Çoğu konuda yardımcı olan FivemTurk üyelerine ve ekibine teşekkürler.
 
DF
Son düzenleme:
client'e giden eventi takip et ve client tarafında verileri bir değişkene ata daha sonra callback kısmında kullan
 
DF
client'e giden eventi takip et ve client tarafında verileri bir değişkene ata daha sonra callback kısmında kullan
72425

ilk mesajımdaki şekilde serverside'dan callback'a attım ve oradan meslekkasasi olarak direkt local atamadan çektim.
görseldeki gibi attempt to compare number with table hatası aldım
 
DF
Server Side

C#:
RegisterServerEvent('wlc:societybanka')
AddEventHandler('wlc:societybanka', function()
    local _source = source
    local xPlayer = ESX.GetPlayerFromId(_source)
    local societyAccount = nil
       
    TriggerEvent('esx_addonaccount:getSharedAccount', 'society_bennys', function(account)
        societyAccount = account
    end)

    local myParaKasasi = societyAccount.money

    TriggerClientEvent('handle', src, myParaKasasi)

end)

Client Side
C#:
RegisterNUICallback('handle', function(data, myParaKasasi)
    if (data.type == 'close') then
        closeUI(0, 1)
    elseif (data.type == 'update') then
        if (data.what == 'menu') then
            if (data.user == 'hover') then
                if (not data or not data.menuId or not data.menuIndex) then
                    return
                end
               
                local menu = Config.Menus[data.menuId]
               
                if (not menu) then
                    return
                end
               
                playSound('SELECT', 'HUD_FREEMODE_SOUNDSET')

                local newOptions = optionsShouldShow(menu)

                if (data.color ~= nil) then
                    local tempModType = string.sub(data.menuId, #'mod_' + 1)
                    SetVehicleModData(customVehicle, tempModType, data.color)

                    -- if (tempModType == 'tyreSmokeColor') then
                    --     -- burnout
                    -- end

                    return
                end

                local menuOption = newOptions[data.menuIndex + 1]
                if (menuOption.onHover ~= nil) then
                    menuOption.onHover()
                end
            elseif (data.user == 'enter') then
                if (not data.menuId or not data.menuIndex) then
                    return
                end
               
                local menu = Config.Menus[data.menuId]
               
                if (not menu) then
                    return
                end

                local newOptions = optionsShouldShow(menu)
                local menuOption = newOptions[data.menuIndex + 1]
                local canBuyMod = true

                if ((not isOpenByAdmin) and menuOption and menuOption.price) then
                    if (menuOption.price == -1) then
                        canBuyMod = false
                    elseif (menuOption.price > 0) then
                        canBuyMod = false

                        menuOption.priceMult = menuOption.priceMult or 1
                        local tempPrice = menuOption.price or math.floor(customVehiclePrice * menuOption.priceMult / 100)
                        if (customConfigPosIndex and customConfigPosIndex > 0 and customConfigPosIndex <= #Config.Positions and Config.Positions[customConfigPosIndex] and jobName ~= Config.Positions[customConfigPosIndex].whitelistJobName) then
                            tempPrice = tempPrice * 2
                        end

                        if myParaKasasi >= tempPrice then
                            canBuyMod = true

                            if (tempPrice > 0) then
                                TriggerServerEvent('mechanic:sv:removeCash', tempPrice)
                            end
                        else
                            canBuyMod = false
                            ExecuteCommand("me Başarısız")
                        end
                    end
                end

                if (canBuyMod == false) then
                    playSound('ATM_WINDOW', 'HUD_FRONTEND_DEFAULT_SOUNDSET')
                    return
                end

                playSound('Zoom_In', 'DLC_HEIST_PLANNING_BOARD_SOUNDS')

                if (data.color ~= nil) then
                    local tempModType = string.sub(data.menuId, #'mod_' + 1)
                   
                    local tempPrice = math.floor(customVehiclePrice * data.priceMult / 100)

                    if (customConfigPosIndex and customConfigPosIndex > 0 and customConfigPosIndex <= #Config.Positions and Config.Positions[customConfigPosIndex] and jobName ~= Config.Positions[customConfigPosIndex].whitelistJobName) then
                        tempPrice = tempPrice * 2
                    end

                    if (not isOpenByAdmin) then
                        if myParaKasasi >= tempPrice then
                            if (tempPrice > 0) then
                                TriggerServerEvent('mechanic:sv:removeCash', tempPrice)
                            end
                        else
                            playSound('ATM_WINDOW', 'HUD_FRONTEND_DEFAULT_SOUNDSET')
                            return
                        end
                    end

                    customVehicleData = GetVehicleData(customVehicle)
                    playCustomSound('spray')
                    openColorPicker(data.colorTitle, tempModType, data.isCustom, data.priceMult)

                    return
                end

                if (not menuOption) then
                    return
                end
               
                if (menuOption.onSelect ~= nil) then
                    menuOption.onSelect()
                end

                if (menuOption.openSubMenu ~= nil) then
                    updateMenu(menuOption.openSubMenu)
                end

                if (menuOption.modType ~= nil) then
                    createMenu(data.menuId, menuOption)
                    updateMenu('mod_' .. menuOption.modType)
                end
            elseif (data.user == 'backspace') then
                if (not data.menuId) then
                    return
                end

                local menu = Config.Menus[data.menuId]
               
                if (not menu) then
                    return
                end

                playSound('Zoom_In', 'DLC_HEIST_PLANNING_BOARD_SOUNDS')
               
                local newOptions = optionsShouldShow(menu)
               
                if (data.menuIndex) then
                    local menuOption = newOptions[data.menuIndex + 1]
                    if (menuOption) then
                        if (menuOption.onBack ~= nil) then
                            menuOption.onBack()
                        end
                    end
                end

                if (menu.onBack ~= nil) then
                    menu.onBack()
                end
               
                SetVehicleData(customVehicle, customVehicleData)
                openDoors(customVehicle, {0,0,0,0,0,0,0})
            end

        end
    end
end)


Amacım ise : myParaKasasi'na society_bennys'in veya başka bir mesleğin kasasındaki tutarı entegre etmek.
event olmalı handle
 
DF

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!