diff --git a/README.md b/README.md index fe5bf31..dd3fbe8 100644 --- a/README.md +++ b/README.md @@ -10,30 +10,39 @@ It precharges the database in a table when opening the server or adding / removi # Commands ___ -1. ** ban: add id days reason ** (Allows ban a connected player) +1. **ban:add id days reason ** ( Allows ban a connected player ) - "id" is the player's number in the list - "days" must be a number to say how many days it will be ban. (0 days mean permanent) - - "reason" Ability to register why he is banished. Attention if there is no reason the player will see: "You are banned for: No reason" - - ban example: add 3 1 Troll (Will give ban player # 3 for 1 days with Troll reason) + - "reason" Ability to register why he is banished. Attention if there is no reason the player will see: "You are banned for: unknown reason" + - example ban:add 3 1 Troll (Will give ban player # 3 for 1 days with Troll reason) ___ -2. ** ban: unban "Steam Name" ** +2. **ban:addoff days name ( Allows ban a offline player ) + - "days" must be a number to say how many days it will be ban. (0 days mean permanent) + - "name" is the player's steam name + - example:addoff 3 Alex Garcio (Will ask you to entry ban:reason to continu) +2.1 *** /ban:reason (reason) + - "reason" Ability to register why he is banished. + - example ban:reason reason (Will ban player you have entry before for X days and the reason) +___ +3. **ban:unban "Steam Name" ** - Deban the player matching the written name. - - Example ban: unban Alex Garcio (Will remove from the ban list the player + - Example ban:unban Alex Garcio (Will remove from the ban list the player) ___ -3. ** ban: load ** (reload the BanList and the BanListHistory) +4. **ban:load ** (reload the BanList and the BanListHistory) - Can be used if you edit directly in your database. ___ -4. ** ban: history option "Steam Name" ** (Allows you to view the ban history of a player offline or online) +5. **ban:history option "Steam Name" ** (Allows you to view the ban history of a player offline or online) - "option" - 0 To display all the banns of a player - 1 To display only the first ban - 2 To display only the second ban - 3 ect ...... - 4 ect ...... -- Example ban: history 0 Alex Garcio (Go to display all the list of player's bans) +- Example ban:history 0 Alex Garcio (Go to display all the list of player's bans) # Required resource - Async +- Esx (Optional) # To do - Add a config for text messages to facilitate translation. @@ -58,17 +67,26 @@ ___ 1. **ban:add id jours raison** ( Permet de ban un joueur connecté ) - "id" correspond au chiffre du joueur dans la liste - "jours" doit être un chiffre pour dire combien de jours il va etre ban. (0 jours veux dire permanent) - - "raison" Possibilité d'inscrire pourquoi il est bani. Attention si il n'y a pas de raison le joueur va voir : "Vous etes banni pour : Aucune raison" + - "raison" Possibilité d'inscrire pourquoi il est bani. Attention si il n'y a pas de raison le joueur va voir : "Vous etes banni pour : Raison Inconnue" - exemple ban:add 3 1 Troll (Va donner bannir le joueur #3 pour 1 jours avec la raison Troll) ___ -2. **ban:unban "Nom Steam"** + +2. **ban:addoff jours nom ( Vous permet de ban un jours hors ligne ) + - "jours" doit être un chiffre pour dire combien de jours il va etre ban. (0 jours veux dire permanent) + - "nom" correspond au nom steam du joueur + - example:addoff 3 Alex Garcio (Va vous demander de faire ban:reason pour continuer) +2.1 *** /ban:reason (reason) + - "reason" Possibilité d'inscrire pourquoi il est bani. + - example ban:reason reason (Va donner bannir le joueur que vous avez entré plus tot pour la raison entrer ici) +___ +3. **ban:unban "Nom Steam"** - Déban le joueur correcpondant au nom écrit. - Exemple ban:unban Alex Garcio (Va enlever de la liste de ban le joueur) ___ -3. **ban:load** ( Recharge la BanList et la BanListHistory ) +4. **ban:load** ( Recharge la BanList et la BanListHistory ) - Peut etre utilisé si vous modifiez directement dans votre base de données. ___ -4. **ban:history option "Nom Steam"** ( Permet d'afficher l'historique de ban d'un joueur hors ligne ou en ligne ) +5. **ban:history option "Nom Steam"** ( Permet d'afficher l'historique de ban d'un joueur hors ligne ou en ligne ) - "option" - 0 Pour afficher tout les bans d'un joueur - 1 Pour afficher seulement le premier ban @@ -79,6 +97,7 @@ ___ # Ressource requis - Async +- Esx (Optionel) # A Faire - Ajouter une config pour les messages texte afin de faciliter la traduction. diff --git a/config.lua b/config.lua index d711bf3..97ec996 100644 --- a/config.lua +++ b/config.lua @@ -1,5 +1,6 @@ Config = {} Config.Lang = 'fr' +Config.esx = true --Turn this true if you are using esx Config.TextFr = { @@ -8,6 +9,8 @@ Config.TextFr = { banlistloaded = "La BanList a ete charger avec succes.", historyloaded = "La BanListHistory a ete charger avec succes.", loaderror = "ERROR : La BanList n a pas été charger.", + addoff = "Veillez entrer /ban:addoff (Durée en jours) (Nom steam)", + forcontinu = " jours. Pour continuer entrer /ban:reason (Raison du ban)", noreason = "Raison Inconnue", during = " pendant : ", noresult = "Il n'y a pas autant de résultats !", @@ -18,7 +21,7 @@ Config.TextFr = { yourban = "Vous avez ete ban pour : ", yourpermban = "Vous avez ete ban permanant pour : ", youban = "Vous avez banni : ", - forr = ". pour : ", + forr = " jours. Pour : ", permban = " de facon permanente parce que ", timeleft = ". Il reste : ", day = " Jours ", @@ -33,6 +36,8 @@ Config.TextEn = { banlistloaded = "The BanList has been loaded successfully.", historyloaded = "The BanListHistory has been loaded successfully.", loaderror = "ERROR: The BanList was not loaded.", + addoff = "Please enter /ban:addoff (Duration in days) (Steam name)", + forcontinu = " days. To continue entering /ban:reason (Ban reason)", noreason = "unknown reason", during = " during : ", noresult = "There are not as many results!", @@ -43,7 +48,7 @@ Config.TextEn = { yourban = "You have been ban for : ", yourpermban = "You have been ban permanent for : ", youban = "You have ban : ", - forr = ". for : ", + forr = " days. For : ", permban = " permanently for ", timeleft = ". Time remains : ", day = " Days ", diff --git a/server.lua b/server.lua index df25a81..be4cf98 100644 --- a/server.lua +++ b/server.lua @@ -1,4 +1,6 @@ local Text = {} +local lastduree = "" +local lasttarget = "" local BanList = {} local BanListLoad = false local BanListHistory = {} @@ -157,6 +159,71 @@ TriggerEvent('es:addGroupCommand', 'ban:add', "admin", function (source, args, u end end) +TriggerEvent('es:addGroupCommand', 'ban:addoff', "admin", function (source, args, user) + if args ~= "" then + lastduree = tonumber(args[1]) + lasttarget = table.concat(args, " ",2) + if lastduree ~= "" then + if lastduree ~= "" then + TriggerClientEvent('chatMessage', source, "BanList", {255, 0, 0}, lasttarget .. Text.during .. lastduree .. Text.forcontinu) + else + TriggerClientEvent('chatMessage', source, "BanList", {255, 0, 0}, Text.invalidid) + end + else + TriggerClientEvent('chatMessage', source, "BanList", {255, 0, 0}, Text.invalidtime) + end + else + TriggerClientEvent('chatMessage', source, "BanList", {255, 0, 0}, Text.addoff) + end +end) + +TriggerEvent('es:addGroupCommand', 'ban:reason', "admin", function (source, args, user) + local duree = lastduree + local target = lasttarget + local reason = table.concat(args, " ",1) + local identifier = "" + + if Config.esx then + MySQL.Async.fetchScalar('SELECT identifier FROM users WHERE name=@name', + { + ['@name'] = name + }, function(_identifier) + if identifier ~= nil then + identifier = _identifier + end + end) + else + target = nil + end + + if reason == "" then + reason = Text.noreason + end + + if target ~= nil then + if duree ~= nil and duree < 365 then + local sourceplayername = GetPlayerName(source) + local targetplayername = target + + if duree > 0 then + ban(source,target,identifier,targetplayername,sourceplayername,duree,reason) + DropPlayer(target, Text.yourban .. reason) + lastduree = "" + lasttarget = "" + else + permban(source,target,identifier,targetplayername,sourceplayername,duree,reason) + DropPlayer(target, Text.yourpermban .. reason) + lastduree = "" + lasttarget = "" + end + + else + TriggerClientEvent('chatMessage', source, "BanList", {255, 0, 0}, Text.invalidtime) + end + else + TriggerClientEvent('chatMessage', source, "BanList", {255, 0, 0}, Text.invalidid) + end +end) function ban(source,target,identifier,targetplayername,sourceplayername,duree,reason)