Advertisement
Guest User

Untitled

a guest
Mar 28th, 2022
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.86 KB | None | 0 0
  1. local currentTattoos = {}
  2. local cam = nil
  3. local back = 1
  4. local opacity = 1
  5. local scaleType = nil
  6. local scaleString = ""
  7.  
  8. ESX = nil
  9. Citizen.CreateThread(function()
  10. while ESX == nil do
  11. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  12. Citizen.Wait(0)
  13. end
  14. end)
  15.  
  16. Citizen.CreateThread(function()
  17. AddTextEntry("ParaTattoos", "Negozio di Tatuaggi")
  18. for k, v in pairs(Config.Shops) do
  19. local blip = AddBlipForCoord(v)
  20. SetBlipSprite(blip, 75)
  21. SetBlipColour(blip, 1)
  22. SetBlipScale(blip, 0.8)
  23. SetBlipAsShortRange(blip, true)
  24. BeginTextCommandSetBlipName("ParaTattoos")
  25. EndTextCommandSetBlipName(blip)
  26. end
  27. end)
  28.  
  29. AddEventHandler('skinchanger:modelLoaded', function()
  30. ESX.TriggerServerCallback('SmallTattoos:GetPlayerTattoos', function(tattooList)
  31. if tattooList then
  32. ClearPedDecorations(PlayerPedId())
  33. for k, v in pairs(tattooList) do
  34. if v.Count ~= nil then
  35. for i = 1, v.Count do
  36. SetPedDecoration(PlayerPedId(), v.collection, v.nameHash)
  37. end
  38. else
  39. SetPedDecoration(PlayerPedId(), v.collection, v.nameHash)
  40. end
  41. end
  42. currentTattoos = tattooList
  43. end
  44. end)
  45. end)
  46.  
  47. Citizen.CreateThread(function()
  48. while true do
  49. Citizen.Wait(300000)
  50. if not IsMenuOpen() then
  51. ESX.TriggerServerCallback('SmallTattoos:GetPlayerTattoos', function(tattooList)
  52. if tattooList then
  53. ClearPedDecorations(PlayerPedId())
  54. for k, v in pairs(tattooList) do
  55. if v.Count ~= nil then
  56. for i = 1, v.Count do
  57. SetPedDecoration(PlayerPedId(), v.collection, v.nameHash)
  58. end
  59. else
  60. SetPedDecoration(PlayerPedId(), v.collection, v.nameHash)
  61. end
  62. end
  63. currentTattoos = tattooList
  64. end
  65. end)
  66. end
  67. end
  68. end)
  69.  
  70. function DrawTattoo(collection, name)
  71. ClearPedDecorations(PlayerPedId())
  72. for k, v in pairs(currentTattoos) do
  73. if v.Count ~= nil then
  74. for i = 1, v.Count do
  75. SetPedDecoration(PlayerPedId(), v.collection, v.nameHash)
  76. end
  77. else
  78. SetPedDecoration(PlayerPedId(), v.collection, v.nameHash)
  79. end
  80. end
  81. for i = 1, opacity do
  82. SetPedDecoration(PlayerPedId(), collection, name)
  83. end
  84. end
  85.  
  86. function GetNaked()
  87. TriggerEvent('skinchanger:getSkin', function()
  88. if GetEntityModel(PlayerPedId()) == `mp_m_freemode_01` then
  89. TriggerEvent('skinchanger:loadSkin', {
  90. sex = 0,
  91. tshirt_1 = 15,
  92. tshirt_2 = 0,
  93. arms = 15,
  94. torso_1 = 91,
  95. torso_2 = 0,
  96. pants_1 = 14,
  97. pants_2 = 0,
  98. shoes_1 = 5,
  99. glasses_1 = 0
  100. })
  101. else
  102. TriggerEvent('skinchanger:loadSkin', {
  103. sex = 1,
  104. tshirt_1 = 34,
  105. tshirt_2 = 0,
  106. arms = 15,
  107. torso_1 = 101,
  108. torso_2 = 1,
  109. pants_1 = 16,
  110. pants_2 = 0,
  111. shoes_1 = 5,
  112. glasses_1 = 5
  113. })
  114. end
  115. end)
  116. end
  117.  
  118. function ResetSkin()
  119. ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin)
  120. TriggerEvent('skinchanger:loadSkin', skin)
  121. end)
  122. ClearPedDecorations(PlayerPedId())
  123. for k, v in pairs(currentTattoos) do
  124. if v.Count ~= nil then
  125. for i = 1, v.Count do
  126. SetPedDecoration(PlayerPedId(), v.collection, v.nameHash)
  127. end
  128. else
  129. SetPedDecoration(PlayerPedId(), v.collection, v.nameHash)
  130. end
  131. end
  132. end
  133.  
  134. function ReqTexts(text, slot)
  135. RequestAdditionalText(text, slot)
  136. while not HasAdditionalTextLoaded(slot) do
  137. Citizen.Wait(0)
  138. end
  139. end
  140.  
  141. function OpenTattooShop()
  142. JayMenu.OpenMenu("tattoo")
  143. FreezeEntityPosition(PlayerPedId(), true)
  144. GetNaked()
  145. ReqTexts("TAT_MNU", 9)
  146. end
  147.  
  148. function CloseTattooShop()
  149. ClearAdditionalText(9, 1)
  150. FreezeEntityPosition(PlayerPedId(), false)
  151. EnableAllControlActions(0)
  152. back = 1
  153. opacity = 1
  154. --ResetSkin()
  155. return true
  156. end
  157.  
  158. function ButtonPress()
  159. PlaySoundFrontend(-1, "SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET", true)
  160. end
  161.  
  162. function IsMenuOpen()
  163. return (JayMenu.IsMenuOpened('tattoo') or string.find(tostring(JayMenu.CurrentMenu() or ""), "ZONE_"))
  164. end
  165.  
  166. function BuyTattoo(collection, name, label, price)
  167. ESX.TriggerServerCallback('SmallTattoos:PurchaseTattoo', function(success)
  168. if success then
  169. table.insert(currentTattoos, {collection = collection, nameHash = name, Count = opacity})
  170. end
  171. end, currentTattoos, price, {collection = collection, nameHash = name, Count = opacity}, GetLabelText(label))
  172. end
  173.  
  174. function RemoveTattoo(name, label)
  175. for k, v in pairs(currentTattoos) do
  176. if v.nameHash == name then
  177. table.remove(currentTattoos, k)
  178. end
  179. end
  180. TriggerServerEvent("SmallTattoos:RemoveTattoo", currentTattoos)
  181. ESX.ShowNotification("Hai rimosso " .. GetLabelText(label))
  182. end
  183.  
  184. function CreateScale(sType)
  185. if scaleString ~= sType and sType == "OpenShop" then
  186. scaleType = setupScaleform("instructional_buttons", "Negozio di Tatuaggi", 38)
  187. scaleString = sType
  188. elseif scaleString ~= sType and sType == "Control" then
  189. scaleType = setupScaleform2("instructional_buttons", "Cambia Visuale", 21, "Cambia Opacità", {90, 89}, "Compra / Rimuovi Tatuaggio", 191)
  190. scaleString = sType
  191. end
  192. end
  193.  
  194. Citizen.CreateThread(function()
  195. JayMenu.CreateMenu("tattoo", "Negozio di Tatuaggi", function()
  196. return CloseTattooShop()
  197. end)
  198. JayMenu.SetSubTitle('tattoo', "Categories")
  199.  
  200. for k, v in ipairs(Config.TattooCats) do
  201. JayMenu.CreateSubMenu(v[1], "tattoo", v[2])
  202. JayMenu.SetSubTitle(v[1], v[2])
  203. end
  204.  
  205. while true do
  206. Citizen.Wait(0)
  207. local CanSleep = true
  208. if not IsMenuOpen() then
  209. for _,interiorId in ipairs(Config.interiorIds) do
  210. if GetInteriorFromEntity(PlayerPedId()) == interiorId then
  211. CanSleep = false
  212. if not IsPedInAnyVehicle(PlayerPedId(), false) then
  213. CreateScale("OpenShop")
  214. DrawScaleformMovieFullscreen(scaleType, 255, 255, 255, 255, 0)
  215. if IsControlJustPressed(0, 38) then
  216. OpenTattooShop()
  217. end
  218. end
  219. end
  220. end
  221. end
  222.  
  223. if IsMenuOpen() then
  224. DisableAllControlActions(0)
  225. CanSleep = false
  226. end
  227.  
  228. if JayMenu.IsMenuOpened('tattoo') then
  229. CanSleep = false
  230. for k, v in ipairs(Config.TattooCats) do
  231. JayMenu.MenuButton(v[2], v[1])
  232. end
  233. ClearPedDecorations(PlayerPedId())
  234. for k,v in pairs(currentTattoos) do
  235. if v.Count ~= nil then
  236. for i = 1, v.Count do
  237. SetPedDecoration(PlayerPedId(), v.collection, v.nameHash)
  238. end
  239. else
  240. SetPedDecoration(PlayerPedId(), v.collection, v.nameHash)
  241. end
  242. end
  243. if DoesCamExist(cam) then
  244. DetachCam(cam)
  245. SetCamActive(cam, false)
  246. RenderScriptCams(false, false, 0, 1, 0)
  247. DestroyCam(cam, false)
  248. end
  249. JayMenu.Display()
  250. end
  251. for k, v in ipairs(Config.TattooCats) do
  252. if JayMenu.IsMenuOpened(v[1]) then
  253. CanSleep = false
  254. if not DoesCamExist(cam) then
  255. cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", 1)
  256. SetCamActive(cam, true)
  257. RenderScriptCams(true, false, 0, true, true)
  258. StopCamShaking(cam, true)
  259. end
  260. CreateScale("Control")
  261. DrawScaleformMovieFullscreen(scaleType, 255, 255, 255, 255, 0)
  262. if IsDisabledControlJustPressed(0, 21) then
  263. ButtonPress()
  264. if back == #v[3] then
  265. back = 1
  266. else
  267. back = back + 1
  268. end
  269. end
  270. if IsDisabledControlJustPressed(0, 90) then
  271. ButtonPress()
  272. if opacity == 10 then
  273. opacity = 10
  274. else
  275. opacity = opacity + 1
  276. end
  277. end
  278. if IsDisabledControlJustPressed(0, 89) then
  279. ButtonPress()
  280. if opacity == 1 then
  281. opacity = 1
  282. else
  283. opacity = opacity - 1
  284. end
  285. end
  286. if GetCamCoord(cam) ~= GetOffsetFromEntityInWorldCoords(PlayerPedId(), v[3][back]) then
  287. SetCamCoord(cam, GetOffsetFromEntityInWorldCoords(PlayerPedId(), v[3][back]))
  288. PointCamAtCoord(cam, GetOffsetFromEntityInWorldCoords(PlayerPedId(), v[4]))
  289. end
  290. for _, tattoo in pairs(Config.AllTattooList) do
  291. if tattoo.Zone == v[1] then
  292. if GetEntityModel(PlayerPedId()) == `mp_m_freemode_01` then
  293. if tattoo.HashNameMale ~= '' then
  294. local found = false
  295. for k, v in pairs(currentTattoos) do
  296. if v.nameHash == tattoo.HashNameMale then
  297. found = true
  298. break
  299. end
  300. end
  301. if found then
  302. local clicked, hovered = JayMenu.SpriteButton(GetLabelText(tattoo.Name), "commonmenu", "shop_tattoos_icon_a", "shop_tattoos_icon_b")
  303. if clicked then
  304. RemoveTattoo(tattoo.HashNameMale, tattoo.Name)
  305. end
  306. else
  307. local price = math.ceil(tattoo.Price / 20) == 0 and 100 or math.ceil(tattoo.Price / 20)
  308. local clicked, hovered = JayMenu.Button(GetLabelText(tattoo.Name), "~HUD_COLOUR_GREENDARK~$" .. price)
  309. if clicked then
  310. BuyTattoo(tattoo.Collection, tattoo.HashNameMale, tattoo.Name, price)
  311. elseif hovered then
  312. DrawTattoo(tattoo.Collection, tattoo.HashNameMale)
  313. end
  314. end
  315. end
  316. else
  317. if tattoo.HashNameFemale ~= '' then
  318. local found = false
  319. for k, v in pairs(currentTattoos) do
  320. if v.nameHash == tattoo.HashNameFemale then
  321. found = true
  322. break
  323. end
  324. end
  325. if found then
  326. local clicked, hovered = JayMenu.SpriteButton(GetLabelText(tattoo.Name), "commonmenu", "shop_tattoos_icon_a", "shop_tattoos_icon_b")
  327. if clicked then
  328. RemoveTattoo(tattoo.HashNameFemale, tattoo.Name)
  329. end
  330. else
  331. local price = math.ceil(tattoo.Price / 20) == 0 and 100 or math.ceil(tattoo.Price / 20)
  332. local clicked, hovered = JayMenu.Button(GetLabelText(tattoo.Name), "~HUD_COLOUR_GREENDARK~$" .. price)
  333. if clicked then
  334. BuyTattoo(tattoo.Collection, tattoo.HashNameFemale, tattoo.Name, price)
  335. elseif hovered then
  336. DrawTattoo(tattoo.Collection, tattoo.HashNameFemale)
  337. end
  338. end
  339. end
  340. end
  341. end
  342. end
  343. JayMenu.Display()
  344. end
  345. end
  346. if CanSleep then
  347. Citizen.Wait(3000)
  348. end
  349. end
  350. end)
  351.  
  352. function ButtonMessage(text)
  353. BeginTextCommandScaleformString("STRING")
  354. AddTextComponentScaleform(text)
  355. EndTextCommandScaleformString()
  356. end
  357.  
  358. function Button(ControlButton)
  359. PushScaleformMovieMethodParameterButtonName(ControlButton)
  360. end
  361.  
  362. function setupScaleform2(scaleform, message, button, message2, buttons, message3, button2)
  363. local scaleform = RequestScaleformMovie(scaleform)
  364. while not HasScaleformMovieLoaded(scaleform) do
  365. Citizen.Wait(0)
  366. end
  367. PushScaleformMovieFunction(scaleform, "CLEAR_ALL")
  368. PopScaleformMovieFunctionVoid()
  369.  
  370. PushScaleformMovieFunction(scaleform, "SET_CLEAR_SPACE")
  371. PushScaleformMovieFunctionParameterInt(200)
  372. PopScaleformMovieFunctionVoid()
  373.  
  374. PushScaleformMovieFunction(scaleform, "SET_DATA_SLOT")
  375. PushScaleformMovieFunctionParameterInt(0)
  376. Button(GetControlInstructionalButton(2, buttons[1], true))
  377. Button(GetControlInstructionalButton(2, buttons[2], true))
  378. ButtonMessage(message2)
  379. PopScaleformMovieFunctionVoid()
  380.  
  381. PushScaleformMovieFunction(scaleform, "SET_DATA_SLOT")
  382. PushScaleformMovieFunctionParameterInt(1)
  383. Button(GetControlInstructionalButton(2, button, true))
  384. ButtonMessage(message)
  385. PopScaleformMovieFunctionVoid()
  386.  
  387. PushScaleformMovieFunction(scaleform, "SET_DATA_SLOT")
  388. PushScaleformMovieFunctionParameterInt(2)
  389. Button(GetControlInstructionalButton(2, button2, true))
  390. ButtonMessage(message3)
  391. PopScaleformMovieFunctionVoid()
  392.  
  393. PushScaleformMovieFunction(scaleform, "DRAW_INSTRUCTIONAL_BUTTONS")
  394. PopScaleformMovieFunctionVoid()
  395.  
  396. PushScaleformMovieFunction(scaleform, "SET_BACKGROUND_COLOUR")
  397. PushScaleformMovieFunctionParameterInt(0)
  398. PushScaleformMovieFunctionParameterInt(0)
  399. PushScaleformMovieFunctionParameterInt(0)
  400. PushScaleformMovieFunctionParameterInt(80)
  401. PopScaleformMovieFunctionVoid()
  402.  
  403. return scaleform
  404. end
  405.  
  406. function setupScaleform(scaleform, message, button)
  407. local scaleform = RequestScaleformMovie(scaleform)
  408. while not HasScaleformMovieLoaded(scaleform) do
  409. Citizen.Wait(0)
  410. end
  411. PushScaleformMovieFunction(scaleform, "CLEAR_ALL")
  412. PopScaleformMovieFunctionVoid()
  413.  
  414. PushScaleformMovieFunction(scaleform, "SET_CLEAR_SPACE")
  415. PushScaleformMovieFunctionParameterInt(200)
  416. PopScaleformMovieFunctionVoid()
  417.  
  418. PushScaleformMovieFunction(scaleform, "SET_DATA_SLOT")
  419. PushScaleformMovieFunctionParameterInt(0)
  420. Button(GetControlInstructionalButton(2, button, true))
  421. ButtonMessage(message)
  422. PopScaleformMovieFunctionVoid()
  423.  
  424. PushScaleformMovieFunction(scaleform, "DRAW_INSTRUCTIONAL_BUTTONS")
  425. PopScaleformMovieFunctionVoid()
  426.  
  427. PushScaleformMovieFunction(scaleform, "SET_BACKGROUND_COLOUR")
  428. PushScaleformMovieFunctionParameterInt(0)
  429. PushScaleformMovieFunctionParameterInt(0)
  430. PushScaleformMovieFunctionParameterInt(0)
  431. PushScaleformMovieFunctionParameterInt(80)
  432. PopScaleformMovieFunctionVoid()
  433.  
  434. return scaleform
  435. end
  436.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement