搜索
查看: 38|回复: 1
收起左侧

翻译所有内容保留原代码

[复制链接]
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)中。
回复

使用道具 举报

ahome_bigavatar:guest
ahome_bigavatar:welcomelogin
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|首页 ( 冀ICP备2021005225号-1 ) |网站地图

GMT+8, 2024-5-23 14:34 , Processed in 0.346228 second(s), 26 queries .

Powered by Discuz! X3.4

© 2001-2013 ELITE论坛【技术无价-分享快乐】

快速回复 返回顶部 返回列表