Skip to content

Commit

Permalink
Merge pull request #6 from meyervp/offlineMode
Browse files Browse the repository at this point in the history
update fxmanifest and add offline players management
  • Loading branch information
Metrakit authored Jul 5, 2020
2 parents e1951cc + 7a17700 commit 5eea47f
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 26 deletions.
5 changes: 0 additions & 5 deletions vote/__resource.lua

This file was deleted.

4 changes: 4 additions & 0 deletions vote/config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Config = {}
Config.giveMoney = true
Config.amountGiven = 1500
Config.addMoneyOfflinePlayer = true
79 changes: 58 additions & 21 deletions vote/example_esx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
_Prefix = '^2[voteTopServeur]^0'
_PrefixError = '^1[voteTopServeur]^0'

local function getPlayerByName(playername)
local xPlayers = ESX.GetPlayers()
Expand All @@ -12,30 +14,65 @@ local function getPlayerByName(playername)
return xPlayer
end
end
return nil
return false
end

AddEventHandler('onPlayerVote', function (playername, ip, date)
local Player = getPlayerByName(playername)
if Player then
Player.addMoney(100)

-- Pour notifier (requiert pNotify) :
-- TriggerClientEvent("pNotify:SendNotification", -1, {
-- text = ""..playername.. " a voté pour le serveur</br>Il a gagné <b style='color:green'>100$</b>",
-- type = "info",
-- timeout = 15000,
-- layout = "centerRight"
-- })
else
print("Joueur introuvable !")
if Config.giveMoney then
if getPlayerByName(playername) then
Player.addMoney(Config.amountGiven)

-- Pour notifier (requiert pNotify) :
-- TriggerClientEvent("pNotify:SendNotification", -1, {
-- text = "Un inconnu a voté pour le serveur !",
-- type = "info",
-- timeout = 15000,
-- layout = "centerRight"
-- })
-- Pour notifier (requiert pNotify) :
--TriggerClientEvent("pNotify:SendNotification", -1, {
-- text = ""..playername.. " a voté pour le serveur</br>Il a gagné <b style='color:green'>".. Config.amountGiven .."$</b>",
-- type = "info",
-- timeout = 2500,
-- layout = "centerRight"
--})
return
end
if Config.addMoneyOfflinePlayer == false then
-- Pour notifier (requiert pNotify) :
--TriggerClientEvent("pNotify:SendNotification", -1, {
-- text = "Un inconnu a voté pour le serveur !",
-- type = "info",
-- timeout = 1000,
-- layout = "centerRight"
--})
return
end
MySQL.Async.fetchAll("SELECT * FROM users WHERE name = @name", {
['@name'] = playername
}, function (result)
if result[1] then
-- Pour notifier (requiert pNotify) :
MySQL.Async.execute('UPDATE users SET bank = @bank WHERE name = @name',
{
['@bank'] = result[1]['bank'] + Config.amountGiven,
['@name'] = result[1]['name']
}, function(rowschanged)
if rowschanged then
--TriggerClientEvent("pNotify:SendNotification", -1, {
-- text = ""..playername.. " a voté pour le serveur</br>Il a gagné <b style='color:green'>".. Config.amountGiven .."$</b>",
-- type = "info",
-- timeout = 2500,
-- layout = "centerRight"
--})
else
print(_PrefixError .. " : add bank money for username : " .. playername .. " !")
end
end)
else
print(_PrefixError .. " : Joueur introuvable : "..playername.." !")

-- Pour notifier (requiert pNotify) :
--TriggerClientEvent("pNotify:SendNotification", -1, {
-- text = "Un inconnu a voté pour le serveur !",
-- type = "info",
-- timeout = 1000,
-- layout = "centerRight"
--})
end
end)
end
end)
13 changes: 13 additions & 0 deletions vote/fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
description 'Vote plugin pour Top-Serveurs (top-serveurs.net)'

server_script "lib/VotePlugin.net.dll"

server_script {
"config.lua",
"example.lua",
"example_esx.lua"
}

fx_version 'adamant'

game 'gta5'

1 comment on commit 5eea47f

@keatans
Copy link

@keatans keatans commented on 5eea47f Sep 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

description 'Vote plugin pour Top-Serveurs (top-serveurs.net)'

server_script "lib/VotePlugin.net.dll"

server_script {
"config.lua",
"@mysql-async/lib/MySQL.lua",
"example_esx.lua"
}

fx_version 'adamant'

game 'gta5'

Please sign in to comment.