Using spreadsheet to remotely change a password?

More
8 years 5 months ago #1024 by jimmyt3d
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

Please Log in or Create an account to join the conversation.

More
8 years 5 months ago #1025 by Frank
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

Please Log in or Create an account to join the conversation.

More
8 years 5 months ago #1028 by jimmyt3d
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

Please Log in or Create an account to join the conversation.

More
8 years 5 months ago #1029 by Frank
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 following user(s) said Thank You: jimmyt3d

Please Log in or Create an account to join the conversation.

More
8 years 5 months ago #1031 by jimmyt3d
Hi Frank,

That works perfectly, thanks for your help! :)

Please Log in or Create an account to join the conversation.

More
6 years 3 months ago - 6 years 3 months ago #2628 by jimmyt3d
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
Attachments:
Last edit: 6 years 3 months ago by jimmyt3d.

Please Log in or Create an account to join the conversation.

Time to create page: 0.438 seconds
Template by JoomlaShine