├── .gitignore
├── vote
├── lib
│ └── VotePlugin.net.dll
├── config.lua
├── config.ini
├── example.lua
├── fxmanifest.lua
└── example_esx.lua
├── README.md
└── README_FR.md
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
--------------------------------------------------------------------------------
/vote/lib/VotePlugin.net.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Top-Serveurs/fivem-vote-plugin/HEAD/vote/lib/VotePlugin.net.dll
--------------------------------------------------------------------------------
/vote/config.lua:
--------------------------------------------------------------------------------
1 | Config = {}
2 | Config.giveMoney = true
3 | Config.amountGiven = 1500
4 | Config.addMoneyOfflinePlayer = true
--------------------------------------------------------------------------------
/vote/config.ini:
--------------------------------------------------------------------------------
1 | # The token is mandatory. It is the token of your server file available on your panel https://top-games.net/gta
2 | Token="XXXX"
3 | # The port is optional. The default port is port 8192
4 | Port=8192
--------------------------------------------------------------------------------
/vote/example.lua:
--------------------------------------------------------------------------------
1 | -- This is a basic example using ESX.
2 | -- It's only a demo, it's up to you to modify at your convenience.
3 |
4 | AddEventHandler('onPlayerVote', function (playername, ip, date)
5 | print(playername)
6 | print(ip)
7 | print(date)
8 | end)
--------------------------------------------------------------------------------
/vote/fxmanifest.lua:
--------------------------------------------------------------------------------
1 | description 'Voting plugin for Top-Games (top-games.net)'
2 |
3 | server_script "lib/VotePlugin.net.dll"
4 |
5 | server_script {
6 | "config.lua",
7 | "example.lua",
8 | "example_esx.lua"
9 | }
10 |
11 | fx_version 'adamant'
12 |
13 | game 'gta5'
--------------------------------------------------------------------------------
/vote/example_esx.lua:
--------------------------------------------------------------------------------
1 | -- This is a basic example using ESX.
2 | -- It's only a demo, it's up to you to modify at your convenience.
3 |
4 | ESX = nil
5 | TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
6 | _Prefix = '^2[voteTopGames]^0'
7 | _PrefixError = '^1[voteTopGames]^0'
8 |
9 | local function getPlayerByName(playername)
10 | local xPlayers = ESX.GetPlayers()
11 | for i=1, #xPlayers, 1 do
12 | local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
13 | if xPlayer ~= nil and xPlayer.getName() == playername then
14 | return xPlayer
15 | end
16 | end
17 | return false
18 | end
19 |
20 | AddEventHandler('onPlayerVote', function (playername, ip, date)
21 | if Config.giveMoney then
22 | if getPlayerByName(playername) then
23 | Player.addMoney(Config.amountGiven)
24 |
25 | -- For notify (pNotify needed):
26 | --TriggerClientEvent("pNotify:SendNotification", -1, {
27 | -- text = ""..playername.. " voted for the serverHe won ".. Config.amountGiven .."$",
28 | -- type = "info",
29 | -- timeout = 2500,
30 | -- layout = "centerRight"
31 | --})
32 | return
33 | end
34 | if Config.addMoneyOfflinePlayer == false then
35 | -- For notify (pNotify needed):
36 | --TriggerClientEvent("pNotify:SendNotification", -1, {
37 | -- text = "A stranger voted for the server!",
38 | -- type = "info",
39 | -- timeout = 1000,
40 | -- layout = "centerRight"
41 | --})
42 | return
43 | end
44 | MySQL.Async.fetchAll("SELECT * FROM users WHERE name = @name", {
45 | ['@name'] = playername
46 | }, function (result)
47 | if result[1] then
48 | -- For notify (pNotify needed):
49 | MySQL.Async.execute('UPDATE users SET bank = @bank WHERE name = @name',
50 | {
51 | ['@bank'] = result[1]['bank'] + Config.amountGiven,
52 | ['@name'] = result[1]['name']
53 | }, function(rowschanged)
54 | if rowschanged then
55 | --TriggerClientEvent("pNotify:SendNotification", -1, {
56 | -- text = ""..playername.. " voted for the serverHe won ".. Config.amountGiven .."$",
57 | -- type = "info",
58 | -- timeout = 2500,
59 | -- layout = "centerRight"
60 | --})
61 | else
62 | print(_PrefixError .. ": add bank money for username: " .. playername .. " !")
63 | end
64 | end)
65 | else
66 | print(_PrefixError .. ": Player not found: "..playername.." !")
67 |
68 | -- For notify (pNotify needed):
69 | --TriggerClientEvent("pNotify:SendNotification", -1, {
70 | -- text = "A stranger voted for the server!",
71 | -- type = "info",
72 | -- timeout = 1000,
73 | -- layout = "centerRight"
74 | --})
75 | end
76 | end)
77 | end
78 | end)
79 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # (old) Votes plugin for GTA V FIVEM
2 |
3 | **Important:** We have created a new plugin available here: https://github.com/Top-Serveurs/cfx-vote-plugin. This plugin is therefore no longer supported by the Top-Games team, you can still use it but we strongly recommend that you use the new plugin.
4 |
5 | - [:us: English documentation](./README.md)
6 | - [:fr: Documentation française](./README_FR.md)
7 |
8 | This is the Top-Games (also Top-Serveurs) votes plugin (https://top-games.net/gta) which is used to receive votes directly on your FIVEM server. When a player votes, Top-Games directly notifies your server and you can thus reward your players or make a ranking of the best voters (by example), the possibilities are endless.
9 |
10 | But what is FiveM for? [FiveM](https://top-games.net/gta/type/fivem) allows you to create a GTA server, you can find in particular a [GTA 5 RP](https://top-games.net/gta/type/roleplay) on our site.
11 |
12 | **Important:** This version of the plugin is in resource form according to the latest versions of FiveM, and therefore uses an fxmanifest. If you are having configuration problems it is most likely that you are using an older version of FiveM. So **if you are using an old version of Fivem, we advise you to download the old version of our plugin** (0.1.X): https://github.com/Top-Serveurs/fivem-vote-plugin/releases/tag/0.1.4.3.
13 |
14 | ## Features
15 |
16 | - Event `onPlayerVote` allowing the reception of the votes cast on your server file in real time! This therefore allows actions to be taken accordingly. Example: rewarding voters.
17 |
18 | ## Installation
19 |
20 | 1. Copy the `vote` directory to the `resources` directory of your FIVEM server
21 | 2. Configure the voting plugin in the `vote/config.ini` file like this:
22 |
23 | ```ini
24 | Token="XXXX" # The token is mandatory. It is the token of your server file available on your panel https://top-games.net/gta
25 | Port=8192 # The listening port of the plugin. Default is port 8192 but you can specify which one you want. Do not forget to configure it also on the management panel of your server on https://top-games.net/gta
26 | ```
27 | **Remember to open the chosen port (for example 8192) in UDP on your server/firewall**.
28 |
29 | 3. Edit your `server.cfg` file to activate the plugin. Just add the following line:
30 |
31 | ```
32 | start vote
33 | ```
34 |
35 | 4. Use the `onPlayerVote` event to receive the votes cast. An example is available in the `example.lua` file and in the `example_esx.lua` file for a small example with ESX (remember to delete the examples). Here is an example:
36 |
37 | ```lua
38 | AddEventHandler('onPlayerVote', function (playername, ip, date)
39 | -- Add actions here when a vote is received.
40 | -- For example: give In-Game money, give points, save in DB, ...
41 | print(playername)
42 | print(ip)
43 | print(date)
44 | end)
45 | ```
46 |
47 | 5. Start your server. If you see the message `[VotePlugin] Voting plugin active on port xxxx`, everything is fine!
48 |
49 | 6. Last step: activate the voting plugin on the management panel of your server file. Go to https://top-games.net/gta in your server management, at the bottom there is a `Voting plugin` section. You need to activate the plugin and specify the port you indicated above in the `config.ini` file. Once the plugin is activated, you can click on the button to test the connectivity and then it's up to you!
50 |
51 |
52 | ## Help & Suggestions
53 |
54 | If you need help setting up the plugin or if you have any suggestions, do not hesitate to contact us here: https://top-games.net/contact or at contact@top-games.net.
55 |
56 | ## Contributors
57 |
58 | Thanks to our contributors who help us improve the plugin:
59 | - [@meyervp](https://github.com/meyervp)
60 | - [@dolutattoo](https://github.com/dolutattoo)
61 |
--------------------------------------------------------------------------------
/README_FR.md:
--------------------------------------------------------------------------------
1 | # Plugin de votes pour GTA V FIVEM
2 |
3 | **Important :** Nous avons créé un nouveau plugin disponible ici : https://github.com/Top-Serveurs/cfx-vote-plugin. Ce plugin n'est donc plus supporté par l'équipe Top-Serveurs, vous pouvez toujours l'utiliser mais nous vous recommandons chaudement d'utiliser le nouveau plugin.
4 |
5 | - [:us: English documentation](./README.md)
6 | - [:fr: Documentation française](./README_FR.md)
7 |
8 | Ceci est le plugin de votes de Top-Serveurs (https://gta.top-serveurs.net) qui sert à réceptionner les votes directement sur votre serveur FIVEM. Lorsqu'un joueur vote, Top-Serveurs notifie directement votre serveur et vous pouvez ainsi récompenser vos joueurs ou effectuer un clasement des meilleurs voteurs (par exemple), les possibilités sont infinies.
9 |
10 | Mais à quoi sert FiveM ? [FiveM](https://gta.top-serveurs.net/type/fivem) vous permet de créer un serveur GTA, vous pouvez trouver notamment un serveur [GTA 5 RP](https://gta.top-serveurs.net/type/roleplay) sur notre site.
11 |
12 | **Important :** Cette version du plugin est sous forme de resource conformément aux dernières versions de FiveM, et elle utilise donc un fxmanifest. Si vous rencontrez des problèmes de configuration c'est certainement que vous utilisez une ancienne version de FiveM. Donc **si vous utilisez une ancienne version de Fivem, nous vous conseillons de télécharger l'ancienne version de notre plugin** (0.1.X) : https://github.com/Top-Serveurs/fivem-vote-plugin/releases/tag/0.1.4.3.
13 |
14 | ## Fonctionnalités
15 |
16 | - Event `onPlayerVote` permettant la réception des votes effectués sur votre fiche serveur en temps réel ! Ceci permet donc d'effectuer des actions en conséquence. Exemple : récompenser les voteurs.
17 |
18 | ## Installation
19 |
20 | 1. Copiez le répertoire `vote` dans le dossier `resources` de votre serveur FIVEM
21 | 2. Configurez le plugin de vote dans le fichier `vote/config.ini` comme ceci :
22 |
23 | ```ini
24 | Token="XXXX" # La token est obligatoire. C'est la token de votre fiche serveur disponible sur votre panel https://gta.top-serveurs.net
25 | Port=8192 # Le port d'écoute du plugin. Par défaut, c'est le port 8192 mais vous pouvez spécifier celui que vous voulez. N'oubliez pas de le configurer aussi sur le panel de gestion de votre serveur sur https://gta.top-serveurs.net
26 | ```
27 | **Pensez à bien ouvrir le port choisi (par exemple 8192) en UDP sur votre serveur/firewall**.
28 |
29 | 3. Editez votre fichier `server.cfg` pour activer le plugin. Il suffit de rajouter la ligne suivante :
30 |
31 | ```
32 | start vote
33 | ```
34 |
35 | 4. Utilisez l'event `onPlayerVote` pour réceptionner les votes effectués. Un exemple est disponible dans le fichier `example.lua` et dans le fichier `example_esx.lua` pour un petit exemple avec ESX (pensez à supprimer les exemples). Voici un exemple :
36 |
37 | ```lua
38 | AddEventHandler('onPlayerVote', function (playername, ip, date)
39 | -- Ajouter ici des actions lorsqu'un vote est perçu.
40 | -- Par exemple : donner de l'argent In-Game, donner des points, enregistrer en BDD, ...
41 | print(playername)
42 | print(ip)
43 | print(date)
44 | end)
45 | ```
46 |
47 | 5. Démarrez votre serveur. Si vous voyez le message `[VotePlugin] Plugin de vote actif sur le port xxxx`, tout est bon !
48 |
49 | 6. Dernière étape : activez le plugin de vote sur le panel de gestion de votre fiche serveur. Rendez-vous sur https://gta.top-serveurs.net dans la gestion de votre serveur, en bas il y a une section `Plugin de vote`. Vous devez activer le plugin et spécifier le port que vous avez indiqué plus haut dans le fichier `config.ini`. Une fois le plugin activé, vous pouvez cliquer sur le bouton pour tester la connectivité et ensuite à vous de jouer !
50 |
51 |
52 | ## Aide & Suggestions
53 |
54 | Si vous avez besoin d'aide sur la mise en place du plugin ou si vous avez des suggestions, n'hésitez pas à nous contacter ici : https://gta.top-serveurs.net/contact ou à gta@top-serveurs.net.
55 |
56 | ## Contributeurs
57 |
58 | Merci à nos contributeurs qui nous aident à améliorer le plugin :
59 | - [@meyervp](https://github.com/meyervp)
60 | - [@dolutattoo](https://github.com/dolutattoo)
61 |
--------------------------------------------------------------------------------