Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Using spreadsheet to remotely change a password?

Using spreadsheet to remotely change a password? 2 years 2 months ago #1024

  • jimmyt3d
  • jimmyt3d's Avatar
  • Offline
  • Senior Member
  • Posts: 44
  • Thank you received: 1
  • Karma: 1
Hi Frank,

Currently I have a basic password system on my game in the form of the following script -
#pragma strict

var password : String = "";
function OnGUI () {

password = GUI.PasswordField (Rect (Screen.width/2, Screen.height / 1.95, 256, 32), password, "*" [0], 25);

if (password == "password123") 
{

Application.LoadLevel("Level_1");

}

}

However what would be really good, would be if I could remotely change the password from the Google spreadsheet, so that the script looks to the plugin/spreadsheet rather than a baked in password like it is at the moment.

Would it be possible to modify this script to achieve this?

Many thanks
The administrator has disabled public write access.

Using spreadsheet to remotely change a password? 2 years 2 months ago #1025

  • Frank
  • Frank's Avatar
  • Offline
  • Administrator
  • Posts: 915
  • Thank you received: 196
  • Karma: 58
Yes, you can store game data in your spreadsheet and it will be downloaded.

You can create a new term (or row in the spreadsheet) named "GamePassword" or anything that fits. And for every language, set the password as its translation.

Then, in the game, execute
password = I2.Loc.ScriptLocalization.Get("GamePassword", false);

Hope that helps,
Frank
Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out
The administrator has disabled public write access.

Using spreadsheet to remotely change a password? 2 years 2 months ago #1028

  • jimmyt3d
  • jimmyt3d's Avatar
  • Offline
  • Senior Member
  • Posts: 44
  • Thank you received: 1
  • Karma: 1
Hi Frank,
Thanks for your help, I am almost there, I have written the following script and attached it to the password input field.
public class PasswordInput2 : MonoBehaviour {

	public void PassWordCheck(string incomingPassword)
	{
		incomingPassword = I2.Loc.ScriptLocalization.Get("GamePassword", false);
		{

		if (incomingPassword == "GamePassword")
		{
			Application.LoadLevel("Level_1");
	}
}
}
}

Without your line, the password box accepts whatever I put in the (incomingPassword == "???") field as the password and correctly loads the level.
If I add your line in, I get the error - "The name 'password' does not exist in the current context", so I changed 'password' to 'incomingPassword' and the error disappears and the game loads, however nothing happens when I put the password in.
I assume I am missing something to connect the password in the plugin to the 'incomingPassword' field?

Many thanks
The administrator has disabled public write access.

Using spreadsheet to remotely change a password? 2 years 2 months ago #1029

  • Frank
  • Frank's Avatar
  • Offline
  • Administrator
  • Posts: 915
  • Thank you received: 196
  • Karma: 58
Hi,
I think you should compare the incoming password with the one you get from I2.
public class PasswordInput2 : MonoBehaviour {

	public void PassWordCheck(string incomingPassword)
	{
		var RealPassword = I2.Loc.ScriptLocalization.Get("GamePassword", false);
		

		if (incomingPassword == RealPassword)
		{
			Application.LoadLevel("Level_1");
  	  	}
  	}
}

Hope that helps,
Frank
Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out
The administrator has disabled public write access.
The following user(s) said Thank You: jimmyt3d

Using spreadsheet to remotely change a password? 2 years 2 months ago #1031

  • jimmyt3d
  • jimmyt3d's Avatar
  • Offline
  • Senior Member
  • Posts: 44
  • Thank you received: 1
  • Karma: 1
Hi Frank,

That works perfectly, thanks for your help! :)
The administrator has disabled public write access.

Using spreadsheet to remotely change a password? 5 days 4 hours ago #2628

  • jimmyt3d
  • jimmyt3d's Avatar
  • Offline
  • Senior Member
  • Posts: 44
  • Thank you received: 1
  • Karma: 1
Hi Frank,

I have just updated Unity to 5.6.4 (was previously on 5.3.5) and I2Loc to v2.8.1f1 (was previously on v2.7.0f1) and am now getting the following error for this script -

Assets/Scripts/PasswordInput2.cs(11,29): error CS0234: The type or namespace name `ScriptLocalization' does not exist in the namespace `I2.Loc'. Are you missing an assembly reference?

Has something changed in the latest version to cause this?

My full script which has always worked prior to this update, is as follows -
using UnityEngine;
using System.Collections;

public class PasswordInput2 : MonoBehaviour {

		public GameObject myObject;
	public GameObject myObject2;

	public void PassWordCheck(string incomingPassword)
	{
		var RealPassword = I2.Loc.ScriptLocalization.Get("Maps_Password", false);


		if (incomingPassword == RealPassword)
		{
			myObject.SetActive(false);
			myObject2.SetActive(true);
								}
		else
		{
			myObject.SetActive(true);
			myObject2.SetActive(false);
	}
}
}





Many thanks
Last Edit: 5 days 4 hours ago by jimmyt3d.
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Time to create page: 0.179 seconds
Colors