Advertisement
YourMain12

Basic Anticheat (GO)

Jan 7th, 2023
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.04 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "bufio"
  5.     "fmt"
  6.     "os"
  7.     "strings"
  8. )
  9.  
  10. func main() {
  11.     // Set a flag to determine if the user is cheating
  12.     isCheating := false
  13.  
  14.     // Define a function to check if the user is cheating
  15.     checkForCheats := func(input string) {
  16.         // Set a list of cheats
  17.         cheats := []string{"cheat1", "cheat2", "cheat3"}
  18.  
  19.         // Iterate through the list of cheats
  20.         for _, cheat := range cheats {
  21.             // If the input contains a cheat, set the flag to true and break out of the loop
  22.             if strings.Contains(input, cheat) {
  23.                 isCheating = true
  24.                 break
  25.             }
  26.         }
  27.     }
  28.  
  29.     // Prompt the user for input
  30.     fmt.Print("Enter a command: ")
  31.     scanner := bufio.NewScanner(os.Stdin)
  32.     if scanner.Scan() {
  33.         userInput := scanner.Text()
  34.  
  35.         // Check if the user is cheating
  36.         checkForCheats(userInput)
  37.  
  38.         // If the user is cheating, display a message and exit the program
  39.         if isCheating {
  40.             fmt.Println("Cheating is not allowed!")
  41.             os.Exit(0)
  42.         }
  43.  
  44.         // If the user is not cheating, continue with the program
  45.         fmt.Println("Valid input")
  46.     }
  47. }
  48.  
Tags: go
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement