This tutorial will teach you how to properly add Premium member only areas.
Purpose
If a character who is not a member attempts to get in the member only area then it will teleport the non-premium character out of the member area and send them a message that say's they need to subscribe to be in that area.
Source Tested On
Deltascape, but it should work on all with some tiny modifications..
To begin with you need to add the following to your server, I take no credit for this part of the tutorial (I can't remember who made this part though..)
1)Open up your config folder and make a file called members.text
2)Add the following code next to some other int's:
Code:
public int checkmembers()
{
try
{
BufferedReader in = new BufferedReader(new FileReader("config/members.txt"));
String data = null;
while ((data = in.readLine()) != null) {
if (playerName.equalsIgnoreCase(data)) {
return 5;
}
}
} catch (IOException e)
{
System.out.println("Critical error while check members!");
e.printStackTrace();
}
return 0;
}
That is all we will be using from the other person's tutorial, I will explain what it does though.
Explanation of Step 2
What the above code does is checks the file "members.text" to see whether or not a player is a member. If a player is a member then it returns a 5, if the player isn't a member then it doesn't return a 5.
3)Now we are going to add another void, it is almost the same as the IsInWilderness Void found in most sources.
So, add this code:
Code:
public boolean memberArea(int coordX, int coordY, int Type) {
if (Type == 3) {
if ((coordY >= XXXX) && (coordY <= XXXX) && (coordX <= XXXX)
&& (coordX >= XXXX)) {
return true;
}
} else if (Type == 4) {
if ((coordY >= XXXX) && (coordY <= XXXX) && (coordX <= XXXX)
&& (coordX >= XXXX)) {
return true;
}
}
return false;
}
So to add a member only area fill in the "X's" with the COORDS of the area you want to be members only. You would fill in the COORDS the same way you would add them to a safezone.
If you wanted to add a new area other then the 2 that I put options for then you would put the following code in after the and put
Code:
} else if (Type == 5) {
if ((coordY >= XXXX) && (coordY <= XXXX) && (coordX <= XXXX)
&& (coordX >= XXXX)) {
return true;
}
}
and so on.. All you have to do is change the "Type == 5" to "Type == WHATEVER"
So now we need to make the server check for whether or not a player is in the memberArea. To do this go into your boolean process and add the following:
Code:
if (memberArea(absX, absY, 3)) /*Start Runeore Premium membership check and teleport*/
{
if (checkmembers() != 5)
{
sM("Sorry this is a member's only area, please purchase");
sM("a membership pin from the Runeore Forums!");
toX = 3092;
toY = 3499;
}
}
Explanation of the above code:
The above code is basically saying that if a player is in a memberArea then the server need's to check whether or not the player is premium or not. If the player is not premium then he will be sent a message and teleported to the above codes.
Code:
(memberArea(absX, absY, 3))
What that code means is that it's using the memberArea int to check what COORDS are member only. The only thing you need to worry about in that part of the code is Replace that with whatever your "Type ==" From above.
I think that is explained pretty thoroughly, if you didn't understand something or you get errors then post back here.