Forum rules: Do not post bugs or feature requests here! Report bugs to our Issue Tracker and suggestions to Suggest a Feature.

This site is not for solicitation of services or 'purchasing' development. Please do not post requesting side mods/plugins and so on. Your thread will be removed, and you will receive a warning.
User avatar
By Jephon
#136554 I'm getting pretty desperate. There has to be some way of doing this, either naturally or with a plugin of some sort..

I am trying to fix it so that if you have a badge (Boulder Badge for example), when you walk up to a gate, it automagically opens and the badge is taken away from you. The gate should only open if you have that badge in your inventory. If you don't you get no reaction at all from the gate.

I am doing this via command blocks as it seemed like it required the least amount of work to maintain it once set up.

What I have:
Spoiler:
Image

I have a timed clock mechanism to get a constant pulse for it to be checking for players to walk up to a spot.

If the first Command Block sees a player, it then sends a signal to the second command block to remove boulder badge from player and open door.

----
Thats the dream at least.
What actually usually happens is the first one functions perfectly, the second command block then removes the badge and opens the door. Cool.

I then try the process again and notice that the comparator (or whatever) is still on. I have to remove the second commandblock to get it to turn off. I also notice that even when I dont have a boulder badge in my inventory, I could still open the door..

What I guess I need is some sort of /testfor and it look for an item but I am not aware of that testfor command existing.. yet..

Does anyone know of a better way? Does anyone know of a plugin that adds commands to commandblocks?

Help?

Edit:
The exact commands from both blocks:
First one (The one closest to the pulsating clock) testfor @p[r=3,x=1830,y=102,z=-1755]
Second one: clear @p[r=3,x=1830,y=102,z=-1755] 4212

Where 4212 is my Boulder Badge id.

User avatar
By bobbanana09
#136557 I've tried that, and its failed. So I just used server signs to TP the player past the gate, and then they would get the badge back from the server sign.
User avatar
By Burgy
#136558 What you could do, and what I had done for a past server is make a Gym System where you gain XP as well as the badge after each gym.
However, users may gain XP in other methods so I had to make this first; which only allows players to be specific levels.
Code: Select alltestfor @r[lm=1,l=5]   xp set @r[lm=1,l=5] 0L

testfor @r[lm=6,l=9]   xp set @r[lm=6,l=9] 10L

testfor @r[lm=11,l=15]   xp set @r[lm=11,l=15] 10L

testfor @r[lm=16,l=19]   xp set @r[lm=16,l=19] 20L

testfor @r[lm=21,l=25]   xp set @r[lm=21,l=25] 20L

testfor @r[lm=26,l=29]   xp set @r[lm=26,l=29] 30L

testfor @r[lm=31,l=35]   xp set @r[lm=31,l=35] 30L

testfor @r[lm=36,l=39]   xp set @r[lm=36,l=39] 40L

testfor @r[lm=41,l=45]   xp set @r[lm=41,l=45] 40L

testfor @r[lm=46,l=49]   xp set @r[lm=46,l=49] 50L

testfor @r[lm=51,l=55]   xp set @r[lm=51,l=55] 50L

testfor @r[lm=56,l=59]   xp set @r[lm=56,l=59] 60L

testfor @r[lm=61,l=65]   xp set @r[lm=61,l=65] 60L

testfor @r[lm=66,l=69]   xp set @r[lm=66,l=69] 70L

testfor @r[lm=71,l=75]   xp set @r[lm=71,l=75] 70L

testfor @r[lm=76,l=79]   xp set @r[lm=76,l=79] 80L

testfor @r[lm=81,l=85]   xp set @r[lm=81,l=85] 80L

testfor @r[lm=86,l=89]   xp set @r[lm=86,l=89] 80L

Each line is a new CMD Block and the space between the commands are comparators -> cmd blocks
E.g
{CMD Block, "testfor @r[lm=86,l=89]"} -> {Comparator} -> {CMD Block, "xp set @r[lm=86,l=89] 80L"}

So this only allows players to have EXP values of 10, 20, 30, 40, 50, 60, 70 & 80.


Now, if you were to put CMD Blocks underneath the player podium in your gyms you could wire it to the opposite podium where the gym leader could press a button and give the player an EXP value. Such as: "xp set @p {value}L" and the obvious give command.

For the Level Door:
Code: Select allCommand Block One: /testfor @p[lm=5]
This will run a TEST (testfor) on the CLOSEST PLAYER (@p) to see if they have a MINIMUM LEVEL (lm) of 5 EXPERIENCE LEVELS.
Behind this command block, place a redstone comparator. If the player tests positive (meaning the player has a minimum of 5 xp levels) the command block will output a signal to the comparator. MAKE SURE THE COMPARATOR IS NOT IN SUBTRACTION MODE. Have this comparator facing another command block.

Command Block Two (with this comparator): /tp @p] x y z
If the player tests positive to what we did earlier, the player will be teleported to our coordinates and activate a pressure plate. That pressure plate will activate a signal and do the following:

    /xp -5L @p[lm=5]

Player has 5 EXPERIENCE LEVELS TAKEN FROM THEM (-5L) if player has a MINIMUM OF 5 LEVELS (lm=5)

2. /say Door Opened!

Broadcasts a message across the map telling all players that a door has been opened.

3. /tp @p x y z

This will teleport the CLOSEST PLAYER (@p) to the coordinates of your choice. I suggest teleporting the player to a block in front of the button.

Also, for the door, when the player teleports to the coordinates of the pressure plate, run a wire to an inverter to switch it off. This will deactivate a redstone torch, and make the pistons retract, releasing sand. This means the door has fallen, and is open. If you don't want to use sand, you can use an Iron door and wire the pressure plate up to a T-Flip Flop, which will be wired up to the door.

Coming off the same line of redstone we were first using, make a new section.

Command Block One: /testfor @p[l=4]
This will run a TEST (testfor) to see if the player has a MAXIMUM (l) of 4 EXPERIENCE LEVELS. This means the player has 4 levels or LESS. If the player tests positive to this test, he has tested negative to the other.
Now, to show the player he doesn't have enough xp, we will do the following:
Place down a redstone comparator branching off the command block, then place another command block in front of the comparator.
Have it run this message: /tell @p You do not have the required amount of funds to perform that action.
If this message appears, the player needs more XP to open the door.


Now you can do all this with scoreboards as well. Just change the @p[lm=5] to @pPoints_min] and the @p] to @pPoints=4] and skip the whole first thing about all those command blocks to keep the EXP levels at intervals of 10
User avatar
By Jephon
#136563
Burgy » 01 Sep 2014 02:07 wrote:What you could do, and what I had done for a past server is make a Gym System where you gain XP as well as the badge after each gym.
However, users may gain XP in other methods so I had to make this first; which only allows players to be specific levels.
Code: Select alltestfor @r[lm=1,l=5]   xp set @r[lm=1,l=5] 0L

testfor @r[lm=6,l=9]   xp set @r[lm=6,l=9] 10L

testfor @r[lm=11,l=15]   xp set @r[lm=11,l=15] 10L

testfor @r[lm=16,l=19]   xp set @r[lm=16,l=19] 20L

testfor @r[lm=21,l=25]   xp set @r[lm=21,l=25] 20L

testfor @r[lm=26,l=29]   xp set @r[lm=26,l=29] 30L

testfor @r[lm=31,l=35]   xp set @r[lm=31,l=35] 30L

testfor @r[lm=36,l=39]   xp set @r[lm=36,l=39] 40L

testfor @r[lm=41,l=45]   xp set @r[lm=41,l=45] 40L

testfor @r[lm=46,l=49]   xp set @r[lm=46,l=49] 50L

testfor @r[lm=51,l=55]   xp set @r[lm=51,l=55] 50L

testfor @r[lm=56,l=59]   xp set @r[lm=56,l=59] 60L

testfor @r[lm=61,l=65]   xp set @r[lm=61,l=65] 60L

testfor @r[lm=66,l=69]   xp set @r[lm=66,l=69] 70L

testfor @r[lm=71,l=75]   xp set @r[lm=71,l=75] 70L

testfor @r[lm=76,l=79]   xp set @r[lm=76,l=79] 80L

testfor @r[lm=81,l=85]   xp set @r[lm=81,l=85] 80L

testfor @r[lm=86,l=89]   xp set @r[lm=86,l=89] 80L

Each line is a new CMD Block and the space between the commands are comparators -> cmd blocks
E.g
{CMD Block, "testfor @r[lm=86,l=89]"} -> {Comparator} -> {CMD Block, "xp set @r[lm=86,l=89] 80L"}

So this only allows players to have EXP values of 10, 20, 30, 40, 50, 60, 70 & 80.


Now, if you were to put CMD Blocks underneath the player podium in your gyms you could wire it to the opposite podium where the gym leader could press a button and give the player an EXP value. Such as: "xp set @p {value}L" and the obvious give command.

For the Level Door:
Code: Select allCommand Block One: /testfor @p[lm=5]
This will run a TEST (testfor) on the CLOSEST PLAYER (@p) to see if they have a MINIMUM LEVEL (lm) of 5 EXPERIENCE LEVELS.
Behind this command block, place a redstone comparator. If the player tests positive (meaning the player has a minimum of 5 xp levels) the command block will output a signal to the comparator. MAKE SURE THE COMPARATOR IS NOT IN SUBTRACTION MODE. Have this comparator facing another command block.

Command Block Two (with this comparator): /tp @p] x y z
If the player tests positive to what we did earlier, the player will be teleported to our coordinates and activate a pressure plate. That pressure plate will activate a signal and do the following:

    /xp -5L @p[lm=5]

Player has 5 EXPERIENCE LEVELS TAKEN FROM THEM (-5L) if player has a MINIMUM OF 5 LEVELS (lm=5)

2. /say Door Opened!

Broadcasts a message across the map telling all players that a door has been opened.

3. /tp @p x y z

This will teleport the CLOSEST PLAYER (@p) to the coordinates of your choice. I suggest teleporting the player to a block in front of the button.

Also, for the door, when the player teleports to the coordinates of the pressure plate, run a wire to an inverter to switch it off. This will deactivate a redstone torch, and make the pistons retract, releasing sand. This means the door has fallen, and is open. If you don't want to use sand, you can use an Iron door and wire the pressure plate up to a T-Flip Flop, which will be wired up to the door.

Coming off the same line of redstone we were first using, make a new section.

Command Block One: /testfor @p[l=4]
This will run a TEST (testfor) to see if the player has a MAXIMUM (l) of 4 EXPERIENCE LEVELS. This means the player has 4 levels or LESS. If the player tests positive to this test, he has tested negative to the other.
Now, to show the player he doesn't have enough xp, we will do the following:
Place down a redstone comparator branching off the command block, then place another command block in front of the comparator.
Have it run this message: /tell @p You do not have the required amount of funds to perform that action.
If this message appears, the player needs more XP to open the door.


Now you can do all this with scoreboards as well. Just change the @p[lm=5] to @pPoints_min] and the @p] to @pPoints=4] and skip the whole first thing about all those command blocks to keep the EXP levels at intervals of 10


The scoreboard idea sounds the best. I think this will get kind of annoying as the server I am building will be a survival server which of course means player ran (and built) gyms. Still, I think this shouldn't be hard to put in each gym.

I cannot believe there is no better way than this. I glanced over what 1.8 adds to the game, do you know if this will be do-able when we eventually update to that? Just curious if what I am doing needs to be considered a temp fix or a perm one.
User avatar
By Jephon
#136569 I actually did find a problem with this scenario that may really change our plans as far as our gyms go. Trainers cannot activate any commands can they? Nor can they be potentially tied to a command block in any form or fashion right? Our first gym was going to be an NPC gym to teach players on the gym leader challenge and to encourage that aspect of our server but if I cannot do this, I'll need to rethink that.
User avatar
By Burgy
#136582 Well, what if you used the very first method you had however, you added a command block at the end that was a /setblock and reset the comparitor? I'm hypothesizing that this would work. But not 100% sure
User avatar
By Jephon
#136588 Actually yea, I tried that. Seemed to form an endless loop. Maybe I did that wrong. But I'm pretty sure I didn't.

I think we will just toss the idea of the gym close to spawn awarding badges. We can figure out something. Could even be a gym to award a hitmonlee/ Hitmonchan type thing.

Thanks for looking into it though!!
JOIN THE TEAM