Thread: Wtf is wrong with my code?!?!?!?

Results 1 to 8 of 8
  1. #1 Wtf is wrong with my code?!?!?!? [ REP+ for (working) Help!!!!!] 
    Registered Member

    Join Date
    Jul 2007
    Posts
    268
    Thanks given
    0
    Thanks received
    1
    Rep Power
    101
    Hello there,

    I am using the Z508 base, I followed a tutorial for adding donator's, it worked out good and no error's everything works also, I wanted to increase the donator package to get more peaple to buy it.

    I am adding non-combat skills (Thieving, Woodcutting, Mining, ETC.) and I wanted that those could not be set wit the ::lvl id xpammount command...

    However I wanted that Donators could, So I changed this in my ::lvl id xpammount command:

    Code:
    			if (cmd[0].equals("lvl")) {
    				int level = Integer.parseInt(cmd[1]);
    				int experience = Integer.parseInt(cmd[2]);
    				if (p.rights >= 2) {
    					p.appendExperience(experience, level);
    					return;
    				}
    				if (p.wildernessZone(p.absX, p.absY)) {
    					p.getActionSender().sendMessage(p, "You cannot change levels while inside of the wilderness.");
    					return;
    				}
    				for (int e : p.equipment) {
    					if (e != -1) {
    						p.getActionSender().sendMessage(p, "You cannot be wearing any armour while changing stats.");
    						return;
    					}
    				}
    				if (cmd[2].contains("-")) {
    					return;
    				}
    				if (p.donator >= 0) {
    				if (!(level == 0 || level == 1 || level == 2 || level == 4 || level == 5 || level == 6));
    					p.getActionSender().sendMessage(p, "Only Donators' can level non-combat levels using the 'lvl' command!");
    					p.getActionSender().sendMessage(p, "They get 10M extra spending experiance for this, buy your Donator status today!");
    					return;
    				}
    				if (experience > p.spendingExperience) {
    					experience = p.spendingExperience;
    				}
    				int HPExperience = (int)Math.round((experience / 798) * 266);
    				boolean oldEXPSetting = p.getExperience;
    				p.getExperience = true;
    				p.appendExperience(experience, level);
    				p.appendExperience(HPExperience, 3);
    				p.getExperience = oldEXPSetting;
    				p.getActionSender().sendMessage(p, "You have just spent "+experience+".");
    				p.spendingExperience -= experience;
    				p.getActionSender().sendMessage(p, "You have "+p.spendingExperience+" spending experience remaining.");
    			}
    What did I do wrong in the code?

    Thanks for reading, Quik answer could be awesome!
    Reply With Quote  
     

  2. #2  
    Registered Member

    Join Date
    Jul 2007
    Posts
    268
    Thanks given
    0
    Thanks received
    1
    Rep Power
    101
    bump
    Reply With Quote  
     

  3. #3  
    Tierney
    Guest
    Don't bump threads its aginst rules...

    anyway, explain your problem, what is it that you need? Are there errors, or can normal players can do the command?
    Reply With Quote  
     

  4. #4  
    Registered Member

    Join Date
    Jul 2007
    Posts
    268
    Thanks given
    0
    Thanks received
    1
    Rep Power
    101
    sorry for no explanation here it comes:

    No errors, however it makes donators and normal players cant lvl combat or non-combat skills, and this is supossed to make that donators can set both, and that normal players only can set combat skills, and that normal players also cant set non-combat skills (thieving wc, mining etc.)
    Reply With Quote  
     

  5. #5  
    Meh. I can't code.

    Soulevoker's Avatar
    Join Date
    Sep 2007
    Age
    29
    Posts
    1,198
    Thanks given
    5
    Thanks received
    6
    Rep Power
    137
    Code:
                if (cmd[0].equals("lvl")) {
                    int level = Integer.parseInt(cmd[1]);
                    int experience = Integer.parseInt(cmd[2]);
                    if (p.rights >= 2) {
                        p.appendExperience(experience, level);
                        return;
                    }
                    if (p.wildernessZone(p.absX, p.absY)) {
                        p.getActionSender().sendMessage(p, "You cannot change levels while inside of the wilderness.");
                        return;
                    }
                    for (int e : p.equipment) {
                        if (e != -1) {
                            p.getActionSender().sendMessage(p, "You cannot be wearing any armour while changing stats.");
                            return;
                        }
                    }
                    if (cmd[2].contains("-")) {
                        return;
                    }
                    if (p.donator >= 0) {
                    if (p.donator == 0 && !(level == 0 || level == 1 || level == 2 || level == 4 || level == 5 || level == 6)) {
                        p.getActionSender().sendMessage(p, "Only Donators' can level non-combat levels using the 'lvl' command!");
                        p.getActionSender().sendMessage(p, "They get 10M extra spending experiance for this, buy your Donator status today!");
                        return;
                    }
                    if (experience > p.spendingExperience) {
                        experience = p.spendingExperience;
                    }
                        int HPExperience = (int)Math.round((experience / 798) * 266);
                        boolean oldEXPSetting = p.getExperience;
                        p.getExperience = true;
                        p.appendExperience(experience, level);
                        p.appendExperience(HPExperience, 3);
                        p.getExperience = oldEXPSetting;
                        p.getActionSender().sendMessage(p, "You have just spent "+experience+".");
                        p.spendingExperience -= experience;
                        p.getActionSender().sendMessage(p, "You have "+p.spendingExperience+" spending experience remaining.");
                    }
                }

    Reply With Quote  
     

  6. #6  
    Registered Member
    wreckless's Avatar
    Join Date
    Dec 2008
    Posts
    727
    Thanks given
    82
    Thanks received
    78
    Rep Power
    294
    I r no pro at this but I'm pretty sure you can't have two "if" statements next to each other.

    if (p.donator >= 0) {
    if (!(level == 0 || level == 1 || level == 2 || level == 4 || level == 5 || level == 6));

    p.getActionSender().sendMessage(p, "Only Donators' can level non-combat levels using the 'lvl' command!");
    p.getActionSender().sendMessage(p, "They get 10M extra spending experiance for this, buy your Donator status today!");
    return;
    }
    Reply With Quote  
     

  7. #7  
    Registered Member

    Join Date
    Jul 2007
    Posts
    268
    Thanks given
    0
    Thanks received
    1
    Rep Power
    101
    it doesnt give errors.
    Reply With Quote  
     

  8. #8  
    Meh. I can't code.

    Soulevoker's Avatar
    Join Date
    Sep 2007
    Age
    29
    Posts
    1,198
    Thanks given
    5
    Thanks received
    6
    Rep Power
    137
    dude you can have as many if statements as you want. and if statements within if statements... Use the code i posted.

    Reply With Quote  
     


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
  •