Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

Leaderboard


Popular Content

Showing content with the highest reputation on 10/25/2016 in all areas

  1. 1 point
    Hey guys! I know i don't post a lot, but i hope you find this one handy! Note: this is for commercial use and more, but do not repost or sell this as your own script! Someone did that to the last script i posted.... Unity3d Java Script: #pragma strict var username = ""; var password = ""; var repassword = ""; var email = ""; var message = ""; var islogin = true; var isregister = false; var hdskin : GUISkin; var loguser = ""; var logpass = ""; var logmessage = ""; var level2load = ""; var isSuccess = false; var mainDomainName = ""; var generatednumber :int = 0; var numberinput:int = 0; var loginPHPScriptName = "unitylogin.php"; var registerPHPScriptName = "unityregister.php"; var HofBox = 25; function OnGUI(){ GUI.skin = hdskin; if(islogin == false && isregister == true){ GUI.Box(Rect((Screen.width)/2-250,20,500,480),""); GUI.Label(Rect((Screen.width)/2-100,30,200,50),"Please fill out the fields"); GUI.Label(Rect((Screen.width)/2-230, 130,200,50),"Username:"); username = GUI.TextField(Rect((Screen.width)/2-20,130,200,HofBox),username,45); GUI.Label(Rect((Screen.width)/2-230,190,200,50),"Password:"); password = GUI.PasswordField(Rect ((Screen.width)/2-20,190,200,HofBox),password,"*"[0],45); GUI.Label(Rect((Screen.width)/2-230,250,200,50),"Re-Enter pass:"); repassword = GUI.PasswordField(Rect((Screen.width)/2-20,250,200,HofBox),repassword,"*"[0],45); GUI.Label(Rect((Screen.width)/2-230,310,200,50),"Email:"); email = GUI.TextField(Rect ((Screen.width)/2-20,310,200,HofBox),email,45); GUI.Label(Rect((Screen.width)/2-230,360,150,50),"Please verify:"); GUI.Label(Rect((Screen.width)/2-80,360,100,HofBox),generatednumber.ToString()); numberinput = int.Parse(GUI.TextField(Rect((Screen.width)/2+80,360,100,HofBox),numberinput.ToString())); if(GUI.Button(Rect((Screen.width)/2-230,420,200,HofBox),"Register!")){ message = ""; if(username == "" || email == "" || password == "" || numberinput == 0){ message += "Please fill in the empty fields. \n"; }else{ if(password == repassword){ if(numberinput == generatednumber){ doRegister(); }else{ message += "The number you inputed is not the same number."; } }else{ message += "The passwords do not match. \n"; } } } if(GUI.Button(Rect((Screen.width)/2-20,420,200,HofBox),"Return to login")){ islogin = true; isregister = false; username = ""; //cleaning our variables password = ""; repassword = ""; email = ""; numberinput = 0; message = ""; loguser = ""; logpass = ""; logmessage = ""; } if(message != ""){ GUI.Label(Rect((Screen.width)/2-230,460,460,50), message); } }else if(islogin == true && isregister == false){ GUI.Box(Rect((Screen.width)/2-250,20,500,450),""); GUI.Label(Rect((Screen.width)/2-100,30,200,50),"Please login to play"); GUI.Label(Rect((Screen.width)/2-230, 130,200,50),"Username:"); loguser = GUI.TextField(Rect((Screen.width)/2-20,130,200,HofBox),loguser,45); GUI.Label(Rect((Screen.width)/2-230,230,200,50),"Password:"); logpass = GUI.PasswordField(Rect ((Screen.width)/2-20,230,200,HofBox),logpass,"*"[0],45); if(GUI.Button(Rect((Screen.width)/2-230,330,200,HofBox),"Login")){ if(loguser == "" || logpass == ""){ logmessage += "Please enter the necessary data! \n"; } else{ logmessage = ""; doLogin(); } } if(GUI.Button(Rect((Screen.width)/2-20,330,200,HofBox),"Register")){ islogin = false; isregister = true; generatednumber=Random.Range(1000,99999); username = ""; //cleaning our variables password = ""; repassword = ""; email = ""; numberinput = 0; message = ""; loguser = ""; logpass = ""; logmessage = ""; } if(logmessage != ""){ GUI.Label(Rect((Screen.width)/2-230,360,460,50),logmessage); } } } function doRegister(){ var form = new WWWForm(); form.AddField("user" , username); form.AddField("pass" , password); form.AddField("email" , email); var w = new WWW(mainDomainName + "/"+ registerPHPScriptName, form); yield w; if(w.error == null){ message += w.text; }else{ message += "Error : " + w.error + "\n"; } } function doLogin(){ var logform = new WWWForm(); logform.AddField("username" , loguser); logform.AddField("password" , logpass); var logw = new WWW(mainDomainName + "/"+ loginPHPScriptName, logform); yield logw; if(logw.error == null){ logmessage += logw.text; }else{ logmessage +="Error : " + logw.error + "\n"; } if(logmessage == "Login success! Please wait while the game loads..."){ isSuccess = true; } } function Update(){ if(isSuccess == true){ Application.LoadLevel(level2load); } } C# Converted Version, Credits to Connor Gibsoon! using UnityEngine; using System.Collections; public class Account : MonoBehaviour { public string username= ""; public string password= ""; public string repassword= ""; public string email= ""; public string message= ""; public bool islogin= true; public bool isregister= false; GUISkin hdskin; public static string loguser= ""; public string logpass= ""; public string logmessage= ""; public string level2load= ""; public bool isSuccess= false; public string mainDomainName= ""; int generatednumber = 0; int numberinput = 0; public string loginPHPScriptName= "unitylogin.php"; public string registerPHPScriptName= "unityregister.php"; public int HofBox= 25; void OnGUI (){ GUI.skin = hdskin; if(islogin == false && isregister == true){ GUI.Box( new Rect((Screen.width)/2-250,20,500,480),""); GUI.Label( new Rect((Screen.width)/2-100,30,200,50),"Please fill out the fields"); GUI.Label( new Rect((Screen.width)/2-230, 130,200,50),"Username:"); username = GUI.TextField( new Rect((Screen.width)/2-20,130,200,HofBox),username,45); GUI.Label( new Rect((Screen.width)/2-230,190,200,50),"Password:"); password = GUI.PasswordField( new Rect((Screen.width)/2-20,190,200,HofBox),password,"*"[0],45); GUI.Label( new Rect((Screen.width)/2-230,250,200,50),"Re-Enter pass:"); repassword = GUI.PasswordField( new Rect((Screen.width)/2-20,250,200,HofBox),repassword,"*"[0],45); GUI.Label( new Rect((Screen.width)/2-230,310,200,50),"Email:"); email = GUI.TextField( new Rect((Screen.width)/2-20,310,200,HofBox),email,45); GUI.Label( new Rect((Screen.width)/2-230,360,150,50),"Please verify:"); GUI.Label( new Rect((Screen.width)/2-80,360,100,HofBox),generatednumber.ToString()); numberinput = int.Parse(GUI.TextField( new Rect((Screen.width)/2+80,360,100,HofBox),numberinput.ToString())); if(GUI.Button( new Rect((Screen.width)/2-230,420,200,HofBox),"Register!")){ message = ""; if(username == "" || email == "" || password == "" || numberinput == 0){ message += "Please fill in the empty fields. \n"; }else{ if(password == repassword){ if(numberinput == generatednumber){ doRegister(); }else{ message += "The number you inputed is not the same number."; } }else{ message += "The passwords do not match. \n"; } } } if(GUI.Button( new Rect((Screen.width)/2-20,420,200,HofBox),"Return to login")){ islogin = true; isregister = false; username = ""; //cleaning our variables password = ""; repassword = ""; email = ""; numberinput = 0; message = ""; loguser = ""; logpass = ""; logmessage = ""; } if(message != ""){ GUI.Label( new Rect((Screen.width)/2-230,460,460,50), message); } }else if(islogin == true && isregister == false){ GUI.Box( new Rect((Screen.width)/2-250,20,500,450),""); GUI.Label( new Rect((Screen.width)/2-100,30,200,50),"Please login to play"); GUI.Label( new Rect((Screen.width)/2-230, 130,200,50),"Username:"); loguser = GUI.TextField( new Rect((Screen.width)/2-20,130,200,HofBox),loguser,45); GUI.Label( new Rect((Screen.width)/2-230,230,200,50),"Password:"); logpass = GUI.PasswordField( new Rect((Screen.width)/2-20,230,200,HofBox),logpass,"*"[0],45); if(GUI.Button( new Rect((Screen.width)/2-230,330,200,HofBox),"Login")){ if(loguser == "" || logpass == ""){ logmessage += "Please enter the necessary data! \n"; } else{ logmessage = ""; doLogin(); } } if(GUI.Button( new Rect((Screen.width)/2-20,330,200,HofBox),"Register")){ islogin = false; isregister = true; generatednumber=Random.Range(1000,99999); username = ""; //cleaning our variables password = ""; repassword = ""; email = ""; numberinput = 0; message = ""; loguser = ""; logpass = ""; logmessage = ""; } if(logmessage != ""){ GUI.Label( new Rect((Screen.width)/2-230,360,460,50),logmessage); } } } IEnumerator doRegister (){ WWWForm form= new WWWForm(); form.AddField("user" , username); form.AddField("pass" , password); form.AddField("email" , email); WWW w= new WWW(mainDomainName + "/"+ registerPHPScriptName, form); yield return w; if(w.error == null){ message += w.text; }else{ message += "Error : " + w.error + "\n"; } } IEnumerator doLogin (){ WWWForm logform= new WWWForm(); logform.AddField("username" , loguser); logform.AddField("password" , logpass); WWW logw= new WWW(mainDomainName + "/"+ loginPHPScriptName, logform); yield return logw; if(logw.error == null){ logmessage += logw.text; }else{ logmessage +="Error : " + logw.error + "\n"; } if(logmessage == "Login success! Please wait while the game loads..."){ isSuccess = true; } } void Update (){ if(isSuccess == true){ Application.LoadLevel(level2load); } } } Register Script PHP: <?PHP $host = "localhost"; //put your host here $user = "root"; //in general is root $password = ""; //use your password here $dbname = "unitytest"; //your database mysql_connect($host, $user, $password) or die("Cant connect into database");//connects to the mysql database with the credentials listed above. mysql_select_db($dbname)or die("Cant connect into database");//connects to the schema you listed above. $user = mysql_real_escape_string($_POST['user']);//gains the user data inputted. $pass = mysql_real_escape_string($_POST['pass']);//gains the password data inputted. $email = $_POST['email'];//gains the email data inputted. $check = mysql_query("SELECT * FROM accounts WHERE user = '".$user."'"); //checks if there is any username with the same username the player inputted. $usercheck = mysql_num_rows($check);//generates the rows with the same username. if($usercheck == 0){//if there are no rows with the same username, then proceed. $d = 'INSERT INTO accounts (user, pass, email) VALUES ("'.$user.'", "'.$pass.'","'.$email.'" )';//inserts the data you inputted into the mysql table. mysql_query($d) OR die (mysql_error());//executes the query or kills the script if there is an error. if($d)//if it works, then procceed. die("Success! Please login to play!");//kills the script because you are done with the registration. }else{//if there is a username that is the same one that you inputted, then it will spit an error at you. die("User already exists!");//kills the script because you cannot create that account. } ?> Login script PHP: <?PHP $host = "localhost"; //put your host here $user = "root"; //in general is root $password = ""; //use your password here $dbname = "unitytest"; //your database mysql_connect($host, $user, $password) or die("Cant connect into database");//connects to the mysql table with those credentials. mysql_select_db($dbname)or die("Cant connect into database");//and selects the database you wrote $dbname. or kills the php script if it cant connect. $username = mysql_real_escape_string($_POST['username']);//takes the username inputted from the wwwform. $password = mysql_real_escape_string($_POST['password']);//takes the password inputed from the wwwform. $data = mysql_query("SELECT * FROM accounts WHERE user ='".$username."' AND pass = '".$password."'");//selects all the information where the user and pass = the data you inputted. $usercheck = mysql_num_rows($data);//generates a value of rows with the username and password credentials you inputted. if($usercheck == 1){ // if there is 1 row of data, then you are successfully logged in. die("Login success! Please wait while the game loads...");//kills the rest of the script... its practically pointless if you are successful in logging in. }else{//if there is no row with the inputted username or password together, then it will not let you login. die("The username or password is invalid.");//kills the script because you inputted the wrong user/password. } ?> Mysql script: DROP TABLE IF EXISTS `accounts`; CREATE TABLE `accounts` ( `Id` int(10) unsigned NOT NULL AUTO_INCREMENT, `user` varchar(45) NOT NULL, `pass` varchar(45) NOT NULL, `email` varchar(45) NOT NULL DEFAULT 'none', `emailhash` varchar(45) NOT NULL, `emailconfirm` varchar(45) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=latin1; Instructions: First off, I would like to say thank you for buying this asset. Feed back is always welcome. This entitles you to use this for commercial and non-commercial use. [sTEPS TO USE THIS!] 1. Download or use a webserver / webhost. I use Wampserver, it can be downloaded 100% free. Website: 'http://www.wampserver.com/en/#download-wrapper' 2. Start wampserver. 3. On the little tray at the bottom of your computer, you should see a "[W]" in red. Click on it and press 'Start all services.' Note: If you have skype running, close it before running the services. 4. Download Mysql Query Browser and install it. Website: 'http://www.brothersoft.com/mysql-query-browser-for-windows-download-71868.html' 5. PORTFORWARD UDP AND TCP THE FOLLOWING PORTS: 3306 , 80 (This is because its php and mysql. so anyone anywhere can access) 6. Click on the Wampserver icon and place the 2 php scripts, "unityregister.php" and "unitylogin.php" into the 'www' directory. 7. Go to your unity3d game and add the 'mainlogin-register.js' to any gameobject that is active. 8. Go and create a new Schema in mysql and go to 'file' -> 'open new script' -> open the drop down menu 'Files of Type: ' and find "Any file ANSI assumed (*)" then find "login-register.txt" and execute it. 9. Navigate to 'unityregister.php' and edit : '$host , $user , $password , $dbname' so that it corrisponds with mysql. 10. Do the same thing except for do it for 'unitylogin.php' 11. Go to 'Whatsmyip.org' and remember that external IP of yours. 12. Edit ""Main Domain Name"" in your 'Mainlogin-register.js' so that it is your ip. EX: "MainDomainName: 127.0.0.1" 13. Edit ""Level2Load"" in your 'Mainlogin-register.js' to the level you want to load after the user successfully logs in. 14. Edit ""Login PHPScript Name"" in your 'Mainlogin-register.js' to the name and extension of your 'unitylogin.php' script. 15. Edit ""Register PHPScript Name"" in your 'Mainlogin-register.js' to the name and extension of your 'unityregister.php' script. 16. Edit ""HDskin"" to whatever GUISkin you want.... 17. Edit ""HofBox (Height of Box) to whatever. 25 is the amount of height pixels. 18. You should be completely finished! I hope you enjoy the script! WEBPLAYER DEMO: http://eyeofnerorpg.dx.am/Login-Register.html
  2. 1 point
  3. 1 point
×
×
  • Create New...