Advertisement
Nidhoggx

gouv

Apr 24th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.07 KB | None | 0 0
  1. local gouv = {x=-429.525,y=1109.5,z=327.682}
  2. local office = {x=3069.9,y=-4632.4,z=16.2}
  3. local sortie = {x=-80.489,y=-832.529,z=243.386}
  4.  
  5. local accountMoney = {x=-81.883,y=-808.073,z=243.39}
  6.  
  7. local playerJob = ""
  8. local playerGrade = ""
  9.  
  10. RegisterNetEvent('esx:playerLoaded')
  11. AddEventHandler('esx:playerLoaded', function(xPlayer)
  12. playerJob = xPlayer.job.name
  13. playerGrade = xPlayer.job.grade
  14. end)
  15.  
  16.  
  17. Citizen.CreateThread(function()
  18.  
  19. company = AddBlipForCoord(gouv.x, gouv.y, gouv.z)
  20. SetBlipSprite(company, 419)
  21. SetBlipAsShortRange(company, true)
  22. BeginTextCommandSetBlipName("STRING")
  23. AddTextComponentString("Gouvernement")
  24. EndTextCommandSetBlipName(company)
  25.  
  26. while playerJob == "" do
  27. Citizen.Wait(10)
  28. end
  29.  
  30. TriggerServerEvent("gouv:addPlayer", playerJob)
  31.  
  32. while true do
  33. Citizen.Wait(0)
  34.  
  35.  
  36. DrawMarker(1,gouv.x,gouv.y,gouv.z-1,0,0,0,0,0,0,2.001,2.0001,0.5001,0,155,255,200,0,0,0,0)
  37. DrawMarker(1,sortie.x,sortie.y,sortie.z-1,0,0,0,0,0,0,2.001,2.0001,0.5001,0,155,255,200,0,0,0,0)
  38.  
  39. if(isNear(gouv)) then
  40. if(playerJob == "gouv") then
  41. Info("Appuyez sur ~g~E~w~ pour entrer")
  42.  
  43. if(IsControlJustPressed(1, 38)) then
  44. SetEntityCoords(GetPlayerPed(-1),-75.8466, -826.9893, 243.3859)
  45. end
  46. else
  47. Info("Appuyez sur ~g~E~w~ pour sonner")
  48.  
  49. if(IsControlJustPressed(1, 38)) then
  50. TriggerServerEvent("gouv:sendSonnette")
  51. end
  52. end
  53. end
  54.  
  55. if(isNear(sortie)) then
  56. Info("Appuyez sur ~g~E~w~ pour sortir.")
  57.  
  58. if(IsControlJustPressed(1, 38)) then
  59. SetEntityCoords(GetPlayerPed(-1),gouv.x,gouv.y,gouv.z+1)
  60. end
  61. end
  62.  
  63. if(playerGrade == "boss" and playerJob == "gouv") then
  64. DrawMarker(1,accountMoney.x,accountMoney.y,accountMoney.z-1,0,0,0,0,0,0,2.001,2.0001,0.5001,0,155,255,200,0,0,0,0)
  65.  
  66. if(isNear(accountMoney)) then
  67. Info("Appuyez sur ~g~E~w~ pour ouvrir le coffre.")
  68.  
  69. if(IsControlJustPressed(1, 38)) then
  70. renderMenu("gouv", "Gouvernement")
  71. end
  72. end
  73. end
  74. end
  75.  
  76. end)
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86. function renderMenu(name, menuName)
  87. local _name = name
  88. local elements = {}
  89.  
  90.  
  91. table.insert(elements, {label = 'retirer argent', value = 'withdraw_society_money'})
  92. table.insert(elements, {label = 'déposer argent', value = 'deposit_money'})
  93.  
  94. ESX.UI.Menu.CloseAll()
  95.  
  96. ESX.UI.Menu.Open(
  97. 'default', GetCurrentResourceName(), 'realestateagent',
  98. {
  99. title = menuName,
  100. elements = elements
  101. },
  102. function(data, menu)
  103.  
  104. if data.current.value == 'withdraw_society_money' then
  105.  
  106. ESX.UI.Menu.Open(
  107. 'dialog', GetCurrentResourceName(), 'withdraw_society_money_amount',
  108. {
  109. title = 'montant du retrait'
  110. },
  111. function(data, menu)
  112.  
  113. local amount = tonumber(data.value)
  114.  
  115. if amount == nil then
  116. ESX.ShowNotification('montant invalide')
  117. else
  118. menu.close()
  119. print(_name)
  120. TriggerServerEvent('esx_society:withdrawMoney', _name, amount)
  121. end
  122.  
  123. end,
  124. function(data, menu)
  125. menu.close()
  126. end
  127. )
  128.  
  129. end
  130.  
  131. if data.current.value == 'deposit_money' then
  132.  
  133. ESX.UI.Menu.Open(
  134. 'dialog', GetCurrentResourceName(), 'deposit_money_amount',
  135. {
  136. title = 'montant du dépôt'
  137. },
  138. function(data, menu)
  139.  
  140. local amount = tonumber(data.value)
  141.  
  142. if amount == nil then
  143. ESX.ShowNotification('montant invalide')
  144. else
  145. menu.close()
  146. TriggerServerEvent('esx_society:depositMoney', _name, amount)
  147. end
  148.  
  149. end,
  150. function(data, menu)
  151. menu.close()
  152. end
  153. )
  154.  
  155. end
  156.  
  157. end,
  158. function(data, menu)
  159.  
  160. menu.close()
  161. end
  162. )
  163. end
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178. function isNear(tabl)
  179. local distance = GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)),tabl.x,tabl.y,tabl.z, true)
  180.  
  181. if(distance<3) then
  182. return true
  183. end
  184.  
  185. return false
  186. end
  187.  
  188.  
  189. function Info(text, loop)
  190. SetTextComponentFormat("STRING")
  191. AddTextComponentString(text)
  192. DisplayHelpTextFromStringLabel(0, loop, 1, 0)
  193. end
  194.  
  195. local stopRequest = false
  196. RegisterNetEvent("gouv:sendRequest")
  197. AddEventHandler("gouv:sendRequest", function(name,id)
  198. stopRequest = true
  199. SendNotification("~b~"..name.." ~w~a sonné à la porte du gouvernement.")
  200. SendNotification("~b~F~w~ pour ~g~accepter~w~ / ~b~G~w~ pour ~r~refuser~w~.")
  201.  
  202. stopRequest = false
  203. while not stopRequest do
  204. Citizen.Wait(0)
  205.  
  206. if(IsControlJustPressed(1, 23)) then
  207. TriggerServerEvent("gouv:sendStatusToPoeple", id, 1)
  208. stopRequest = true
  209. end
  210.  
  211. if(IsControlJustPressed(1, 47)) then
  212. TriggerServerEvent("gouv:sendStatusToPoeple", id,0)
  213. stopRequest = true
  214. end
  215. end
  216. end)
  217.  
  218.  
  219. RegisterNetEvent("gouv:sendStatus")
  220. AddEventHandler("gouv:sendStatus", function(status)
  221. if(status == 1) then
  222. SendNotification("~g~Quelqu'un est venu vous ouvrir la porte.")
  223. SetEntityCoords(GetPlayerPed(-1),-75.8466, -826.9893, 243.3859)
  224. else
  225. SendNotification("~r~Personne n'a voulu vous ouvrir la porte...")
  226. end
  227. end)
  228.  
  229.  
  230. function SendNotification(message)
  231. SetNotificationTextEntry("STRING")
  232. AddTextComponentString(message)
  233. DrawNotification(false, false)
  234. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement