Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.11 KB | None | 0 0
  1. local T_RandChrochetage = math.random(40000, 90000) --temps du crochetage
  2. local T_AlarmeAfterCrochetage = 60000 -- temps de l alarme apres crochetage
  3. local percentAlarmV2 = 100 --% d avoir une alarme V2
  4. local T_StartAlarmV2 = 15000 --Timer avant de start l alarme V2 apres crochetage
  5. local T_StopAlarmV2 = 15000 -- timer avant de libéré le joueurs du vehicul si pas de police
  6. local alarmRun = false
  7. local player = GetPlayerPed(-1)
  8.  
  9. Citizen.CreateThread(function()
  10. RequestAnimDict("mini@repair")
  11. while not HasAnimDictLoaded("mini@repair") do
  12. Wait(1)
  13. end
  14. end)
  15.  
  16. function SetOnAlarmVeh(veh)
  17. Citizen.CreateThread(function()
  18. while alarmRun do
  19. SetVehicleAlarm(veh, true)
  20. StartVehicleAlarm(veh)
  21. Wait(10000)
  22. Citizen.Trace("Fin boucle SetOnAlarmVeh")
  23. end
  24. end)
  25. end
  26.  
  27. function TimerAlarmRunning(veh)
  28. if alarmRun == false then
  29. alarmRun = true
  30. Citizen.Trace("AlarmRun is true")
  31. SetOnAlarmVeh(veh)
  32. else
  33. alarmRun = false
  34. Citizen.Trace("AlarmRun is false")
  35. end
  36. end
  37.  
  38. function CheckIfPlayerIsinVeh(veh, player)
  39. local driver = GetPedInVehicleSeat(veh, -1)
  40. if driver == player then
  41. Citizen.Trace("meme ped comme conducteur")
  42. end
  43. end
  44.  
  45. Citizen.CreateThread(function()
  46. while true do
  47. Wait(0)
  48. if DoesEntityExist(GetVehiclePedIsTryingToEnter(PlayerPedId())) then
  49. local veh = GetVehiclePedIsTryingToEnter(PlayerPedId())
  50. local lock = GetVehicleDoorLockStatus(veh)
  51. if lock == 7 then
  52. SetVehicleDoorsLocked(veh, 2)
  53. end
  54.  
  55. local pedd = GetPedInVehicleSeat(veh, -1)
  56.  
  57. if pedd then
  58. SetPedCanBeDraggedOut(pedd, false)
  59. end
  60. if lock == 2 then
  61. DisplayHelpText("Pressez ~INPUT_CONTEXT~ pour crocheter le véhicule")
  62. if IsControlJustPressed(0, 38) then
  63. Lockpick(veh)
  64. Wait(T_RandChrochetage)
  65. TimerAlarmRunning(veh)
  66. end
  67. end
  68.  
  69. end
  70. end
  71. end)
  72.  
  73.  
  74.  
  75. function Lockpick(veh)
  76. local bool = true
  77. local anim = true
  78. TimerAlarmRunning(veh)
  79. Citizen.CreateThread(function()
  80. local entcoords = GetEntityCoords(GetPlayerPed(-1), 0)
  81. drawNotification("~r~Vous crochetez le véhicule !!")
  82. Citizen.Wait(T_RandChrochetage)
  83. SetVehicleDoorsLocked(veh, 1)
  84. drawNotification("~g~Vous avez crocheter le véhicule !!")
  85. ClearPedTasksImmediately(GetPlayerPed(-1))
  86. StartAlarmV2(veh)
  87. anim = false
  88. Wait(T_AlarmeAfterCrochetage)
  89. bool = false
  90. end)
  91. Citizen.CreateThread(function()
  92. while anim do
  93. TaskPlayAnim(GetPlayerPed(-1),"mini@repair","fixing_a_player", 8.0, 0.0, 120000, 16, 0, 0, 0, 0)
  94. if not anim then
  95. ClearPedTasksImmediately(GetPlayerPed(-1))
  96. end
  97. Wait(10000)
  98. end
  99. end)
  100. end
  101.  
  102. function StartAlarmV2(veh)
  103. Citizen.CreateThread(function()
  104. local isV2Alarme = math.random(0, 100)
  105. if isV2Alarme < percentAlarmV2 then
  106. Wait(T_StartAlarmV2)
  107. CheckIfPlayerIsinVeh(veh, player)
  108. Citizen.Trace("debut V2")
  109. SetVehicleDoorsLocked(veh, 4)
  110. SetVehicleWheelsCanBreak(veh, false)
  111. SetVehicleUndriveable(veh, 1)
  112. drawNotification("~r~Systeme d'alarmeV2 de la voiture activé")
  113. stopalarm(T_StopAlarmV2, veh)
  114. end
  115. end)
  116. end
  117.  
  118.  
  119. function stopalarm(timer, veh)
  120. Citizen.CreateThread(function()
  121. Citizen.Trace("stop alarms 1/2")
  122. Citizen.Wait(timer)
  123. Citizen.Trace("stop alarms 2/2")
  124. SetVehicleDoorsLocked(veh, 1)
  125. drawNotification("~g~Systeme d'alarmeV2 de la voiture désactivé")
  126. end)
  127. end
  128.  
  129. function DisplayHelpText(str)
  130. SetTextComponentFormat("STRING")
  131. AddTextComponentString(str)
  132. DisplayHelpTextFromStringLabel(0, 0, 1, -1)
  133. end
  134. function drawNotification(text)
  135. SetNotificationTextEntry("STRING")
  136. AddTextComponentString(text)
  137. DrawNotification(false, false)
  138. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement