can anyone see if this c# script is right for gorilla tag

using UnityEngine; using System.Collections; public class AdminBanGun : MonoBehaviour { public LineRenderer lineRenderer; public float maxDistance = 10f;
private bool isLineVisible = false; void Start() { if (lineRenderer == null) { Debug.LogError("LineRenderer is not assigned."); return; } lineRenderer.positionCount = 2; // Set the number of positions in the line lineRenderer.enabled = false; // Initially disable the line renderer } void Update() { UpdateLine(); // Update the line position HandleInput(); // Check for user input } private void HandleInput() { float gripValue = ControllerInputPoller.instance.right.Controller.index.grip; float triggerValue = ControllerInputPoller.instance.right.Controller.index.trigger; if (gripValue > 0.2f) { if (!isLineVisible) { isLineVisible = true; // Show the line if grip is pressed lineRenderer.enabled = true; } } else { if (isLineVisible) { isLineVisible = false; // Hide the line if grip is released lineRenderer.enabled = false; } } if (triggerValue > 0.2f && isLineVisible) { StartCoroutine(DelayBanUser(12345)); // Example user ID } } void UpdateLine() { if (isLineVisible) { lineRenderer.SetPosition(0, transform.position); // Set start position lineRenderer.SetPosition(1, transform.position + transform.forward * maxDistance); // Set end position } } private IEnumerator DelayBanUser(int userId) { PerformAction(userId); // Perform the ban action yield return new WaitForSeconds(6 * 60 * 60); // Wait for 6 hours } private void PerformAction(int userId) { Debug.Log("User banned: " + userId); // Log the ban action } }
8 Replies
ero
ero3d ago
you're modding a game, yes? did you get permission from the developer to do so? we cannot aid in potentially tos-breaking work
MelloDaMonke4221
MelloDaMonke4221OP3d ago
This is my own fan game that i made im makeing a dely ban gun for the mods of the game to use in ther meni
ero
ero3d ago
So what's the question?
MelloDaMonke4221
MelloDaMonke4221OP3d ago
i want to kniw if the script is right and if its wrong whats wrong with it
Joreyk ( IXLLEGACYIXL )
never public fields, make them as properties
jcotton42
jcotton423d ago
This is Unity, where public fields are the norm.
MelloDaMonke4221
MelloDaMonke4221OP2d ago
so is anything wrong wit it
Joreyk ( IXLLEGACYIXL )
public fields properties are in PascalCase but even unity didnt follow it because of javascript times
Want results from more Discord servers?
Add your server