shuijiao 发表于 2024-5-6 08:32:45

翻译所有内容保留原代码


RegisterNetEvent('esx_pawnshop:registerShop', function()
    exports.ox_inventory:RegisterShop('Pawnshop', {
      name = 'Pawnshop',
      inventory = Config.ItemsSold,
      locations = {
            vec3(-477.6, 278.55, 82.31),
            vec3(133.31, -1776.99, 28.75),
            vec3(1705.79, 3783.57, 33.73),
      },
    })
end)

RegisterNetEvent('esx_pawnshop:sellAll', function(item, price)
    local Player = ESX.GetPlayerFromId(source)
    local itemData = Player.getInventoryItem(item)
    if itemData ~= nil then
      Player.removeInventoryItem(item, itemData.count)
      Player.addAccountMoney('bank', itemData.count * price)
      TriggerClientEvent('ox_lib:notify', source, {title = 'Payment Successful', description = 'You received $'.. itemData.count * price .. ' to your bank account', type = 'success', icon = 'building-columns', position = 'center-right'})
    end
end)

RegisterNetEvent('esx_pawnshop:sellSome', function(item, price, amount)
    local Player = ESX.GetPlayerFromId(source)
    local itemData = Player.getInventoryItem(item)
    if itemData.count >= amount then
      Player.removeInventoryItem(item, itemData.count)
      Player.addAccountMoney('bank', itemData.count * price)
      TriggerClientEvent('ox_lib:notify', source, {title = 'Payment Successful', description = 'You received $'.. itemData.count * price .. ' to your bank account', type = 'success', icon = 'building-columns', position = 'center-right'})
    else
      TriggerClientEvent('ox_lib:notify', source, {title = 'You don\'t have that much of this item', type = 'error', position = 'center-right'})
    end
end)


ChatGPT 发表于 2024-5-6 08:32:56

注册网络事件'esx_pawnshop:registerShop',在其中:
RegisterNetEvent('esx_pawnshop:registerShop', function()
    exports.ox_inventory:RegisterShop('Pawnshop', {
      name = 'Pawnshop',
      inventory = Config.ItemsSold,
      locations = {
            vec3(-477.6, 278.55, 82.31),
            vec3(133.31, -1776.99, 28.75),
            vec3(1705.79, 3783.57, 33.73),
      },
    })
end)
在服务器脚本文件(server.lua)中放置此代码。

注册网络事件'esx_pawnshop:sellAll',在其中:
RegisterNetEvent('esx_pawnshop:sellAll', function(item, price)
    local Player = ESX.GetPlayerFromId(source)
    local itemData = Player.getInventoryItem(item)
    if itemData ~= nil then
      Player.removeInventoryItem(item, itemData.count)
      Player.addAccountMoney('bank', itemData.count * price)
      TriggerClientEvent('ox_lib:notify', source, {title = '支付成功', description = '您已将 $'.. itemData.count * price .. ' 存入银行账户', type = 'success', icon = 'building-columns', position = 'center-right'})
    end
end)

注册网络事件'esx_pawnshop:sellSome',在其中:
RegisterNetEvent('esx_pawnshop:sellSome', function(item, price, amount)
    local Player = ESX.GetPlayerFromId(source)
    local itemData = Player.getInventoryItem(item)
    if itemData.count >= amount then
      Player.removeInventoryItem(item, itemData.count)
      Player.addAccountMoney('bank', itemData.count * price)
      TriggerClientEvent('ox_lib:notify', source, {title = '支付成功', description = '您已将 $'.. itemData.count * price .. ' 存入银行账户', type = 'success', icon = 'building-columns', position = 'center-right'})
    else
      TriggerClientEvent('ox_lib:notify', source, {title = '您没有足够的该物品', type = 'error', position = 'center-right'})
    end
end)
以上代码需要放置在服务器脚本文件(server.lua)中。
页: [1]
查看完整版本: 翻译所有内容保留原代码