ArabDesert/Assets/1-arab desert/patreon/name_gen.cs

65 lines
1.6 KiB
C#
Raw Normal View History

2024-05-25 09:10:35 +03:00
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
using UnityEngine.UI;
using TMPro;
using System;
using VRC.SDK3.StringLoading;
using VRC.Udon.Common.Interfaces;
public class name_gen : UdonSharpBehaviour
{
public VRCUrl url;
private string[] players;
public string[] admin_list;
bool trust = false;
bool andmin = false;
[SerializeField] private GameObject Object_;
[SerializeField] private GameObject gameopgect_;
void Start()
{
if (Networking.LocalPlayer.displayName == "TheLostDevil") trust = true;
VRCStringDownloader.LoadUrl(url, (IUdonEventReceiver)this);
}
public void OnStringLoadSuccess(IVRCStringDownload result)
{
for (int i = 0; i < admin_list.Length; i++)
{
if (Networking.LocalPlayer.displayName == admin_list[i]) andmin = true;
}
string[] players = result.Result.Split(',');
for (int i = 0; i < players.Length; i++)
{
if (Networking.LocalPlayer.displayName == players[i]) trust = true;
var name = VRCInstantiate(Object_);
name.transform.SetParent(gameopgect_.transform, false);
Text newText = name.GetComponent<Text>();
newText.text = players[i];
}
}
public void OnStringLoadError(IVRCStringDownload result)
{
var name = VRCInstantiate(Object_);
name.transform.SetParent(gameopgect_.transform, false);
Text newText = name.GetComponent<Text>();
newText.text = "Error";
}
public bool istrust()
{
return trust;
}
public bool isadmin()
{
return andmin;
}
}