Welcome to GEMENTAR TOUR PUO V2 Development Documentation. Enjoy your stay!

PasswordChange.cs

Full Script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using TMPro;
 
public class PasswordChange : MonoBehaviour
{
    public TMP_InputField current_password;
    public TMP_InputField new_password;
    public TMP_InputField new_password_confirm;
    public TextMeshProUGUI username;
 
    public PopUpSystem popUp;
 
    public void ButtonChangePassword()
    {
        if (new_password.text != new_password_confirm.text)
        {
            popUp.OpenPopUp("ERROR!", "new password didn't match");
            return;
        }
 
        if (new_password.text.Length <= 6)
        {
            popUp.OpenPopUp("ERROR!", "Field cannot be empty");
        }
 
        if (current_password.text == "" || new_password.text == "" || new_password_confirm.text == "")
        {
            popUp.OpenPopUp("ERROR!", "Field cannot be empty");
            return;
        }
 
        StartCoroutine(Upload());
    }
 
    IEnumerator Upload()
    {
        WWWForm form = new WWWForm();
        form.AddField("playerUsername", username.text);
        form.AddField("currentPassword", current_password.text);
        form.AddField("newPassword", new_password.text);
 
        using (UnityWebRequest www = UnityWebRequest.Post("hidden", form))
        {
            yield return www.SendWebRequest();
 
            if (www.result != UnityWebRequest.Result.Success)
            {
                Debug.Log(www.error);
            }
            else
            {
                if(www.downloadHandler.text.Equals("Password Changed."))
                {
                    popUp.OpenPopUp("ERROR!", "Password Changed.");
                }
 
                if (www.downloadHandler.text.Equals("Wrong Current Password Entered."))
                {
                    popUp.OpenPopUp("ERROR!", "Wrong Current Password Entered.");
 
                }
 
                if (www.downloadHandler.text.Equals("Error! Please if you find the message contact us at admin@gementar.com"))
                {
                    popUp.OpenPopUp("ERROR!", "Error! Please if you find the message contact us at admin@gementar.com");
                }
 
                Debug.Log(www.downloadHandler.text);
 
            }
        }
    }
}

public void ButtonChangePassword()

 
Client side password checker.

IEnumerator Upload()

 
Upload password into database and check error.

RankingSystem.cs

Full Script

using Sirenix.OdinInspector;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
 
public class RankingSystem : MonoBehaviour
{
    public GameObject RankParent;
    public GameObject rankFirst;
    public GameObject rankSecond;
    public GameObject rankThird;
    public GameObject rankNorm;
    public GameObject scoreUI;
 
    public hidden;
 
    bool toggleRankingList = true;
 
    public void ButtonOpenRankingList()
    {
        scoreUI.SetActive(true);
 
        if (toggleRankingList == false) return;
        toggleRankingList = false;
        var playerlist = hidden
 
        int i = 0;
        foreach (var item in playerlist)
        {
            GameObject newItem;
            if (i == 0)
            {
                newItem = Instantiate(rankFirst, this.transform);
                newItem.transform.SetParent(RankParent.transform);
            }
            else if (i == 1)
            {
                newItem = Instantiate(rankSecond, this.transform);
                newItem.transform.SetParent(RankParent.transform);
            }
            else if (i == 2)
            {
                newItem = Instantiate(rankThird, this.transform);
                newItem.transform.SetParent(RankParent.transform);
            }
            else
            {
                newItem = Instantiate(rankNorm, this.transform);
                newItem.transform.SetParent(RankParent.transform);
            }
 
 
            try
            {
            var split = item.Split(':');
 
            newItem.transform.Find("Text_Score").gameObject.GetComponent<TextMeshProUGUI>().SetText(split[1], 3.5f);
            newItem.transform.Find("Text_NickName").gameObject.GetComponent<TextMeshProUGUI>().SetText(split[0], 3.5f);
 
            if (i >= 3) newItem.transform.Find("Text_4").gameObject.GetComponent<TextMeshProUGUI>().SetText((i + 1).ToString(), 3.5f);
            }
            catch (System.Exception)
            {
                Destroy(newItem);
            }
 
            i++;
        }
 
    }
 
}

public void ButtonOpenRankingList()

 
When button clicked it with fetch all the player list String convert it example name:score:email and it will split it by ":"
iterate through all the users
instantiate object for ever iteration and assign it
due to the list already sort it self by player score in sQL query so we will not sort it here all done in server side..


QR Code
QR Code wiki:menu_scriptss_code (generated for current page)
Hello World!
DokuWiki with monobook... rules!