Advertisement
YourMain12

Basic Anticheat (RUBY)

Jan 7th, 2023
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.81 KB | None | 0 0
  1. # Set a flag to determine if the user is cheating
  2. is_cheating = false
  3.  
  4. # Define a function to check if the user is cheating
  5. def check_for_cheats(input)
  6.   # Set a list of cheats
  7.   cheats = ["cheat1", "cheat2", "cheat3"]
  8.  
  9.   # Iterate through the list of cheats
  10.   cheats.each do |cheat|
  11.     # If the input contains a cheat, set the flag to true and break out of the loop
  12.     if input.include?(cheat)
  13.       is_cheating = true
  14.       break
  15.     end
  16.   end
  17. end
  18.  
  19. # Prompt the user for input
  20. print "Enter a command: "
  21. user_input = gets.chomp
  22.  
  23. # Check if the user is cheating
  24. check_for_cheats(user_input)
  25.  
  26. # If the user is cheating, display a message and exit the program
  27. if is_cheating
  28.   puts "Cheating is not allowed!"
  29.   exit
  30. end
  31.  
  32. # If the user is not cheating, continue with the program
  33. puts "Valid input"
  34.  
Tags: Ruby
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement