fork(3) download
  1. local firstspawn = 0
  2. AddEventHandler('playerSpawned', function(spawn)
  3. if firstspawn == 0 then
  4. firstspawn = 1
  5. else
  6. TriggerServerEvent('player_state:setdefaultneeds')
  7. end
  8. end)
  9.  
  10. RegisterNetEvent('player_state:death')
  11. AddEventHandler('player_state:death', function()
  12. SetEntityHealth(GetPlayerPed(-1), 0)
  13. end)
  14.  
  15. -- FOOD
  16. RegisterNetEvent('player_state:set')
  17. AddEventHandler('player_state:set', function(state)
  18. SendNUIMessage({ state = json.encode({food = state.food, water = state.water, needs = state.needs})
  19. })
  20. end)
  21. -------------------------------------------------------------------------
  22. -------------------------------------------------------------------------
  23. -- EMOTES
  24. -------------------------------------------------------------------------
  25. -------------------------------------------------------------------------
  26. RegisterNetEvent('player_state:drink')
  27. AddEventHandler('player_state:drink', function()
  28. local bone = GetPedBoneIndex(GetPlayerPed(-1), 28422)
  29. local bottleProp = 0
  30. local bottleModel = "prop_ld_flow_bottle"
  31. function newBottleProp()
  32. local x,y,z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
  33. RequestModel(bottleModel)
  34. while not HasModelLoaded(bottleModel) do
  35. Citizen.Wait(100)
  36. end
  37. return CreateObject(bottleModel, 1.0, 1.0, 1.0, 1, 1, 0)
  38. end
  39. bottleProp = newBottleProp()
  40. TriggerEvent("player:looseItem", item, 1)
  41. AttachEntityToEntity(bottleProp, GetPlayerPed(-1), bone, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, 1, 0, 0, 2, 1)
  42. RequestModel("prop_ld_flow_bottle")
  43. ped = GetPlayerPed(-1)
  44. if ped then
  45. Citizen.CreateThread(function()
  46. RequestAnimDict('amb@world_human_drinking_fat@beer@male@idle_a')
  47. local pedid = PlayerPedId()
  48. TaskPlayAnim(pedid, 'amb@world_human_drinking_fat@beer@male@idle_a', 'idle_a', 8.0, -8, -1, 16, 0, 0, 0, 0)
  49. Citizen.Wait(300)
  50. TaskPlayAnim(pedid, 'amb@world_human_drinking_fat@beer@male@idle_a', 'idle_b', 8.0, -8, -1, 16, 0, 0, 0, 0)
  51. Citizen.Wait(300)
  52. TaskPlayAnim(pedid, 'amb@world_human_drinking_fat@beer@male@idle_a', 'idle_c', 8.0, -8, -1, 16, 0, 0, 0, 0)
  53. end)
  54. end
  55. Citizen.Wait(3000)
  56. ClearPedTasks(ped)
  57. DeleteEntity(bottleProp)
  58. end)
  59. --//////////////
  60. RegisterNetEvent('player_state:eat')
  61. AddEventHandler('player_state:eat', function()
  62. local bone = GetPedBoneIndex(GetPlayerPed(-1), 28422)
  63. local tacosProp = 0
  64. local tacosModel = "prop_food_bs_burger2"
  65. function newTacosProp()
  66. local x,y,z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
  67. RequestModel(tacosModel)
  68. while not HasModelLoaded(tacosModel) do
  69. Citizen.Wait(100)
  70. end
  71. return CreateObject(tacosModel, 1.0, 1.0, 1.0, 1, 1, 0)
  72. end
  73. tacosProp = newTacosProp()
  74. AttachEntityToEntity(tacosProp, GetPlayerPed(-1), bone, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, 1, 0, 0, 2, 1)
  75. RequestModel("prop_food_bs_burger2")
  76. ped = GetPlayerPed(-1)
  77. if ped then
  78. Citizen.CreateThread(function()
  79. RequestAnimDict('amb@code_human_wander_eating_donut@male@idle_a')
  80. local pedid = PlayerPedId()
  81. TaskPlayAnim(pedid, 'amb@code_human_wander_eating_donut@male@idle_a', 'idle_c', 8.0, -8, -1, 16, 0, 0, 0, 0)
  82. Citizen.Wait(5000)
  83. ClearPedTasks(ped)
  84. end)
  85. end
  86. Citizen.Wait(5000)
  87. DeleteEntity(tacosProp)
  88. end)
  89. -------------------------------------------------------------------------
  90. -------------------------------------------------------------------------
  91. -- EMOTES END
  92. -------------------------------------------------------------------------
  93. -------------------------------------------------------------------------
  94. RegisterNetEvent('player_state:pee')
  95. AddEventHandler('player_state:pee', function()
  96. ped = GetPlayerPed(-1)
  97. local hashSkin = GetHashKey("mp_m_freemode_01")
  98. if IsPedInAnyVehicle(GetPlayerPed(-1), true) == false then
  99. if ped then
  100. if(GetEntityModel(GetPlayerPed(-1)) ~= hashSkin) then
  101. Citizen.CreateThread(function()
  102. RequestAnimDict('missfbi3ig_0')
  103. local pedid = PlayerPedId()
  104. TaskPlayAnim(pedid, 'missfbi3ig_0', 'shit_loop_trev', 8.0, 8, -1, 0, 0, 0, 0, 0)
  105. ClearPedTasks(ped)
  106. end)
  107. else
  108. Citizen.CreateThread(function()
  109. RequestAnimDict('misscarsteal2peeing')
  110. local pedid = PlayerPedId()
  111. TaskPlayAnim(pedid, 'misscarsteal2peeing', 'peeing_intro', 8.0, -8, -1, 0, 0, 0, 0, 0)
  112. Citizen.Wait(GetAnimDuration('misscarsteal2peeing', 'peeing_intro'))
  113. TaskPlayAnim(pedid, 'misscarsteal2peeing', 'peeing_loop', 8.0, -8, -1, 0, 0, 0, 0, 0)
  114. Citizen.Wait(GetAnimDuration('misscarsteal2peeing', 'peeing_loop'))
  115. TaskPlayAnim(pedid, 'misscarsteal2peeing', 'peeing_outro', 8.0, -8, -1, 0, 0, 0, 0, 0)
  116. ClearPedTasks(ped)
  117. end)
  118. end
  119. end
  120. else
  121. --TriggerEvent("es_freeroam:notify", "CHAR_MP_STRIPCLUB_PR", 1, "Mairie", false, "ca serai pas mieux en dehors du vehicule?")
  122. end
  123. end)
  124.  
  125. Citizen.CreateThread(function()
  126. while true do
  127. Citizen.Wait(0)
  128. if IsPauseMenuActive() then
  129. SendNUIMessage({ pause = true })
  130. else
  131. SendNUIMessage({ pause = false })
  132. end
  133. end
  134. end)
  135. Citizen.CreateThread(function()
  136. while true do
  137. Citizen.Wait(120000)
  138. TriggerServerEvent('player_state:check')
  139. end
  140. end)
Runtime error #stdin #stdout #stderr 0s 14120KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
lua5.3: prog.lua:2: attempt to call a nil value (global 'AddEventHandler')
stack traceback:
	prog.lua:2: in main chunk
	[C]: in ?