提取并复制 cfx-vote-plugin 文件夹的内容到您 RedM 服务器的 resources/vote 目录。
resources/vote
从 Top-Games 面板获取您的令牌。
将以下行添加到您的 server.cfg 文件:
ensure vote
set vote_token "您的令牌在这里"
在您的 Top-Games 面板中启用"投票插件 v3"。您可以通过点击"测试连接性"来测试插件并模拟投票。
当玩家为您的 RedM 服务器投票时,插件会自动触发 onPlayerVote 事件。
-- RedM 基本使用示例
AddEventHandler('onPlayerVote', function(playername, date)
print('在 RedM 服务器上收到新投票!')
print('牛仔:' .. playername)
print('日期:' .. date)
-- 在此添加您的西部奖励逻辑
end)
-- VORP Framework 特定配置
local VORP = exports.vorp_core:GetCore()
TriggerEvent("getCore", function(core)
VORP = core
end)
AddEventHandler('onPlayerVote', function(playerid, date)
local User = VORP.getUser(playerid)
if User then
local Character = User.getUsedCharacter
local name = Character.firstname .. " " .. Character.lastname
print("Vote received from: " .. name)
-- 现金和黄金奖励
Character.addCurrency(0, 50.0) -- 现金
Character.addCurrency(1, 2.0) -- 黄金
-- VORP 通知
TriggerClientEvent("vorp:TipRight", playerid, "谢谢您的投票!+50$ 和 2 黄金", 4000)
end
end)
resources/ 中ensure vote 行在 server.cfg 中server.cfg 中是否正确AddEventHandler 语法print() 进行调试测试