RolePlay Learning System.

Status
Not open for further replies.
How about some constructive criticism then, you never know.. you might learn something..

PHP:
	                #region :learn  
                    case "learn": 
                        {
							//First of all, for the love of god, please don't use an int for a bool.
                            //int ifLearning;
							bool ifLearning; // Note - this should be stored as a variable in the usermanager, not here.
							
							// Why are you writing this to the database? Why not store it as a variable instead of making pointless queries to SQL?
                            //using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
                            //{
                            //    ifLearning = dbClient.getInt("SELECT learning FROM users WHERE name = '" + _Username + "'");
                            //}
                            
                            // From here on I'm now assuming that ifLearning is a User variable.. for simpletons I'll prefix a _ so you can understand
                            
                            //if (ifLearning == 0 && learningLooper == null)
                            if (!_ifLearning && learningLooper == null)
                            {
                            	// I have no idea why you've stored all your locations and rooms in the coding itself, but I guess if you don't intend on expanding on stuff then you can keep it.
                                if (_roomID == 201) 
                                {
                                    if ((roomUser.Y == 6 && roomUser.X == 4) || (roomUser.Y == 6 && roomUser.X == 6) || (roomUser.Y == 6 && roomUser.X == 8) || (roomUser.Y == 6 && roomUser.X == 10) || (roomUser.Y == 9 && roomUser.X == 4) || (roomUser.Y == 9 && roomUser.X == 6) || (roomUser.Y == 9 && roomUser.X == 8) || (roomUser.Y == 9 && roomUser.X == 10) || (roomUser.Y == 12 && roomUser.X == 4) || (roomUser.Y == 12 && roomUser.X == 6) || (roomUser.Y == 12 && roomUser.X == 8) || (roomUser.Y == 12 && roomUser.X == 10))
                                    {
                                        Room.sendSaying(roomUser, "*Starts to learn*");
                                        ThreadStart learnStarter = new ThreadStart(learn);
                                        learnLooper = new Thread(learnStarter);
                                        learnLooper.Priority = ThreadPriority.Lowest;
                                        learnLooper.Start();
                                        _ifLearning = true; // Another pointless SQL query removed.
                                        //using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
                                        //{
                                        //    dbClient.runQuery("UPDATE users SET learning = '1' WHERE name = '" + _Username + "'");
                                        //}
                                    }
                                }
                            }
                            break;
                        }
                    #endregion
Okay I'm not even going to get started on questioning the fact that you're starting an additional thread for every person that tries to learn, I'll just go with it..
PHP:
		private void learn()
        {
            int iCount = 0;
            try
            {
                while (true)
                {
                    //int learning; // Use _ifLearning
                    using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
                    {
                        //learning = dbClient.getInt("SELECT learning FROM users WHERE name = '" + _Username + "'");
                        //if (learning == 0)
                        if (!_learning)
                        {
                            sendData("BK" + "You must wait 1 minute before learning again.");
                            learnLooper = null;
                            learnLooper.Abort(); // Aborting a thread like this is never a good idea imo, Let threads exit on their own.. in this case instead of using while (true) above why not use while (_learning) that way as soon as we stop learning the thread will exit quietly?
                        }
                        // Ugly ass hardcoding, I recommend caching locations like this on bootup or being a little more creative with your room manager hinthint
                        if (_roomID == 177 && (roomUser.Y == 12 && roomUser.X == 5) || (roomUser.Y == 12 && roomUser.X == 7) || (roomUser.Y == 12 && roomUser.X == 9) || (roomUser.Y == 12 && roomUser.X == 11) || (roomUser.Y == 9 && roomUser.X == 5) || (roomUser.Y == 9 && roomUser.X == 9) || (roomUser.Y == 9 && roomUser.X == 7) || (roomUser.Y == 9 && roomUser.X == 5))
                        {
                        	// Replacing with _MyInt
                            //int myIntel;
                            // Replacing with _MyTime
                            //int myTime;
                            //refreshAppearance(false, false, true);
                            // Why is your intelligience not stored locally? You could save another SQL query by doing so..
                            //myIntel = dbClient.getInt("SELECT intel FROM users WHERE name = '" + _Username + "'");
                            //if (myIntel > 14)
                            if (_MyInt > 14)
                            {
                                sendData("BK" + "Sorry, your intelligence level cannot pass 15.");
                                learnLooper = null;
                                learnLooper.Abort();
                            }
                            int schoolTime = myIntel * 10;
                            // Again, replaced this with a local variable to save yet another SQL query
                            //myTime = dbClient.getInt("SELECT time_learn FROM users WHERE name = '" + _Username + "'");
                            //iCount = myTime;
                            iCount = _MyTime;
                            Room.sendWhisper(roomUser, _Username, "(Learning: " + iCount + "/" + schoolTime + " Minutes)");
                            iCount++;
                            // Finally, an SQL query that actually counts, bravo! If you wanted to be a resource nazi though you could put all your updates into one query and run them every minute instead.. just sayin'
                            dbClient.runQuery("UPDATE users SET time_learn = '" + iCount + "' WHERE name = '" + _Username + "'");
                            if (iCount > schoolTime)
                            {
                                Room.sendSaying(roomUser, "*feels smarter*");
                                // Have you actually tested the below line? Not sure but I would personally remove the quotations around 1, the 0 not so important, but why not
                                //dbClient.runQuery("UPDATE users SET time_learn = '0', intel = intel + '1' WHERE name = '" + _Username + "'");
                                dbClient.runQuery("UPDATE users SET time_learn = 0, intel = intel + 1 WHERE name = '" + _Username + "'");
                                iCount = 0;
                            }
                        }
                        else
                        {
                            //dbClient.runQuery("UPDATE users SET learning = '0' WHERE name = '" + _Username + "'");
                            _ifLearning = false;
                            dbClient.runQuery("UPDATE users SET learning = 0 WHERE name = '" + _Username + "'");
                            Room.sendSaying(roomUser, "*stops learning*");
                            learnLooper = null;
                            learnLooper.Abort();
                        }
                        Thread.Sleep(60000);
                    }
                }
            }
            catch
            {
            	// If you've got to this point then the thread is going to close itself after one line anyway so this abort is pointless
                // Thread.CurrentThread.Abort();
                workoutLooper = null;
            }
        }

Can't be fucked doing your jailtimer, I'm sure you can take what I put above and fix it with your new found knowledge.
 
Cobe even if phoenix is holograph its still the fucking best holograph that has been released so stfu and your learning system is to long umm you can pm you if you want a better one
 
Cobe even if phoenix is holograph its still the fucking best holograph that has been released so stfu and your learning system is to long umm you can pm you if you want a better one

Lol.. How is Phoenix the best Emulator ever..?


@ Aaron, You know what.. Thank you
I never say i'm a leet coder, and you helped x]

+1 rep
 
Quite good that Aaron, As i've said to you before on MSN, i have no idea how you made it all in one timer lol. but yeah, thanks for that ^^ Might do edits on all my timers :P. Are start on a new source :P.
 
Cobe even if phoenix is holograph its still the fucking best holograph that has been released so stfu and your learning system is to long umm you can pm you if you want a better one
Just for the record. if nillus never created holograph phoenix would never be :rolleyes:
 
holo is just a piece of ****. people would have been better off messing with jase.

dude if nillus never made holograph i think their would be better releases cause holo bring up so many noobs


Wow... What a load of bullshit tbh.. I believe HoloGraph was probly the best thing that happen'd to the retroing world. Yes Yes, there might have been glitches, but it in my eyes stated that you could expand on what we had(like the old n' days vb6 programming).

Nillus, did that for free and released it(okay, so what if he quit half way through, wouldn't you with noobs like you screaming at him for a release). I suggest you have a long had look at the retroing history. Nillus is probs one of the best Habbo coders to ever exist.
 
Wow... What a load of bullshit tbh.. I believe HoloGraph was probly the best thing that happen'd to the retroing world. Yes Yes, there might have been glitches, but it in my eyes stated that you could expand on what we had(like the old n' days vb6 programming).

Nillus, did that for free and released it(okay, so what if he quit half way through, wouldn't you with noobs like you screaming at him for a release). I suggest you have a long had look at the retroing history. Nillus is probs one of the best Habbo coders to ever exist.

Thats true but i didn't said their would b better i said their might be better releases because of holo, coders became lazy to code their own server okay
 
This command would be so much better if you included the whole intelligence system. But other then that it is nice maybe I will release a better version of this. But thanks Cobe. :thumbup:
 
Status
Not open for further replies.
Back