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
you should see something like this
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
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
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.