Catchy title huh? Haha, well i want to create a plugin that when you say '/fire' you burst into flames. It's just for a prank on a friend, not meant for any harm. What would be the easiest way? I could see ENTITY_PLAYER + Fireticks, but i don't understand fireticks.
fireticks is how long you will be on fire for (in ticks, which are 1/20th of a second long). if fireticks isnt zero, you're on fire. Every tick the value decreases by 1 until it reaches zero and you stop being on fire. So, to make someone be on fire for 5 second, set fire ticks to 5*20=100
Well i want to direct it only towards the person that says it, that could just me like: if(s[0].equalsIgnoreCase("/fire"){ fireticks = 5*20; } never worked with fireticks so don't know what it is yet
On another note, i have never used a function that's like: /fire <player> like to set that player on fire, because that would be nice too in other words how could i set a guy on fire, since some of my friends goof around on my server i would think it would be funny to just set them on fire willy nilly.
Code: if(s[0].equalsIgnoreCase("/fire"){ Player target; if(s.length > 1) target = plugin.getServer().getPlayer(s[1]); if(target == null) target = e.getPlayer(); target.serFireTicks(100); } a bit like that (just off the top of my head)
urgh, haha never dealt with somethin like that before, time to hit the books XD --- merged: Feb 26, 2011 10:23 PM --- where would you learn that stuff?
Well i understand the if statements but you just threw in targets and stuff Code: Player target; if(s.length > 1) target = plugin.getServer().getPlayer(s[1]); if(target == null) target = e.getPlayer(); target.serFireTicks(100); --- merged: Feb 26, 2011 10:28 PM --- Quick question is minecraft.net down for you too?
It's been down all day. Let me try to comment the code a little: PHP: if(s[0].equalsIgnoreCase("/fire"){ //Define a variable of type Player, called target, for storing the person to set on fire (initially set to null). Player target; //Check whether their command includes an extra argument for player name if(s.length > 1) //If so, set target to be the player with the name given target = event.getPlayer().getServer().getPlayer(s[1]); //if by this point target is still equal to null, either a name argument wasn't supplied or there was no player with that name. if(target == null) //in that case, target the player calling the command. target = event.getPlayer(); //set target on fire. target.setFireTicks(100);}
If i have one string, like s[0] i have to set that up like: String[] s = what? for that instance, because i have String split[0] = event.getMessage().split(" "); and event.getPlayer(); --- merged: Feb 26, 2011 10:39 PM --- Then it says that the "e" and s's arent registered variables.
Oh. replace that 'e' with 'event' (force of habit - I usually name my events e) Also, you need this line (which I assumed you already had from the code you showed me): String[] s = event.getMessage().split(" ");
Ahh, i wish i caught onto that but this is so new to me XD The Player Target; part is the only part that's "broken" that part is fine, but the other target variables in it say i have to make Player target = null;
Oh yeah. It'll complain it may not have been initialised. That's what happens when you code off the top of your head ^_^. Set it equal to null then.
alrighty Thanks Edward! --- merged: Feb 26, 2011 10:52 PM --- I want to make it if player is op to, but i get the thing "op" is not a static reference do i need to make it "public static void (){} or whatever? --- merged: Feb 26, 2011 10:52 PM --- Sorry for bombarding you with questions~
So if i have : if(event.getPlayer().isOp() && s[0].equalsIgnoreCase("/fire")) it's saying if player is Op and he says /fire do: etc
Since we're obvously teaching programming here: if you use event.getPlayer() so often, try to assign it somewhere so you do not call the function too many times. Player myPlayer = event.getPlayer(); and use myPlayer instead. I know here it does not really matter, but if you get into that practice it will only make your code better in the future.
Alright cool, see i can remember this stuff because i studied web development for a while, created a few websites here and there so this isn't all that new with variables but still its tough