Thread: Basic Coding Tutorials

Page 1 of 3 123 LastLast
Results 1 to 10 of 26
  1. #1 Basic Coding Tutorials [1 new TuT] 
    Guitars595
    Guest
    Purpose:To teach newcomers basic tasks on their server.
    Assumed Knowledge:How to compile, how to read, how to follow directions.
    Source Used:Allstar Scape source V.1
    Difficulty:0/10, built for Newcomers to private servers.
    Files Edited:Client.Java, Autospawn.Cfg, NPCHandler.Java, Player.Java.

    Welcome to my Basic Coding Guide. In this Tutorial you will learn numerous simple coding tasks for your server source.

    Chapter 1 - Learning to add objects to the server.
    Chapter 2 - Make a Portal teleport you.
    Chapter 3 - Adding an NPC to your server
    Chapter 4 - How to make an NPC yell
    Chapter 5 - Chaning Max money ammount, starting location, begining player equip
    Chapter 6 - Making a simple switch to Ancient and Normal Magics Command

    Chapter 1 - Adding Objects

    First off open Client.Java in Notepad in your source folder and search [code] public void NewObjects() {

    after that you should should see a lot of these
    Code:
    makeGlobalObject(2510, 3863, 2783, -3, 10);// Anvil
    After finding that go to the last Makeglobalobject and put this code in
    Code:
           makeGlobalObject(Xcood, YCoord , Object ID, face direction, 10);// Object Name
    Now replace Xcoord with the Xcoordinate of where your standing and change the Ycoord to the Ycoordinate. Where it says Object Id put in the object you want. Where it says face direction that means which way the object will be facing.
    and then put a number 1-4.

    Do not change the 10 at the end and where it says object name put the objects name. So this is an example of what it would look like all together

    Code:
          makeGlobalObject(2500, 2400, 103, -3, 10);// Object example.
    And thats all you have to do. Save and compile and there you go you have an object!

    Chapter 2 - Make a portal teleport you

    First find the id of the Portal you want to make. Make the portal where you want it to be and compile to see if it works. Next go back up to the top of Client.Java and search

    Code:
    Portals
    you should see something like this

    Code:
           // Portals
    under that paste this under one of the cases
    Code:
     
           case ####: // Portal name
                teleportToX = ####;
                teleportToY = ####;
                sendMessage("Description");
                break;
    The #'s after the case is the portal Id, the #'s by teleport to x and y are the Coord locations and in between the quote marks is what you want it to say once it teleports you. Example: You teleport to the Pking Area! And Thats it! Save and compile. Log back in and teleport away.

    Chapter 3 - Adding an Npc to your server

    Okay open up your Autospawn.cfg file. It can either be in the Config file or it can be in the main area in your source folder. Anyways open up Autospawn and go to the bottom of the list and add this in
    Code:
    spawn = NpcId	Xcoord	YCoord	0	0	0	0	0	1	Npc Name
    Just for now just edit the things I changed. Do not worry about the rest of the stuff until later. After you finished that save and compiler and your done.

    Chapter 4 - Making an NPC yell

    Go into your source file again and open your NPCHandler.Java file and search
    Code:
    Welcome
    If your using an already coded server you should see something like this
    Code:
                        if (npcs[i].npcType == 409) {
                            if (misc.random2(30) <= 2) {
                                npcs[i].updateRequired = true;
                                npcs[i].textUpdateRequired = true;
                                npcs[i].textUpdate = "Welcome to Servername";
                            }
                        }
    So under the last } add this code
    Code:
                        if (npcs[i].npcType == ####) {
                            if (misc.random2(30) <= 2) {
                                npcs[i].updateRequired = true;
                                npcs[i].textUpdateRequired = true;
                                npcs[i].textUpdate = "Npc Text";
                            }
                        }
    Change the ####'s to the Npc Id and the Npc text to what the Npc is going to say. This will make it so the Npc yells over its head continueously. Save and compiler and your done.

    Chapter 5 - Chaning Max money ammount, starting location, begining player equip

    First off open Player.Java and search
    Code:
        public int maxItemAmount =
    after the maxitemamount you should see 999999999/999999999. Change both codes to
    Code:
    2147000000
    and your done. The max ammount of items and money is now 2147m.

    Okay moving on how to change the character starts out with. Scroll back up to the top of Player.Java and search
    Code:
    
            // Giving the player an unique look
    or [code] playerEquipment[playerHat]= [/code

    Then you will see a whole list of the items that are equipped to the character when they first begin. Change the numbers to the item ID's you want.

    Finally How to change the starting location of a character. Still in Player.Java search this
    Code:
    
            // initial x and y coordinates of the player
    You should see this below it
    Code:
            teleportToX = ####; // ####;
            teleportToY = ####; // ####;
    Change the #'s in teleportToX to the X coordinates of the starting locations. Then do the same with TeleportToY. And thats it!!! Your finally done in Player.Java.
    Save everything and compile.

    Chapter 6 - Making a simple Switch Command

    Okau start off by opening Client.Java and searching for
    Code:
                    if (command.startsWith
    and under the last } of a command add these two codes in
    Code:
                    if (command.startsWith("switchA")) {
    				updateRequired = true;
    				setSidebarInterface(6, 12855);
    				ancients = 1;
    		            sendMessage("You feel a gain in knowledge...");
    }
                    if (command.startsWith("switchN")) {
    				updateRequired = true;
    				setSidebarInterface(6, 1151);
    				ancients = 0;
    		            sendMessage("You feel a loss in knowledge...");
    }
    Now I know this isn't the real switch command I just threw together, so please don't flame. Save and compile and your done!

    Credits: 40% to me, 60% for all server sources.

    Post any problems you find here or any mistakes in the tutorial. Feel free to comment. Please do not leech.

    To avoid any flaming yes I posted this on Moparscape.
    Reply With Quote  
     

  2. #2  
    Guitars595
    Guest
    Hence the word
    Basic
    for retards
    Reply With Quote  
     

  3. #3  
    Calvin™
    Guest
    Highscapee stfu, the only thing you've released that actually was semi good was your Gambling release which is horrible to have on a server.
    Reply With Quote  
     

  4. #4  
    haloking
    Guest
    Quote Originally Posted by Highscapee View Post
    If people don't know how to do these things, they need to go here: [Only registered and activated users can see links. ]

    Its common sense..
    so...

    no rep, no appreciation
    make a real tutorial.
    People need to learn sometime. But im sure you were never a newb at coding. Right? Everybody is a newb at some point, now stop flaming and do something important in your life.
    Reply With Quote  
     

  5. #5  
    Guitars595
    Guest
    thanks for backin me up
    Reply With Quote  
     

  6. #6  
    haloking
    Guest
    Quote Originally Posted by Guitars595 View Post
    thanks for backin me up
    yes no problem, I gave you rep too.
    Reply With Quote  
     

  7. #7  
    Hawt Bird
    Guest
    Great guide, just started coding and this helped a lot.
    Reply With Quote  
     

  8. #8  
    SERGEANT OF THE MASTER SERGEANTS MOST IMPORTANT PERSON OF EXTREME SERGEANTS TO THE MAX!

    cube's Avatar
    Join Date
    Jun 2007
    Posts
    8,881
    Thanks given
    1,854
    Thanks received
    4,741
    Rep Power
    5000
    Just to note you, these aren't really examples of coding...
    Reply With Quote  
     

  9. #9  
    super newb70
    Guest
    this guide helps me alot!
    Reply With Quote  
     

  10. #10  
    tomthebomb80
    Guest
    Quote Originally Posted by Highscapee View Post
    If people don't know how to do these things, they need to go here: [Only registered and activated users can see links. ]

    Its common sense..
    so...

    no rep, no appreciation
    make a real tutorial.

    Dude u have no common sense.. This is good for new java coders that want to learn more about it dont just spam peoples threads because they are trying to help new players..
    Anyway good job
    Reply With Quote  
     

Page 1 of 3 123 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •