fork(5) download
  1. --DO-NOT-EDIT-BELLOW-THIS-LINE--
  2. -- Init ESX
  3. ESX = nil
  4.  
  5. Citizen.CreateThread(function()
  6. while ESX == nil do
  7. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  8. Citizen.Wait(0)
  9. end
  10. end)
  11. -- Fin init ESX
  12.  
  13.  
  14. ----------------------------------------------------------
  15. ---------------------load movie settings------------------
  16. ----------------------------------------------------------
  17. -- Configure the opening hours
  18. local openingHour = 0
  19. local closingHour = 22
  20. local currentcinema
  21. local movie_choosed
  22.  
  23. -- Configure the coordinates for all the cinemas
  24. local cinemaLocations = {
  25. { ['name'] = "Downtown", ['x'] = 300.788, ['y'] = 200.752, ['z'] = 104.385}
  26. }
  27. --adds blips for movie theater
  28. local blipsLoaded = false
  29. local MovieState = false
  30. function LoadBlips()
  31. for k,v in ipairs(cinemaLocations) do
  32. local blip = AddBlipForCoord(v.x, v.y, v.z)
  33. SetBlipSprite(blip, 135)
  34. SetBlipScale(blip, 1.0)
  35. SetBlipColour(blip, 25)
  36. SetBlipAsShortRange(blip, true)
  37. BeginTextCommandSetBlipName("STRING")
  38. AddTextComponentSubstringPlayerName("Cinémas")
  39. EndTextCommandSetBlipName(blip)
  40. --loads the theater interior
  41. RequestIpl("v_cinema")
  42. blipsLoaded = true
  43. end
  44. end
  45.  
  46. ------------------------------------------------------------
  47. ---------------------set up movie---------------------------
  48. ------------------------------------------------------------
  49. function SetupMovie()
  50. cinema = GetInteriorAtCoords(320.217, 263.81, 82.974)
  51. LoadInterior(cinema)
  52. --this gets the hash key of the cinema screen
  53. cin_screen = GetHashKey("v_ilev_cin_screen")
  54. if not DoesEntityExist(tv) then
  55. tv = CreateObjectNoOffset(cin_screen, 320.1257, 248.6608, 86.56934, 1, true, false)
  56. SetEntityHeading(tv, 179.99998474121)
  57. else
  58. tv = GetClosestObjectOfType(319.884, 262.103, 82.917, 20.475, cin_screen, 0, 0, 0)
  59. end
  60. --this checks if the rendertarget is registered and registers rendertarget
  61. if not IsNamedRendertargetRegistered("cinscreen") then
  62. RegisterNamedRendertarget("cinscreen", 0)
  63. end
  64. --this checks if the screen is linked to rendertarget and links screen to rendertarget
  65. if not IsNamedRendertargetLinked(cin_screen) then
  66. LinkNamedRendertarget(cin_screen)
  67. end
  68. rendertargetid = GetNamedRendertargetRenderId("cinscreen")
  69. --this checks if the rendertarget is linked AND registered
  70. if IsNamedRendertargetLinked(cin_screen) and IsNamedRendertargetRegistered("cinscreen") then
  71. --this sets the rendertargets channel and video
  72. Citizen.InvokeNative(0x9DD5A62390C3B735, 2, movie_choosed, 0)
  73. --this sets the rendertarget
  74. SetTextRenderId(rendertargetid)
  75. --duh sets the volume
  76. SetTvVolume(100)
  77. --duh sets the cannel
  78. SetTvChannel(2)
  79. --duh sets subtitles
  80. EnableMovieSubtitles(1)
  81. --these are for the rendertarget 2d settings and stuff
  82. Citizen.InvokeNative(0x67A346B3CDB15CA5, 100.0)
  83. Citizen.InvokeNative(0x61BB1D9B3A95D802, 4)
  84. Citizen.InvokeNative(0xC6372ECD45D73BCD, 1)
  85. else
  86. --this puts the rendertarget back to regular use(playing)
  87. SetTextRenderId(GetDefaultScriptRendertargetRenderId())
  88. end
  89. if MovieState == false then
  90. MovieState = true
  91. CreateMovieThread()
  92. end
  93. end
  94. function helpDisplay(text, state)
  95. SetTextComponentFormat("STRING")
  96. AddTextComponentString(text)
  97. DisplayHelpTextFromStringLabel(0, state, 0, -1)
  98. end
  99. --this FUNCTION deletes the movie screen sets the channel to basicly nothing
  100. function DeconstructMovie()
  101. local obj = GetClosestObjectOfType(319.884, 262.103, 82.917, 20.475, cin_screen, 0, 0, 0)
  102. cin_screen = GetHashKey("v_ilev_cin_screen")
  103. SetTvChannel(-1)
  104. ReleaseNamedRendertarget(GetHashKey("cinscreen"))
  105. SetTextRenderId(GetDefaultScriptRendertargetRenderId())
  106. SetEntityAsMissionEntity(obj,true,false)
  107. DeleteObject(obj)
  108. end
  109. --this FUNCTION is what draws the tv channel(needs to be in a loop)
  110. function StartMovie()
  111. DrawTvChannel(0.5, 0.5, 1.0, 1.0, 0.0, 255, 255, 255, 255)
  112. end
  113. --this starts the movie
  114. function CreateMovieThread()
  115. Citizen.CreateThread(function()
  116. SetTextRenderId(GetNamedRendertargetRenderId("cinscreen"))
  117. Citizen.InvokeNative(0x9DD5A62390C3B735, 2, movie_choosed, 0)
  118. SetTvChannel(2)
  119. EnableMovieSubtitles(1)
  120. Citizen.InvokeNative(0x67A346B3CDB15CA5, 100.0)
  121. Citizen.InvokeNative(0x61BB1D9B3A95D802, 4)
  122. Citizen.InvokeNative(0xC6372ECD45D73BCD, 1)
  123. while(true) do
  124. Citizen.Wait(0)
  125. StartMovie()
  126. end
  127. end)
  128. end
  129. --this is the enter theater stuff
  130. function IsPlayerInArea()
  131. playerPed = GetPlayerPed(-1)
  132. playerCoords = GetEntityCoords(playerPed, true)
  133. hour = GetClockHours()
  134. for k,v in ipairs(cinemaLocations) do
  135. -- Check if the player is near the cinema
  136. if GetDistanceBetweenCoords(playerCoords, v.x, v.y, v.z) < 4.8 then
  137. -- Check if the cinema is open or closed.
  138. if hour < openingHour or hour > closingHour then
  139. helpDisplay("Le cinema est ~r~fermé ~w~mercide revenir entre 1am et 22pm.", 0)
  140. else
  141. helpDisplay("Appuyez sur ~INPUT_CONTEXT~ pour entrer dans la salle de cinéma.", 0)
  142. -- Check if the player is near the cinema and pressed "INPUT_CONTEXT"
  143. if IsControlJustReleased(0, 38) then
  144. ESX.UI.Menu.Open(
  145. 'default', GetCurrentResourceName(), 'menu_cinema',
  146. {
  147. title = 'Programmation',
  148. align = 'top-left',
  149. elements = {
  150. {label = 'Cartoon - 50$', value = 'PL_CINEMA_CARTOON'},
  151. {label = 'Fame or Shame - 50$', value = 'PL_LES1_FAME_OR_SHAME'},
  152. {label = 'Action - 50$', value = 'PL_CINEMA_ACTION'},
  153. {label = 'ArtHouse - 50$', value = 'PL_CINEMA_ARTHOUSE'},
  154. {label = 'Meltown - 10$', value = 'PL_CINEMA_MULTIPLAYER'},
  155. {label = 'CNT - 10$', value = 'PL_STD_CNT'},
  156. --{label = 'Howitzer - 10$', value = 'PL_WEB_HOWITZER'},
  157. --{label = 'Rangers - 10$', value = 'PL_WEB_RANGERS'}
  158. }
  159. },
  160. function(data, menu)
  161. menu.close()
  162. movie_choosed = data.current.value
  163. ESX.TriggerServerCallback('esx_cinema:checkmoney',function(valid)
  164. if (valid) then
  165. DoScreenFadeOut(1000)
  166. SetupMovie()
  167. Citizen.Wait(500)
  168. SetEntityCoords(playerPed, 320.217, 263.81, 81.974, true, true, true, true)
  169. DoScreenFadeIn(800)
  170. Citizen.Wait(30)
  171. currentcinema = v.name
  172. TriggerEvent('EnteringInCinema')
  173. SetEntityHeading(playerPed, 180.475)
  174. TaskLookAtCoord(GetPlayerPed(-1), 319.259, 251.827, 85.648, -1, 2048, 3)
  175. FreezeEntityPosition(GetPlayerPed(-1), 1)
  176. SetNotificationTextEntry('STRING')
  177. AddTextComponentString("Appuyez sur la touche ~r~E ~w~pour sortir du cinéma.")
  178. DrawNotification(false, false)
  179. else
  180. TriggerEvent('esx:showNotification', "Vous n'avez pas assez d'argent !")
  181. end
  182. end)
  183.  
  184. end,
  185. function(data, menu)
  186. menu.close()
  187. end
  188. )
  189. end
  190. end
  191. end
  192. end
  193. end
  194. Citizen.CreateThread(function()
  195. while true do
  196. Citizen.Wait(0)
  197. IsPlayerInArea()
  198. end
  199. end)
  200. --if the player is not inside theater delete screen
  201. Citizen.CreateThread(function()
  202. if GetRoomKeyFromEntity(PlayerPedId()) ~= -1337806789 and DoesEntityExist(GetClosestObjectOfType(319.884, 262.103, 82.917, 20.475, cin_screen, 0, 0, 0)) then
  203. DeconstructMovie()
  204. end
  205. -- Create the blips for the cinema's
  206. LoadBlips()
  207. end)
  208. Citizen.CreateThread(function()
  209. while true do
  210. Citizen.Wait(0)
  211. playerPed = GetPlayerPed(-1)
  212. --if player hits "E" key while in theater they exit
  213. if IsControlPressed(0, 38) and GetRoomKeyFromEntity(PlayerPedId()) == -1337806789 then
  214. DoScreenFadeOut(1000)
  215. if currentcinema == "Downtown" then
  216. SetEntityCoords(playerPed, 297.891, 193.296, 104.344, 161.925)
  217. elseif currentcinema == "Morningwood" then
  218. SetEntityCoords(playerPed, -1421.356, -198.388, 47.28, 350.0)
  219. elseif currentcinema == "Vinewood" then
  220. SetEntityCoords(playerPed, 303.278, 142.258, 103.846, 350.0)
  221. end
  222. Citizen.Wait(30)
  223. DoScreenFadeIn(800)
  224. --
  225. TriggerEvent('GetOutCinema')
  226. --
  227. FreezeEntityPosition(GetPlayerPed(-1), 0)
  228. SetFollowPedCamViewMode(fistPerson)
  229. DeconstructMovie()
  230. SetPlayerInvincible(PlayerId(), false)
  231. --ClearRoomForEntity(playerPed)
  232. MovieState = false
  233. end
  234. if GetRoomKeyFromEntity(PlayerPedId()) == -1337806789 then
  235. --SetPlayerInvisibleLocally(PlayerId(), true)
  236. --SetEntityVisible(PlayerPedId(-1), false)
  237. SetPlayerInvincible(PlayerId(), true)
  238. SetCurrentPedWeapon(PlayerPedId(), GetHashKey("weapon_unarmed"), 1)
  239. SetFollowPedCamViewMode(4)
  240. else
  241. --SetEntityVisible(PlayerPedId(-1), true)
  242. SetPlayerInvincible(PlayerId(), false)
  243. end
  244. end
  245. end)
  246.  
Runtime error #stdin #stdout #stderr 0s 4396KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
lua5.3: prog.lua:5: attempt to index a nil value (global 'Citizen')
stack traceback:
	prog.lua:5: in main chunk
	[C]: in ?