RuneScape 2 Development > Server Help

[REQ] - Tzhaar fightcave respawn

<<< (3/3)

tank nation:

--- Quote from: sk8rdude461 on July 19, 2015, 11:14:58 PM ---
--- Quote from: tank nation on July 19, 2015, 10:11:59 PM ---Okay so here is what i did, this coding makes me go to the spot in fightcaves that i want it after i die inside of fightcaves.. but anywhere else that i die i go to that same spot but it looks as if im at the same place i died but with my tzhaar guys around so i know that im actually back at fight caves.


--- Code: ---if (c.inFightCaves()) {
movePlayer(Config.RESPAWN_X, Config.RESPAWN_Y, 0);
c.isSkulled = false;
c.skullTimer = 0;
c.attackedPlayers.clear();
if (c.inFightCaves()) {
movePlayer(3101, 3494, 0);
} else {
movePlayer(2439, 5169, 0);
}
c.getPA().resetTzhaar();
}
--- End code ---

--- End quote ---
Not exactly understanding what you're saying..
You've also got some spaghetti code going on.
You only want the if statement to surround the code that will be affected, nothing more.
You also have two if statements in there, which is why you're getting a weird respawns for places outside of the fight caves.


Remember the example I gave to you earlier?

--- Quote ---
--- Code: Java ---if(inFightCaves()) {     movePlayer(FIGHT_CAVES_X, FIGHT_CAVES_Y, FIGHT_CAVES_Z);} else {     movePlayer(NORMAL_X, NORMAL_Y, NORMAL_Z);}
--- End quote ---
Notice how the only code within the if statement (and else statement) is the code to move the player.

Now here is your code:

--- Code: Java ---if (c.inFightCaves()) {        movePlayer(Config.RESPAWN_X, Config.RESPAWN_Y, 0);        c.isSkulled = false;        c.skullTimer = 0;        c.attackedPlayers.clear();        if (c.inFightCaves()) {                movePlayer(3101, 3494, 0);        } else {                movePlayer(2439, 5169, 0);        }        c.getPA().resetTzhaar();}(I tabbed it a bit better)
As you can see, your if statement goes around the entirety of the code, so when not in the fightCaves, the player doesn't get moved from their position.
What you need to do is A) Delete this: movePlayer(Config.RESPAWN_X, Config.RESPAWN_Y, 0); (Second line)
B) Delete the if statement that is surrounding all the code.
C) Fix the code in the else statement to use the Config.RESPAWN variables (They are there for a reason, and being ignored isn't that reason).

--- End quote ---

here's what i have now, i did as you said and also i put it in my code of applydead the same way..


--- Code: ---if (c.inFightCaves()) {
        c.isSkulled = false;
        c.skullTimer = 0;
        c.attackedPlayers.clear();
                movePlayer(3101, 3494, 0);
        } else {
                movePlayer(2439, 5169, 0);
        c.getPA().resetTzhaar();
}
--- End code ---

sk8rdude461:
I said to remove the first if statement
Instead, you removed the second one.

Use tabbing to understand how the code will be read...

--- Code: Java ---if (c.inFightCaves()) {        c.isSkulled = false;        c.skullTimer = 0;        c.attackedPlayers.clear();        // ^Everything above this line shouldn't be within the if statement        movePlayer(3101, 3494, 0); // This should be.} else {        movePlayer(2439, 5169, 0);// This should be in the else statement.        c.getPA().resetTzhaar();// This should be in the if statement, not the else statement.}

tank nation:

--- Quote from: sk8rdude461 on July 20, 2015, 11:23:51 AM ---I said to remove the first if statement
Instead, you removed the second one.

Use tabbing to understand how the code will be read...

--- Code: Java ---if (c.inFightCaves()) {        c.isSkulled = false;        c.skullTimer = 0;        c.attackedPlayers.clear();        // ^Everything above this line shouldn't be within the if statement        movePlayer(3101, 3494, 0); // This should be.} else {        movePlayer(2439, 5169, 0);// This should be in the else statement.        c.getPA().resetTzhaar();// This should be in the if statement, not the else statement.}
--- End quote ---


i tried it 2 ways like this
--- Code: ---if (c.inFightCaves()) {
c.getPA().resetTzhaar();
movePlayer(3101, 3494, 0);
        } else {
                movePlayer(2439, 5169, 0);
}
c.isSkulled = false;
        c.skullTimer = 0;
        c.attackedPlayers.clear();
--- End code ---

and like this still the same thing happens.

--- Code: ---if (c.inFightCaves()) {
c.getPA().resetTzhaar();
movePlayer(3101, 3494, 0);
        } else {
                movePlayer(2439, 5169, 0);
c.isSkulled = false;
        c.skullTimer = 0;
        c.attackedPlayers.clear();
}
--- End code ---

sk8rdude461:
The top one of the two would be the correct way to do it.
Make sure there's no other code to move the player.

tank nation:

--- Quote from: sk8rdude461 on July 20, 2015, 03:58:41 PM ---The top one of the two would be the correct way to do it.
Make sure there's no other code to move the player.

--- End quote ---

Yeah i think there is and i'm not finding it.. it's messing with my coding and that's the reason it's not doing the correct thing..

Navigation

[0] Message Index

[*] Previous page

Go to full version
Powered by SMFPacks SEO Pro Mod |