FiveM Vote Plugin
Easily integrate the Top-Games voting system to your FiveM server and reward your players in real time.
Installation
Download the plugin
Download the latest version of the plugin from our GitHub repository.
Download v3Copy to resources
Extract and copy the contents of the cfx-vote-plugin folder into your server's resources/vote directory.
resources/vote
Get the token
Get your token from the Top-Games panel.
Configure server.cfg
Add the following lines to your server.cfg file:
ensure vote
set vote_token "YOUR_TOKEN_HERE"
Enable the plugin
Enable the "Vote Plugin v3" in your Top-Games panel. You can test the plugin by clicking on "Test connectivity" and simulate a vote.
Configuration and usage
Vote event
The plugin automatically triggers the onPlayerVote event when a player votes for your server.
vote-handler.lua
-- Basic usage example
AddEventHandler('onPlayerVote', function(playername, date)
print('New vote received!')
print('Player: ' .. playername)
print('Date: ' .. date)
-- Add your reward logic here
end)
Example with QBCore Framework
vote-rewards-qbcore.lua
-- Example with QBCore Framework
local QBCore = exports['qb-core']:GetCoreObject()
AddEventHandler('onPlayerVote', function(playerId, date)
local Player = QBCore.Functions.GetPlayerByCitizenId(playerId)
if Player then
-- Money reward
Player.Functions.AddMoney('cash', 1000, "vote-reward")
-- Item reward
Player.Functions.AddItem('lockpick', 5, false, "vote-reward")
-- Player notification
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, 'Thank you for your vote! +$1000', 'success', 8000)
-- Global message
TriggerClientEvent('chat:addMessage', -1, {
color = {255, 194, 14},
multiline = true,
args = {"[VOTE]", Player.PlayerData.charinfo.firstname .. " " .. Player.PlayerData.charinfo.lastname .. " voted for the server!"}
})
else
-- Offline player handling
print("Player " .. playerId .. " not found (offline?)")
end
end)
Example with Qbox Framework
vote-rewards-qbox.lua
-- Example with Qbox Framework
AddEventHandler('onPlayerVote', function(playerId, date)
local player = exports.qbx_core:GetPlayer(playerId)
if player then
-- Money reward
player.Functions.AddMoney('cash', 1000, "vote-reward")
-- Item reward
exports.ox_inventory:AddItem(player.PlayerData.source, 'lockpick', 5)
-- Player notification
exports.qbx_core:Notify(player.PlayerData.source, 'Thank you for your vote! +$1000', 'success', 8000)
-- Global message
TriggerClientEvent('chat:addMessage', -1, {
color = {0, 162, 255},,
multiline = true,
args = {"[VOTE]", player.PlayerData.charinfo.firstname .. " " .. player.PlayerData.charinfo.lastname .. " voted for the server!"}
})
else
-- Offline player handling
print("Player " .. playerId .. " not found (offline?)")
end
end)
Troubleshooting
- Check that the folder is properly placed in
resources/ - Make sure the
ensure voteline is inserver.cfg - Restart your server completely
- Check that your token is correct in
server.cfg - Enable the "Vote Plugin v3" in your Top-Games panel
- Make sure your server is accessible from the Internet
- Check the syntax of your
AddEventHandler - Make sure your script containing the handler is properly loaded
- Test with a simple
print()to debug
Information
Support
Need help? Our team is here to assist you.