cfx-vote-plugin
フォルダの内容を展開し、サーバーのresources/vote
ディレクトリにコピーします。
resources/vote
Top-Gamesパネルからトークンを取得します。
server.cfg
ファイルに以下の行を追加します:
ensure vote
set vote_token "YOUR_TOKEN_HERE"
Top-Gamesパネルで「Vote Plugin v3」を有効にします。「接続性テスト」をクリックしてプラグインをテストし、投票をシミュレートできます。
プレイヤーがサーバーに投票すると、プラグインが自動的にonPlayerVote
イベントをトリガーします。
-- 基本的な使用例
AddEventHandler('onPlayerVote', function(playername, date)
print('新しい投票を受け取りました!')
print('プレイヤー: ' .. playername)
print('日付: ' .. date)
-- ここに報酬ロジックを追加してください
end)
-- Example with QBCore Framework
local QBCore = exports['qb-core']:GetCoreObject()
AddEventHandler('onPlayerVote', function(playerId, date)
local Player = QBCore.Functions.GetPlayerByCitizenId(playerId)
if Player then
-- マネー報酬
Player.Functions.AddMoney('cash', 1000, "vote-reward")
-- Item reward
Player.Functions.AddItem('lockpick', 5, false, "vote-reward")
-- プレイヤー通知
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, '投票ありがとうございます!+$1000', 'success', 8000)
-- グローバルメッセージ
TriggerClientEvent('chat:addMessage', -1, {
color = {255, 194, 14},
multiline = true,
args = {"[VOTE]", Player.PlayerData.charinfo.firstname .. " " .. Player.PlayerData.charinfo.lastname .. " がサーバーに投票しました!"}
})
else
-- Offline player handling
print("Player " .. playerId .. " not found (offline?)")
end
end)
-- Example with Qbox Framework
AddEventHandler('onPlayerVote', function(playerId, date)
local player = exports.qbx_core:GetPlayer(playerId)
if player then
-- マネー報酬
player.Functions.AddMoney('cash', 1000, "vote-reward")
-- Item reward
exports.ox_inventory:AddItem(player.PlayerData.source, 'lockpick', 5)
-- プレイヤー通知
exports.qbx_core:Notify(player.PlayerData.source, '投票ありがとうございます!+$1000', 'success', 8000)
-- グローバルメッセージ
TriggerClientEvent('chat:addMessage', -1, {
color = {0, 162, 255},,
multiline = true,
args = {"[VOTE]", player.PlayerData.charinfo.firstname .. " " .. player.PlayerData.charinfo.lastname .. " がサーバーに投票しました!"}
})
else
-- Offline player handling
print("Player " .. playerId .. " not found (offline?)")
end
end)
resources/
に正しく配置されているか確認してくださいserver.cfg
にensure vote
の行があるか確認してくださいserver.cfg
のトークンが正しいか確認してくださいAddEventHandler
の構文を確認してくださいprint()
でテストしてください