Zel Pkz & Zelscape
November 17, 2025, 01:27:50 am
Welcome, Guest. Please login or register.

Login with username, password and session length
 
  Home Forum Help Search Staff List Login Register  

  Show Posts
Pages: [1] 2 3 ... 12
1  Zel Pkz General / Compliments / Re: my compliments to sorry try me hes great pker on: May 09, 2008, 07:41:33 pm
Dude Hes an In-Game Admin -.- lol,
2  Annoucements / Announcements / Re: Vote for you fav theme for the new forums on: May 06, 2008, 12:59:17 am
Dude.. i would do box, if it didnt say box.. or have the button on an xbox, otherwise NO
3  Annoucements / Announcements / Re: Vote for you fav theme for the new forums on: May 05, 2008, 03:22:48 am
No voting. 2nd One. I hate Xbox...It's ****.
4  Java / Java Tutorials / 1v1 Areas! - From Zel's Tut Package 1 on: May 03, 2008, 11:37:07 pm
 1 Vs. 1 Zones [What We Did & Why]
« on: March 04, 2008, 04:08:47 PM » 

--------------------------------------------------------------------------------
I helped somebody out earlier, and outdid myself and made a giant tutorial for this. So here it is, from the original post. Also, this is meant for wL-based servers. I'll hurt myself later for doing that. But it can be very, very easily converted into a "RS2DV by varek" tutorial.

I'm pretty sure that boolean attack() or attackPlayer() or something similar handles all PKing features. Just find the spot where a player starts to attack another player, and then create a new variable for both players. So in the client class, declare a new lets say String object which will tell us if the player is already in a fight (and holds the other players name for purposes uncovered later), and intialize it.


Code:
public String inBattle;

Now that we can actually use something, go back to that attacking method and find the spot where a player attacks another. This time we'll do something similar to this...
When about to attack, simply:


Code:
server.playerHandler.players[playerID].inBattle = server.playerHandler.players[otherPlayerID].playerName;
server.playerHandler.players[otherPlayerID] = server.playerHandler.players[playerID].playerName;

otherPlayerID will be different for most of you. Just use the integer they already setup in that bulk of a method (something like AttackingOn.playerID?)

Now everytime an attack is launched against a player, its inBattle variable has to be set. Now we have to do the opposite of what we just did, and we have to check if the player is already in a battle before he attacks. So...


Code:
if(!inBattle.equals(null)) sendMessage("You just left a battle. Please wait 10 seconds before switching targets.");
else if((!server.playerHandler.players[otherPlayerID].inBattle.equals(null)) || inBattle.equals(server.playerHandler.players[otherPlayerID].inBattle))
{
      //Original attacking part here
}
else sendMessage("You cannot attack a player who is already in combat.");

This will check if the player is in battle. If not, the attack continues. If so, the player is told he is already in a battle and cannot be attacked through the sendMessage(String) method.

From here its actaully pretty easy. We'll have to at some point change the value of inBattle to null again, indicating the player is out of battle. How? Well lets think for a bit. The only way easier way I can think of right now is to compare the time of attack and the current time. Lets go back to the player attacking, or PKing method, I mentioned earlier.

Here, after we set the inBattle variable, we have to set the time of which that happened. So, first, lets create an Integer value that can be used throughout the class.


Code:
private int lastAttack;

Now we can use it with any method we want, because it is not a local variable. So, back to the player attacking method again, we can set that time after we set the value of inBattle. To do this, we can simply do:


Code:
lastAttack = new GregorianCalendar().get(Calendar.SECOND);
The value will range from 0-59 at all times. Now, we'll have to constantly check the seconds between the current time and attack time to see how long it has been. We'll go with the RuneScape default: 10 seconds.

Go to boolean process(), and lets work things out here. We have to get the current time every half-second (thats how fast process() is called), and compare it to the attack time. We only need the seconds for each because of how I roll.


Code:
int currentSecond = new GregorianCalendar().get(Calendar.SECOND);
if(currentSecond < lastAttack)
      if(((60-lastAttack) + currentSecond) == 10) inBattle = null;
else
      if((currentSecond - lastAttack) == 10) inBattle = null;

Looks weird, doesn't it? Well, the way I have it setup is so it only compares seconds. I'm pretty sure this works, but I haven't tested it. If the currentSecond was 5 and the lastAttack was 55, then if I did 5-55 I would get a negative number. So I had to work around that. If the currentSecond is less than lastAttack, it will get the differential between 60 and lastAttack, which would be 5 in this case, and then add it to the currentSecond, resulting in 10 seconds. That's exactly what we need.

Hope I helped. This is all you really need, too.
Ah, see, 15 new lines of code, compared to the dozens in other cruddy tutorials for 1vs1 zones.

Also, you might have to add a few if statements here and there to check for your current position (at the player attacking part) if you want only some parts 1vs1. Because right now, this makes your whole server 1 vs. 1. You'll also need to import the correct packages (hmm.. java.util.GregorianCalendar).
5  Java / Java Tutorials / Zelritz's #1st TuT Package - Comes With 20+ TuTs! on: May 03, 2008, 11:27:01 pm
Hey download my TuT Package, I will slowly release the tuts on these forums. Butthe package is only 36KB!

Heres the link!:

http://uppit.com/7LXXGZ
6  Annoucements / Announcements / Business Partners! on: May 03, 2008, 10:27:34 pm
Hey, I have a business partner. He has a server named Jaxis Scape, we working together.
Were going to make a site with smf forums etc.. And we're following after LittleSoft, a great little GFX company.
But ours will be more on the gaming side Wink
Zel Pkz and Jaxis Scape, will be 2 of the 3 main servers. On there.

Me and my partner are maknig a 3rd server together, of which Hadd has already seen.
You's will be awarded Staff Positions in our new business if it goes well.


Peace, I zel I
7  Annoucements / Announcements / Re: New Staff + New Crowns + New Icons + I'm Back!! on: May 03, 2008, 10:25:33 pm
I was on a break.. + im currently in a business Wink

If you've heard of LittleSoft, it'll be like that.
8  Annoucements / Announcements / New Staff + New Crowns + New Icons + I'm Back!! on: May 03, 2008, 02:22:14 am
Hey Guys! im back, i needed a break im currently co-owner of 3 servers, you know how it is :/

Anyways! Added New Crowns! And New Icons that say Staff...etc..


Ok I'd Like To Announce:

Venom - Has come back, he asked for admin, but instead i made a new member group called helper, which is above admin but below co-owner.
Con Gratz Venom!

I Inlight I - Im making you a forum Mod, you deserver it ;0
Cheers, btw

Im adding a java section to the forum so that people can earn "Java Coder" Smiley
Enjoy!
9  Annoucements / In-Game Updates / Re: Mega Update #1!!! on: April 30, 2008, 01:47:08 am
Nope sorry i've already got the test version of the client from ym ate, hes past Ric914's level of client making, thanks anywayz tho.
10  Annoucements / Announcements / Re: Donations are Done! on: April 28, 2008, 01:00:44 am
lol
11  Donations / Donations - General / You need Paypal on: April 26, 2008, 08:35:16 pm
Hey!

Just thought i'd let yas know you need paypal to donate,
but dw just pretend ur over 18 and yeah.
12  Annoucements / Announcements / Donations are Done! on: April 26, 2008, 08:54:06 am
The donating is set up! Oh Yeah!

To donate go to the home page and look on the left youll see a donating sign Wink

Click on it fill in the details and ammounts and go!

Once you donation is successfully in place ill deliver ur package!
13  Donations / Donations - How? / Re: How to Donate on: April 26, 2008, 08:23:29 am
is it goin into ur paypal account?

and how old r u? if u r under 18 and have ur own paypal. Im gunna make my own and we can use that.

A Member of zel pkz is willing to donate 350$ a month.
His parents have 73mil+ irl.

And he has 75,000 in his paypal.
All he wants is mod..

He also has 5m irl.

14  Annoucements / Announcements / Re: OMG! since no1 else did, I did on: April 26, 2008, 06:49:37 am
Please make a post in the clans section of the forum.

Cheers, Wink
15  Market / Shops / Re: ~Zel's Godswords~ [UNFINISHED] on: April 24, 2008, 10:04:11 pm
Nope godswords all have custom specials made by me, and theyre 45M each in game.
Pages: [1] 2 3 ... 12
Bookmark this site! | Upgrade This Forum
MySMF - Create your own Forum

Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy