Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Add Mecanic Job + show water bottle animation + change backpack model #82

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -250,6 +254,16 @@
"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",

bikouz marked this conversation as resolved.
Show resolved Hide resolved

"city": "Centre-Ville",
"unprocessed_rock": "Pierre non transformée",
"processed_rock": "Pierre transformée",
Expand Down
12 changes: 9 additions & 3 deletions inventory/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
110 changes: 110 additions & 0 deletions mecanic/client.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
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)

bikouz marked this conversation as resolved.
Show resolved Hide resolved

AddEvent("OnDialogSubmit", function(dialog, button, ...)
if dialog == mecanicNpcMenu then
bikouz marked this conversation as resolved.
Show resolved Hide resolved
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")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Mayne rename the event to changeVehicleColor and send the color as an argument to this function?

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
Loading