diff --git a/i18n/fr.json b/i18n/fr.json index 683714c1..f76b1a5f 100644 --- a/i18n/fr.json +++ b/i18n/fr.json @@ -36,6 +36,10 @@ "red": "Rouge", "blue": "Bleu", "green": "Vert", + "white": "Blanc", + "yellow": "Jaune", + "purple": "Violet", + "cyan": "Bleu ciel", "vehicle_1": "Sedan 1", "vehicle_4": "Sedan 2", "vehicle_5": "Sedan 3", @@ -250,6 +254,14 @@ "no_delivery": "Vous n'avez pas de livraison !", "no_delivery_point": "Vous n'êtes pas à votre destination de livraison !", "finished_delivery": "Vous avez terminé votre livraison ainsi vous recevez {1} {2}", + "mecanic_job": "Mécanicien", + "mecanic_menu": "Menu Mécanicien", + "start_stop_mecanic": "Commencer / prendre une pause", + "RepaireMecanic": "Réparer le véhicule", + "ColorMecanic": "Peindre le véhicule", + "RefuelMecanic": "Faire le plein du véhicule", + "color_menu": "Palette de couleur", + "car_already_refuelled": "Ce véhicule à déjà le plein", "city": "Centre-Ville", "unprocessed_rock": "Pierre non transformée", "processed_rock": "Pierre transformée", diff --git a/inventory/server.lua b/inventory/server.lua index e5331e4d..c167e460 100644 --- a/inventory/server.lua +++ b/inventory/server.lua @@ -51,9 +51,15 @@ AddRemoteEvent("UseInventory", function(player, item, amount) addPlayerThirst(player, 5*amount) end if item == "water_bottle" then + local x, y, z = GetPlayerLocation(player) + bottleofwater = CreateObject(1627, x, y, z) + SetObjectAttached(bottleofwater, ATTACH_PLAYER, player, -9.0, 5.0, -10.0, 0.0, 0.0, 0.0, "hand_r") SetPlayerAnimation(player, "DRINKING") RemoveInventory(player, item, amount) - addPlayerThirst(player, 25*amount) + addPlayerThirst(player, 50*amount) + Delay(2000, function() + DestroyObject(bottleofwater) + end) end if item == "health_kit" then if GetPlayerHealth(player) == 100 then @@ -267,8 +273,8 @@ function DisplayPlayerBackpack(player, anim) if GetPlayerBag(player) == 1 then if PlayerData[player].backpack == nil then -- Pour vérifier s'il n'a pas déjà un sac local x, y, z = GetPlayerLocation(player) - PlayerData[player].backpack = CreateObject(820, x, y, z) - SetObjectAttached(PlayerData[player].backpack, ATTACH_PLAYER, player, -30.0, -9.0, 0.0, -90.0, 0.0, 0.0, "spine_03") + PlayerData[player].backpack = CreateObject(1281, x, y, z) + SetObjectAttached(PlayerData[player].backpack, ATTACH_PLAYER, player, -27.0, -20.0, 0.0, -180.0, 90.0, -90.0, "spine_03") if anim == 1 then BackpackPutOnAnim(player) end -- Petite animation RP end else diff --git a/mecanic/client.lua b/mecanic/client.lua new file mode 100644 index 00000000..d7b42ee7 --- /dev/null +++ b/mecanic/client.lua @@ -0,0 +1,108 @@ +local Dialog = ImportPackage("dialogui") +local _ = function(k,...) return ImportPackage("i18n").t(GetPackageName(),k,...) end + +local mecanicNPC +local mecanicNpcMenu +local mecanicMenu +local colorMenu + +AddRemoteEvent("Setupmecanic", function(mecanicnpc) + mecanicNPC = mecanicnpc +end) + +AddEvent("OnTranslationReady", function() + mecanicNpcMenu = Dialog.create(_("mecanic_menu"), nil, _("start_stop_mecanic") ,_("cancel")) + mecanicMenu = Dialog.create(_("mecanic_menu"), nil, _("RepaireMecanic"), _("ColorMecanic"), _("RefuelMecanic"), _("cancel")) + colorMenu = Dialog.create(_("color_menu"), nil, _("black"), _("white"), _("blue"), _("green"), _("red"), _("yellow"), _("purple"), _("cyan"), _("cancel")) +end) + +AddEvent("OnKeyPress", function( key ) + if key == "E" and not onSpawn and not onCharacterCreation then + local Nearestmecanic = GetNearestmecanic() + if Nearestmecanic ~= 0 then + local ScreenX, ScreenY = GetScreenSize() + SetMouseLocation(math.floor(ScreenX / 2), math.floor(ScreenY / 2)) + Dialog.show(mecanicNpcMenu) + end + end + if key == "F3" and not onSpawn and not onCharacterCreation then + local ScreenX, ScreenY = GetScreenSize() + SetMouseLocation(math.floor(ScreenX / 2), math.floor(ScreenY / 2)) + CallRemoteEvent("OpenmecanicMenu") + end +end) + +AddEvent("OnDialogSubmit", function(dialog, button, ...) + if dialog == mecanicNpcMenu then + if button == 1 then + CallRemoteEvent("StartStopmecanic") + end + end + if dialog == mecanicMenu then + if button == 1 then + CallRemoteEvent("RepaireMecanic") + end + if button == 2 then + CallRemoteEvent("ColorMecanic") + end + if button == 3 then + CallRemoteEvent("RefuelMecanic") + end + end + if dialog == colorMenu then + if button == 1 then + CallRemoteEvent("black") + end + if button == 2 then + CallRemoteEvent("white") + end + if button == 3 then + CallRemoteEvent("blue") + end + if button == 4 then + CallRemoteEvent("green") + end + if button == 5 then + CallRemoteEvent("red") + end + if button == 6 then + CallRemoteEvent("yellow") + end + if button == 7 then + CallRemoteEvent("purple") + end + if button == 8 then + CallRemoteEvent("cyan") + end + if button == 9 then + CallRemoteEvent("cancel") + end + end +end) + +AddRemoteEvent("mecanicMenu", function() + Dialog.show(mecanicMenu) +end) + +AddRemoteEvent("colorMenu", function() + Dialog.show(colorMenu) +end) + +function GetNearestmecanic() + local x, y, z = GetPlayerLocation() + + for k,v in pairs(GetStreamedNPC()) do + local x2, y2, z2 = GetNPCLocation(v) + local dist = GetDistance3D(x, y, z, x2, y2, z2) + + if dist < 250.0 then + for k,i in pairs(mecanicNPC) do + if v == i then + return v + end + end + end + end + + return 0 +end \ No newline at end of file diff --git a/mecanic/server.lua b/mecanic/server.lua new file mode 100644 index 00000000..8482b0aa --- /dev/null +++ b/mecanic/server.lua @@ -0,0 +1,295 @@ +local _ = function(k,...) return ImportPackage("i18n").t(GetPackageName(),k,...) end + +local mecanicNpc = { + { + location = { 196309, 206548, 1312, 90 }, + spawn = { 196079, 207180, 1312, 90 } + } +} +local mecanicNpcCached = {} +local playermecanic = {} + +AddEvent("OnPackageStart", function() + for k,v in pairs(mecanicNpc) do + mecanicNpc[k].npc = CreateNPC(mecanicNpc[k].location[1], mecanicNpc[k].location[2], mecanicNpc[k].location[3],mecanicNpc[k].location[4]) + CreateText3D(_("mecanic_job").."\n".._("press_e"), 18, mecanicNpc[k].location[1], mecanicNpc[k].location[2], mecanicNpc[k].location[3] + 120, 0, 0, 0) + table.insert(mecanicNpcCached, mecanicNpc[k].npc) + end +end) + +AddEvent("OnPlayerQuit", function( player ) + if playermecanic[player] ~= nil then + playermecanic[player] = nil + end +end) + +AddEvent("OnPlayerJoin", function(player) + CallRemoteEvent(player, "Setupmecanic", mecanicNpcCached) +end) + +AddRemoteEvent("StartStopmecanic", function(player) + local nearestmecanic = GetNearestmecanic(player) + if PlayerData[player].job == "" then + if PlayerData[player].job_vehicle ~= nil then + DestroyVehicle(PlayerData[player].job_vehicle) + DestroyVehicleData(PlayerData[player].job_vehicle) + PlayerData[player].job_vehicle = nil + CallRemoteEvent(player, "ClientDestroyCurrentWaypoint") + else + local isSpawnable = true + local jobCount = 0 + for k,v in pairs(PlayerData) do + if v.job == "mecanic" then + jobCount = jobCount + 1 + end + end + if jobCount == 15 then + return CallRemoteEvent(player, "MakeNotification", _("job_full"), "linear-gradient(to right, #ff5f6d, #ffc371)") + end + for k,v in pairs(GetAllVehicles()) do + local x, y, z = GetVehicleLocation(v) + local dist2 = GetDistance3D(mecanicNpc[nearestmecanic].spawn[1], mecanicNpc[nearestmecanic].spawn[2], mecanicNpc[nearestmecanic].spawn[3], x, y, z) + if dist2 < 500.0 then + isSpawnable = false + break + end + end + if isSpawnable then + local vehicle = CreateVehicle(7, mecanicNpc[nearestmecanic].spawn[1], mecanicNpc[nearestmecanic].spawn[2], mecanicNpc[nearestmecanic].spawn[3], mecanicNpc[nearestmecanic].spawn[4]) + PlayerData[player].job_vehicle = vehicle + SetPlayerAnimation(player, "HANDSHAKE") + CreateVehicleData(player, vehicle, 7) + plot = CreateObject(1392, 0, 0, 0) + plots = CreateObject(1393, 0, 0, 0) + panneau = CreateObject(1404, 0, 0, 0) + SetObjectAttached(plot, ATTACH_VEHICLE, vehicle, -275.0, 50.0, 77.0, 0.0, 90.0, 0.0) + SetObjectAttached(plots, ATTACH_VEHICLE, vehicle, -275.0, 0.0, 77.0, 0.0, 90.0, 0.0) + SetObjectAttached(panneau, ATTACH_VEHICLE, vehicle, -85.0, 0.0, 88.0, 0.0, 0.0, 0.0) + SetVehicleLicensePlate(vehicle, "MECANICIEN") + SetVehicleColor(vehicle, RGB(255, 55, 0)) + SetVehiclePropertyValue(vehicle, "locked", true, true) + PlayerData[player].job = "mecanic" + return + end + end + elseif PlayerData[player].job == "mecanic" then + if PlayerData[player].job_vehicle ~= nil then + SetPlayerAnimation(player, "HANDSHAKE") + DestroyVehicle(PlayerData[player].job_vehicle) + DestroyVehicleData(PlayerData[player].job_vehicle) + PlayerData[player].job_vehicle = nil + end + PlayerData[player].job = "" + playermecanic[player] = nil + CallRemoteEvent(player, "ClientDestroyCurrentWaypoint") + end +end) + +AddRemoteEvent("OpenmecanicMenu", function(player) + if PlayerData[player].job == "mecanic" then + CallRemoteEvent(player, "mecanicMenu") + end +end) + +AddRemoteEvent("ColorMecanic", function(player) + if PlayerData[player].job == "mecanic" then + CallRemoteEvent(player, "colorMenu") + end +end) + +AddRemoteEvent("RepaireMecanic", function(player) + local nearestCar = GetNearestCar(player) + if nearestCar ~= 0 then + if GetVehicleHealth(nearestCar) >= 5000 then + CallRemoteEvent(player, "MakeNotification", _("dont_need_repair"), "linear-gradient(to right, #ff5f6d, #ffc371)") + else + CallRemoteEvent(player, "LockControlMove", true) + SetPlayerAnimation(player, "COMBINE") + SetVehicleHoodRatio(nearestCar, 60) + Delay(4000, function() + SetVehicleHealth(nearestCar, 5000) + for i=1,8 do + SetVehicleDamage(nearestCar, i, 0) + end + CallRemoteEvent(player, "LockControlMove", false) + SetVehicleHoodRatio(nearestCar, 0.0) + SetPlayerAnimation(player, "STOP") + CallRemoteEvent(player, "MakeNotification", _("repair_successful"), "linear-gradient(to right, #00b09b, #96c93d)") + end) + end + end +end) + +AddRemoteEvent("black", function(player) + local nearestCar = GetNearestCar(player) + if nearestCar ~= 0 then + CallRemoteEvent(player, "LockControlMove", true) + SetPlayerAnimation(player, "COMBINE") + Delay(4000, function() + SetVehicleHealth(nearestCar, 5000) + SetVehicleColor(nearestCar, RGB(0, 0, 0)) + for i=1,8 do + SetVehicleDamage(nearestCar, i, 0) + end + CallRemoteEvent(player, "LockControlMove", false) + SetPlayerAnimation(player, "STOP") + end) + end +end) + +AddRemoteEvent("white", function(player) + local nearestCar = GetNearestCar(player) + if nearestCar ~= 0 then + CallRemoteEvent(player, "LockControlMove", true) + SetPlayerAnimation(player, "COMBINE") + Delay(4000, function() + SetVehicleHealth(nearestCar, 5000) + SetVehicleColor(nearestCar, RGB(255, 255, 255)) + for i=1,8 do + SetVehicleDamage(nearestCar, i, 0) + end + CallRemoteEvent(player, "LockControlMove", false) + SetPlayerAnimation(player, "STOP") + end) + end +end) + +AddRemoteEvent("blue", function(player) + local nearestCar = GetNearestCar(player) + if nearestCar ~= 0 then + CallRemoteEvent(player, "LockControlMove", true) + SetPlayerAnimation(player, "COMBINE") + Delay(4000, function() + SetVehicleHealth(nearestCar, 5000) + SetVehicleColor(nearestCar, RGB(0, 0, 255)) + for i=1,8 do + SetVehicleDamage(nearestCar, i, 0) + end + CallRemoteEvent(player, "LockControlMove", false) + SetPlayerAnimation(player, "STOP") + end) + end +end) + +AddRemoteEvent("green", function(player) + local nearestCar = GetNearestCar(player) + if nearestCar ~= 0 then + CallRemoteEvent(player, "LockControlMove", true) + SetPlayerAnimation(player, "COMBINE") + Delay(4000, function() + SetVehicleHealth(nearestCar, 5000) + SetVehicleColor(nearestCar, RGB(0, 255, 0)) + for i=1,8 do + SetVehicleDamage(nearestCar, i, 0) + end + CallRemoteEvent(player, "LockControlMove", false) + SetPlayerAnimation(player, "STOP") + end) + end +end) + +AddRemoteEvent("red", function(player) + local nearestCar = GetNearestCar(player) + if nearestCar ~= 0 then + CallRemoteEvent(player, "LockControlMove", true) + SetPlayerAnimation(player, "COMBINE") + Delay(4000, function() + SetVehicleHealth(nearestCar, 5000) + SetVehicleColor(nearestCar, RGB(255, 0, 0)) + for i=1,8 do + SetVehicleDamage(nearestCar, i, 0) + end + CallRemoteEvent(player, "LockControlMove", false) + SetPlayerAnimation(player, "STOP") + end) + end +end) + +AddRemoteEvent("yellow", function(player) + local nearestCar = GetNearestCar(player) + if nearestCar ~= 0 then + CallRemoteEvent(player, "LockControlMove", true) + SetPlayerAnimation(player, "COMBINE") + Delay(4000, function() + SetVehicleHealth(nearestCar, 5000) + SetVehicleColor(nearestCar, RGB(255, 255, 0)) + for i=1,8 do + SetVehicleDamage(nearestCar, i, 0) + end + CallRemoteEvent(player, "LockControlMove", false) + SetPlayerAnimation(player, "STOP") + end) + end +end) + +AddRemoteEvent("purple", function(player) + local nearestCar = GetNearestCar(player) + if nearestCar ~= 0 then + CallRemoteEvent(player, "LockControlMove", true) + SetPlayerAnimation(player, "COMBINE") + Delay(4000, function() + SetVehicleHealth(nearestCar, 5000) + SetVehicleColor(nearestCar, RGB(255, 0, 255)) + for i=1,8 do + SetVehicleDamage(nearestCar, i, 0) + end + CallRemoteEvent(player, "LockControlMove", false) + SetPlayerAnimation(player, "STOP") + end) + end +end) + +AddRemoteEvent("cyan", function(player) + local nearestCar = GetNearestCar(player) + if nearestCar ~= 0 then + CallRemoteEvent(player, "LockControlMove", true) + SetPlayerAnimation(player, "COMBINE") + Delay(4000, function() + SetVehicleHealth(nearestCar, 5000) + SetVehicleColor(nearestCar, RGB(0, 255, 255)) + for i=1,8 do + SetVehicleDamage(nearestCar, i, 0) + end + CallRemoteEvent(player, "LockControlMove", false) + SetPlayerAnimation(player, "STOP") + end) + end +end) + +AddRemoteEvent("RefuelMecanic", function(player) + local nearestCar = GetNearestCar(player) + if nearestCar ~= 0 then + print(VehicleData[nearestCar].fuel) + if VehicleData[nearestCar].fuel >= 100 then + CallRemoteEvent(player, "MakeNotification", _("car_already_refuelled"), "linear-gradient(to right, #ff5f6d, #ffc371)") + else + CallRemoteEvent(player, "LockControlMove", true) + SetPlayerAnimation(player, "COMBINE") + Delay(4000, function() + VehicleData[nearestCar].fuel = 100 + CallRemoteEvent(player, "MakeNotification", _("car_refuelled"), "linear-gradient(to right, #00b09b, #96c93d)") + CallRemoteEvent(player, "LockControlMove", false) + SetPlayerAnimation(player, "STOP") + end) + end + end +end) + +function GetNearestmecanic(player) + local x, y, z = GetPlayerLocation(player) + + for k,v in pairs(GetAllNPC()) do + local x2, y2, z2 = GetNPCLocation(v) + local dist = GetDistance3D(x, y, z, x2, y2, z2) + + if dist < 250.0 then + for k,i in pairs(mecanicNpc) do + if v == i.npc then + return k + end + end + end + end + + return 0 +end diff --git a/package.json b/package.json index 5e380275..5e1154c2 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "fuel/server.lua", "spawn/server.lua", "delivery/server.lua", + "mecanic/server.lua", "scoreboard/server.lua", "whitelist/server.lua", "animation/server.lua", @@ -61,6 +62,7 @@ "gps/client.lua", "spawn/client.lua", "delivery/client.lua", + "mecanic/client.lua", "scoreboard/client.lua", "notification/client.lua", "animation/client.lua",