Thread: Extremly simple tutorial. Allowing disallowing members/non-members.

Results 1 to 10 of 10
  1. #1 Extremly simple tutorial. Allowing disallowing members/non-members. 
    The Lemon
    Guest
    This tutorial is extremely easy and will allow you to deny access to someone who isn't/is a member on your server. Very simple and made for newbies didn't see one so i thought i'd post. Read on if you need this, don't bother if you don't as it's that simple.

    Description:
    Explaining how and when to use if statements for commands.

    Difficulty: 0.1/10

    Assumed Knowledge: To be able to read.

    Tested Server:
    Devolution, will work on all.

    Files/Classes Modified:
    client.java

    Result:
    To be able to define what player group you want to access certain features of the server.

    Lots of people have been asking me about this so i thought id post, havent seen any other tutorials on it.
    This also may clarify a few things you didn't know before.

    Ok, first off ill explain what these things do.
    Code:
    if (playerIsMember == 1);
    This piece of code will check if the player is a member, and should be put before the method or process.

    Eg.

    Code:
    if (playerIsMember == 1); // The if statement will check the players status
          sendMessage("Congratulations, You are a member!") //The message
          } else 
          sendMessage("Sorry, your not currently a member.") //The else message
    This is exactly the same when you want to write your own admin only command, it checks the player rights.

    Code:
    if (playerRights == 3); //The player rights check
    	sendMessage("Congratulations, your an owner") // The success message
    	{ 
    	if (playerRights == 2); // The next check
    	 sendMessage("Congratulations, your an admin") // Message
    	{ 
    	if (playerRights == 1); // Next check
    	sendMessage("Nope, your only a moderator") // Message
    	} else 
    	sendMessage("Ouch your a noob") // The message
    I know it's longwinded and the code wont even work in context, its to help people understand what these things do in the process before the final outcome you see in the game.

    Thanks, positive comments only. Did this in a rush so please post if their are fixes to be made.
     

  2. #2  
    Simon :)
    Guest
    Thanks this will explain Elses and other things to me.
     

  3. #3  
    Member #35, most veteran member left? :D


    Join Date
    Jul 2006
    Age
    27
    Posts
    2,663
    Thanks given
    53
    Thanks received
    331
    Rep Power
    925
    For the love of God, please read this and redo your code: [Only registered and activated users can see links. ]

    Also, why the hell did you use break;? You could just use another curly brace (AKA '}').

    Description: Adding Player Following
    ORLY? I SMEEL LIES.

    ++ Teh JaVa Expert ++
    U SHUR?
    [Only registered and activated users can see links. ]

    `Ex-global moderator x3 (resigned)
     

  4. #4  
    The Lemon
    Guest
    Quote Originally Posted by Runite View Post
    For the love of God, please read this and redo your code: [Only registered and activated users can see links. ]

    Also, why the hell did you use break;? You could just use another curly brace (AKA '}').


    ORLY? I SMEEL LIES.
    I fixed the things, as i said did in a rush. Also, you can't use tab whilst writing code in this. And i didn't know all the correct alignment.
     

  5. #5  
    Member #35, most veteran member left? :D


    Join Date
    Jul 2006
    Age
    27
    Posts
    2,663
    Thanks given
    53
    Thanks received
    331
    Rep Power
    925
    Quote Originally Posted by `Alex` View Post
    I fixed the things, as i said did in a rush. Also, you can't use tab whilst writing code in this. And i didn't know all the correct alignment.
    *points to a random text editor, such as Notepad*

    Edit: And you said you fixed the indents, but really it's almost worse in a way.
    [Only registered and activated users can see links. ]

    `Ex-global moderator x3 (resigned)
     

  6. #6  
    The Lemon
    Guest
    Quote Originally Posted by Runite View Post
    *points to a random text editor, such as Notepad*
    Yeh, ok let me copy into their and fix..
     

  7. #7  
    Member #35, most veteran member left? :D


    Join Date
    Jul 2006
    Age
    27
    Posts
    2,663
    Thanks given
    53
    Thanks received
    331
    Rep Power
    925
    Quote Originally Posted by `Alex` View Post
    Yeh, ok let me copy into their and fix..
    Nope, still bad. Look at the example I just added to my tutorial...

    Code:
    public String INTACOURSE() {
    	if(sex) {
    		return "WOO SEX!";
    	} else {
    		return "NO SEX :(";
    	}
    	//hay look dis is all indented
    }
    [Only registered and activated users can see links. ]

    `Ex-global moderator x3 (resigned)
     

  8. #8  
    Registered Member
    Join Date
    Jun 2008
    Posts
    211
    Thanks given
    8
    Thanks received
    0
    Rep Power
    1
    howecome whenever someone is member, when they log out and log in, they arent a member anymore? i need to know how to keep them a member when they log out and log in. ty
     

  9. #9  
    Member #35, most veteran member left? :D


    Join Date
    Jul 2006
    Age
    27
    Posts
    2,663
    Thanks given
    53
    Thanks received
    331
    Rep Power
    925
    Quote Originally Posted by titans321 View Post
    howecome whenever someone is member, when they log out and log in, they arent a member anymore? i need to know how to keep them a member when they log out and log in. ty
    Did you make the value of the variable that states whether or not the player is a member save?
    [Only registered and activated users can see links. ]

    `Ex-global moderator x3 (resigned)
     

  10. #10  
    The Lemon
    Guest
    Are you getting that after adding this? because it isnt a tutorial that works, it just explains. To make someone a member you must change their Character-ismember = 1.

    Or make a command that writes playerIsMember = 1 to their character file.
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •