Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. local killCoordinator = {}
  2. local allowedClasses = {"CLeggedCharacterEntity"}
  3. local amount = 10
  4.  
  5. -- entity : CLeggedCharacterEntity
  6.  
  7. local handleEntity = function(entity)
  8. RunHandled(
  9. function()
  10. while not IsDeleted(entity) do
  11. Wait(CustomEvent("OnStep"))
  12. end
  13. end,
  14.  
  15. -- kev : CDiedScriptEvent
  16. On(Event(entity.Died)),
  17. function(kev)
  18. local player = kev:GetKillerPlayer()
  19.  
  20. if player ~= nil then
  21. if killCoordinator[player] == nil then
  22. killCoordinator[player] = 0
  23. end
  24.  
  25. killCoordinator[player] = killCoordinator[player] + 1
  26. if killCoordinator[player] >= amount then
  27. SignalEvent("AmountReached", player)
  28. end
  29. end
  30. end
  31. )
  32. end
  33.  
  34. RunHandled(
  35. function()
  36. WaitForever()
  37. end,
  38.  
  39. -- ev : CEntitySpawnedScriptEvent
  40. -- entity : CBaseEntity
  41. OnEvery(CustomEvent("EntitySpawned")),
  42. function(ev)
  43. local entity = ev:GetSpawnedEntity()
  44. local class = entity:GetClassName()
  45.  
  46. local hasFound = false
  47. for i = 1, #allowedClasses, 1 do
  48. if allowedClasses[i] == class then
  49. hasFound = true
  50. break
  51. end
  52. end
  53.  
  54. if hasFound then
  55. RunAsync(
  56. function()
  57. handleEntity(entity)
  58. end
  59. )
  60. end
  61. end
  62. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement