SHARE
    TWEET
    supinus

    police

    Apr 3rd, 2025
    629
    0
    Never
    Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
    Lua 1.96 KB | Gaming | 0 0
    1. -- cops_vs_robbers.lua
    2. -- Place this file inside: assettocorsa/server/extension/lua/
    3. local cops = {}
    4. local robbers = {}
    5. local busted = {}
    6. -- Menu d'équipe
    7. function script.update(dt)
    8. for i = 0, ac.getCarCount() - 1 do
    9. local car = ac.getCar(i)
    10. if not cops[i] and not robbers[i] then
    11. ui.begin("Choisissez votre équipe", true, WindowFlags.AlwaysAutoResize)
    12. ui.text("Vous êtes : " .. car.name)
    13. if ui.button("🚓 Rejoindre les flics") then
    14. cops[i] = true
    15. ac.setCarNameTag(i, "🚓 Police")
    16. end
    17. if ui.button("💨 Rejoindre les fuyards") then
    18. robbers[i] = true
    19. ac.setCarNameTag(i, "💨 Fuyard")
    20. end
    21. ui.endWindow()
    22. end
    23. end
    24. -- Vérifier collisions
    25. for i = 0, ac.getCarCount() - 1 do
    26. if cops[i] then
    27. local copCar = ac.getCar(i)
    28. for j = 0, ac.getCarCount() - 1 do
    29. if robbers[j] and not busted[j] then
    30. local robberCar = ac.getCar(j)
    31. if copCar:wasInContactWith(j) then
    32. busted[j] = true
    33. ac.setCarNameTag(j, "❌ Busté")
    34. ac.sendChatMessage(string.format("💥 %s a été attrapé par %s!", robberCar.name, copCar.name))
    35. end
    36. end
    37. end
    38. end
    39. end
    40. -- Vérifier victoire
    41. local remaining = 0
    42. for i = 0, ac.getCarCount() - 1 do
    43. if robbers[i] and not busted[i] then
    44. remaining = remaining + 1
    45. end
    46. end
    47. if remaining == 0 and tableLength(robbers) > 0 then
    48. ac.sendChatMessage("🚨 Tous les fuyards ont été attrapés ! Victoire des flics !")
    49. ac.setSessionOver()
    50. end
    51. end
    52. function tableLength(t)
    53. local count = 0
    54. for _, _ in pairs(t) do count = count + 1 end
    55. return count
    56. end
    Tags: Police
    Advertisement
    Add Comment
    Please, Sign In to add comment
    Public Pastes
    We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
    Not a member of Pastebin yet?
    Sign Up, it unlocks many cool features!

    AltStyle によって変換されたページ (->オリジナル) /