Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Dialog = ImportPackage("dialogui")
- local _ = function(k,...) return ImportPackage("i18n").t(GetPackageName(),k,...) end
- local guidePNJ
- local GuideIds = { }
- AddEvent("OnTranslationReady", function()
- guidePNJ = Dialog.create(_("uneed"), nil, _("choice"), _("cancel"))
- Dialog.addSelect(guidePNJ, 1, _("guide_menu"), 10)
- end)
- function OnKeyPress(key)
- if key == "E" then
- local NearestGuidePNJ = GetNearestGuidePNJ()
- if NearestGuidePNJ ~= 0 then
- CallRemoteEvent("guideInteract", NearestGuidePNJ)
- end
- end
- end
- AddEvent("OnKeyPress", OnKeyPress)
- AddEvent("OnDialogSubmit", function(dialog, button, ...)
- if dialog == guidePNJ then
- local args = { ... }
- if button == 1 then
- if args[1] == "" then
- else
- AddPlayerChat(args[1]))
- end
- end
- end)
- AddRemoteEvent("guideSetup", function(GuideObject)
- GuideIds = GuideObject
- end)
- function GetNearestGuidePNJ()
- 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 < 150.0 then
- for k,i in pairs(GuideIds) do
- if v == i then
- return v
- end
- end
- end
- end
- return 0
- end
- function tablefind(tab, el)
- for index, value in pairs(tab) do
- if value == el then
- return index
- end
- end
- end
- AddRemoteEvent("openGuidePNJ", function(menuGuide))
- local menuName = {}
- for k,v in pairs(menuGuide) do
- menuName[k] = _(k)
- end
- Dialog.setSelectLabeledOptions(guidePNJ, 1, 1, menuName)
- Dialog.show(guidePNJ)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement