RolePlay Learning System.

Status
Not open for further replies.
Joined
Apr 28, 2010
Messages
2,793
Reaction score
1,179
Makarov - RolePlay Learning System. - RaGEZONE Forums

EDIT
I cleaned the code a bit, and deleted a looper.
should still work x] Also notice some errors which have been fixed.


I was bored.. and i remembered how dirty mango's learn code was.

So i decided to re-code it!

Open up VirtualUser.cs

First, ctrl + f private Thread workoutDosLooper;
add this under
PHP:
private Thread learnLooper;

Second, ctrl + f workout
add this code under the workout command
PHP:
                                        #region :learn  
                    case "learn":
                        {
                            int ifLearning;
                            using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
                            {
                                ifLearning = dbClient.getInt("SELECT learning FROM users WHERE name = '" + _Username + "'");
                            }
                            if (ifLearning == 0 && learningLooper == null)
                            {
                                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();
                                        using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
                                        {
                                            dbClient.runQuery("UPDATE users SET learning = '1' WHERE name = '" + _Username + "'");
                                        }
                                    }
                                }
                            }
                            break;
                        }
                    #endregion

Third, now ctrl + f private void workOutDos()
Now add this private void under it
PHP:
         private void learn()
        {
            int iCount = 0;
            try
            {
                while (true)
                {
                    int learning;
                    using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
                    {
                        learning = dbClient.getInt("SELECT learning FROM users WHERE name = '" + _Username + "'");
                        if (learning == 0)
                        {
                            sendData("BK" + "You must wait 1 minute before learning again.");
                            learnLooper = null;
                            learnLooper.Abort();
                        }
                        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))
                        {
                            int myIntel;
                            int myTime;
                            //refreshAppearance(false, false, true);
                            myIntel = dbClient.getInt("SELECT intel FROM users WHERE name = '" + _Username + "'");
                            if (myIntel > 14)
                            {
                                sendData("BK" + "Sorry, your intelligence level cannot pass 15.");
                                learnLooper = null;
                                learnLooper.Abort();
                            }
                            int schoolTime = myIntel * 10;
                            myTime = dbClient.getInt("SELECT time_learn FROM users WHERE name = '" + _Username + "'");
                            iCount = myTime;
                            Room.sendWhisper(roomUser, _Username, "(Learning: " + iCount + "/" + schoolTime + " Minutes)");
                            iCount++;
                            dbClient.runQuery("UPDATE users SET time_learn = '" + iCount + "' WHERE name = '" + _Username + "'");
                            if (iCount > schoolTime)
                            {
                                Room.sendSaying(roomUser, "*feels smarter*");
                                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 + "'");
                            Room.sendSaying(roomUser, "*stops learning*");
                            learnLooper = null;
                            learnLooper.Abort();
                        }
                        Thread.Sleep(60000);
                    }
                }
            }
            catch
            {
                Thread.CurrentThread.Abort();
                learnLooper = null;
            }
        }

Now here is the part im bad at.
You have to Add 3 Columns to the User Table.
PHP:
intel (INT)= 2
PHP:
learning (INT) = 11
PHP:
time_learn (INT) = 11

Sorry about the SQL part :blushing:

But it would be nice if you thanked Meh <3

Bai!


P.S If there is a error in my coding, please notify me!:rolleyes:


Edit
I Implemented a JailBreak Void.

If you Intelligence is at level 14, You can Instantly JailBreak.
And the cops arent notified.

PHP:
        private void jailBreak()
        {
            int iCount = 0;
            try
            {
                while (true)
                {
                    using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
                    {
                        int Intel;
                        Intel = dbClient.getInt("SELECT intel FROM users WHERE name = '" + _Username + "'");
                        {
                            if (Intel == 14)
                            {
                                Room.sendSaying(roomUser, "*successfully breaks down the jail wall freeing everyone inside*");
                                dbClient.runQuery("UPDATE users SET time_jail = '0', arrested = '0'");
                                jailBreakLooper = null;
                                jailBreakLooper.Abort();
                            }
                            else
                            {
                                if (_roomID != 150 || roomUser.Y != 11 || roomUser.X != 4)
                                {
                                    Room.sendSaying(roomUser, "*stops breaking down the wall*");
                                    jailBreakLooper = null;
                                    jailBreakLooper.Abort();
                                }
                                if (iCount == 60)
                                {
                                    Room.sendSaying(roomUser, "*needs three more minutes to succesfully knock down this wall*");
                                }

                                if (iCount == 120)
                                {
                                    Room.sendSaying(roomUser, "*needs two more minutes to succesfully knock down this wall*");
                                }

                                if (iCount == 180)
                                {
                                    Room.sendSaying(roomUser, "*needs one more minute to succesfully knock down this wall*");
                                }

                                iCount++;

                                if (iCount > 180)
                                {
                                    Room.sendSaying(roomUser, "*successfully breaks down the jail wall freeing everyone inside*");
                                    dbClient.runQuery("UPDATE users SET time_jail = '0', arrested = '0'");
                                    jailBreakLooper = null;
                                    jailBreakLooper.Abort();
                                }
                                Thread.Sleep(1000);
                            }
                        }
                    }
                }
                }
            catch
            {
                Thread.CurrentThread.Abort();
                jailBreakLooper = null;
            }
        }

Pressing thanks would be nice!
 
Last edited:
Nice Cobe You Should Do it Like BJorks One Like When You Pick Book up then you Can Learn but this Nice to

Here
Learn checks if you have a book.
PHP:
                    #region :learn  
                    case "learn":
                        {
                            int ifLearning;
                            int book;
                            using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
                            {
                                ifLearning = dbClient.getInt("SELECT learning FROM users WHERE name = '" + _Username + "'");
                            }
                            {
                                book = dbClient.getInt("SELECT book FROM users WHERE name = '" + _Username + "'");
                            }
                            if (ifLearning == 0 && learnDosLooper == null && learningLooper == null && book == 1)
                            {
                                if (_roomID == 200)
                                {
                                    if ((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))
                                    {
                                        if (_Rank < 2)
                                        {
                                            sendData("Sorry, but this a private school.");
                                        }
                                        else
                                        {
                                            Room.sendSaying(roomUser, "*Starts to learn*");
                                            ThreadStart learnStarter = new ThreadStart(learn);
                                            learnLooper = new Thread(learnStarter);
                                            learnLooper.Priority = ThreadPriority.Lowest;
                                            learnLooper.Start();
                                            using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
                                            {
                                                dbClient.runQuery("UPDATE users SET working_out = '1' WHERE name = '" + _Username + "'");
                                            }
                                        }
                                    }
                                }
                            }
                                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();
                                        using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
                                        {
                                            dbClient.runQuery("UPDATE users SET learning = '1' WHERE name = '" + _Username + "'");
                                        }
                                    }
                                }
                            break;
                        }
                    #endregion

And the Book Command.
PHP:
#region :book
                    case "book":
                        {
                          using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
                           {
                                    dbClient.runQuery("UPDATE users SET book = '1' WHERE name = '" + _Username + "'");
                                    Room.sendSaying(roomUser, "*Grabs a text book*"); 
                           }
                            
                            break;
                        }
                    #endregion
 
Status
Not open for further replies.
Back