Delete this thread.

Status
Not open for further replies.
Re: Single Job Changing NPC

It doesn't seem like this script would work. Honestly, even though it doesn't look as neat as having no brackets, I still prefer adding them just so I can organize everything easier. Also, in this script, you can go back to your second job after reaching level 120 which isn't that big of a deal, just something I thought I'd point out. If you want it to job advance as they go along. Just use a cm.sendYesNo in the start function, then have the checks in the action function and do the work from there.
 
Upvote 0
Re: Single Job Changing NPC

PHP:
/**
--------------------------------
Server:
	Ragezone
--------------------------------
NPC Title:
	Job Advance Script
--------------------------------
Created by:
	Ryuuzi~
--------------------------------
Version:
	1.0 - Script Started
--------------------------------
**/

var level = cm.getPlayer().getLevel();
var no = "You cannot job advance using this NPC.";

function start() {
	cm.sendYesNo("Congrats on reaching #bLevel " + level + "#k. Would you like to job advance?");
}

function action(mode, type, selection) {
    if (mode != 1) {
		cm.sendOk("I see. Well come back when you decide to Job Advance.");
		cm.dispose();
		return;
	} else {
		if (level >= 10 && level < 30) {
			if (cm.getPlayer().getJobById() == 0) {
				cm.changeJobById(501);
				cm.getPlayer().dropMessage("You have reached the First Job Advancement. Congrats.");
				cm.dispose();
			} else {
				cm.sendOk(no);
				cm.dispose();
			}
		} else if (level >= 30 && level < 70) {
			if (cm.getPlayer().getJobById() == 501) {
				cm.changeJobById(530);
				cm.getPlayer().dropMessage("You have reached the Second Job Advancement. Congrats.");
				cm.dispose();
			} else {
				cm.sendOk(no);
				cm.dispose();
			}
		} else if (level >= 70 && level < 120) {
			if (cm.getPlayer().getJobById() == 530) {
				cm.changeJobById(531);
				cm.getPlayer().dropMessage("You have reached the Third Job Advancement. Congrats.");
				cm.dispose();
			} else {
				cm.sendOk(no);
				cm.dispose();
			}
		} else if (level >= 120) {
			if (cm.getPlayer().getJobId() == 531) {
				cm.changeJobById(532);
				cm.getPlayer().dropMessage("You have reached the Fourth Job Advancement. Congrats.");
				cm.dispose();
			} else {
				cm.sendOk(no);
				cm.dispose();
			}
		}
	}
}

Untested. If it doesn't work, post the bat errors here. And leave the credits. And yes, I know this script can be made much much simpler.
In an attempt for anyone that says that here, I made a second script that's "shorter" although I don't see the point in it.

PHP:
/**
--------------------------------
Server:
	Ragezone
--------------------------------
NPC Title:
	Job Advance Script
--------------------------------
Created by:
	Ryuuzi~
--------------------------------
Version:
	1.0 - Script Started
--------------------------------
**/

var jobs = [[0, 501, 530, 531], [501, 530, 531, 532]];
var level = [10, 30, 70, 120];
var newJob;

function start() {
	while (var i < jobs[0].length) {
		if ((jobs[0][i] == cm.getPlayer().getJobId()) && (jobs[1][i] != cm.getPlayer().getJobId()) && (jobs[1][i] > cm.getPlayer().getJobId()) && (level[i] <= cm.getPlayer.getLevel())) {
			newJob = jobs[1][i];
		}
		i++;
	}
	cm.changeJobById(newJob);
	cm.dropMessage("You have made a Job Advancement.");
	cm.dispose();
}

Side Note - Don't know if either of the scripts work, but it was worth a shot.
 
Upvote 0
Re: Single Job Changing NPC

On the 2nd script heres the error :
syntax error ((unknown source)#22) in (unknown source) at line number 22

On the 1st script heres the error :
"cm" is not defined. ((Unknown source)#17) in (Unknown source) at line number 17.
 
Upvote 0
Re: Single Job Changing NPC

On the 1st script heres the error :
"cm" is not defined. ((Unknown source)#17) in (Unknown source) at line number 17.

harhar. Mmmk, pretty much delete var level and replace everything that says level with cm.getLevel if you have that method, otherwise replace it with cm.getPlayer().getLevel()
 
Upvote 0
Re: Single Job Changing NPC

NPCConversationManager:
PHP:
    private static final int FIRST_JOB = 0, SECOND_JOB = 1, THIRD_JOB = 2, FOURTH_JOB = 3, **** = 4;
    public String advance()
    {
        int currJob = this.getJobId();
        int changeTo;
        String job = "";
        if (currJob == 0 || currJob == 1000 || currJob == 3000 || currJob == 3001 || (currJob >= 2000 && currJob <= 2003))
        { //**** YOU BEGINNER
            switch (currJob)
            {
                case 0:
                case 1000:
                case 3000:
                    return "Choose your destiny first!";
                case 2000: //Aran
                    changeTo = 2100;
                    this.changeJobById(changeTo);
                    return "Congratulations! You've advanced to 1st job as a " + this.getJobName(changeTo) + "!";
                case 2001: //Evan
                    changeTo = 2200;
                    this.changeJobById(changeTo);
                    return "Congratulations! You've advanced to 1st job as a " + this.getJobName(changeTo) + "!";
                case 2002: //Mercedes
                    changeTo = 2300;
                    this.changeJobById(changeTo);
                    return "Congratulations! You've advanced to 1st job as a " + this.getJobName(changeTo) + "!";
                case 2003: //Phantom
                    changeTo = 2400;
                    this.changeJobById(changeTo);
                    return "Congratulations! You've advanced to 1st job as a " + this.getJobName(changeTo) + "!";
                case 3001: //Demon Slayer
                    changeTo = 3100;
                    this.changeJobById(changeTo);
                    return "Congratulations! You've advanced to 1st job as a " + this.getJobName(changeTo) + "!";
            }
        }
        if ((currJob > 0 && currJob < 2200) || (currJob > 2218)) //Excluding Evan
        {
            switch (getJobType())
            {
                case FIRST_JOB:
                    if (currJob > 0 && currJob <= 500) //adventurers
                    {
                        return "**** you noob, what 2nd job do you want?";
                    } else {
                        if (currJob != 501) //Cannoneer
                        {
                            changeTo = currJob + 10;
                            this.changeJobById(changeTo);
                        } else {
                            changeTo = currJob + 29;
                            this.changeJobById(changeTo);
                        }
                        return "Congratulations! You've advanced to 2nd job as a " + this.getJobName(changeTo) + "!";
                    }
                case SECOND_JOB:
                    changeTo = currJob + 1;
                    this.changeJobById(changeTo);
                    return "Congratulations! You've advanced to 3rd job as a " + this.getJobName(changeTo) + "!";
                case THIRD_JOB:
                    changeTo = currJob + 1;
                    this.changeJobById(changeTo);
                    return "Congratulations! You've advanced to 4th job as a " + this.getJobName(changeTo) + "!";
                case FOURTH_JOB:
                    return "Silly noob, you can't advance hahahaha.";
                case ****:
                    return "HACKER.";
                default:
                    this.changeJobById(0);
                    return "STUPID NOOOBBBB";
            }
        } else {
            if (currJob < 2218)
            {
                changeTo = currJob + 1;
                this.changeJobById(changeTo);
                return "Congratulations! You've advanced to " + this.getJobName(changeTo) + "!";
            } else {
                return "Silly noob, you can't advance hahahaha.";
            }
        }
    }
    
    private int getJobType()
    {
        String job = this.getJobId() +"";
        if (job.endsWith("00") || job.equals("501"))
        {
            return FIRST_JOB;
        } else if (job.endsWith("10") || job.endsWith("20") || job.endsWith("30")) {
            return SECOND_JOB;
        } else if (job.endsWith("11") || job.endsWith("21") || job.endsWith("31")) {
            return THIRD_JOB;
        } else if (job.endsWith("12") || job.endsWith("22") || job.endsWith("32")) {
            return FOURTH_JOB;
        }
        return ****;
    }

cm.sendOk(cm.advance());
 
Upvote 0
Re: Single Job Changing NPC

@Above
It's good you are providing him scripts to use, but his original inquiry was if his script would work; and if it wouldn't he probably wants us to explain to him why not.

Here's an explanation on why it would not work:
PHP:
function start() {
    cm.sendSimple("Would you like to become a #r Cannoneer? \r\n #L0# 1st Job Cannoneer #l \r\n #L1# 2nd Job Cannoneer #l \r\n #L2# 3rd Job Cannoneer #l \r\n #L3# 4th Job Cannoneer #l");
}

function action(mode, type, selection) {
    if (mode == 1) { // Don't know if this is corre3ct mode for continue chat, but I'll assume it is.
        if (selection == 0) // Should use brackets here, even though they wouldn't be necessary after closing the brackets after this; it's just a good coding habit.
			if (cm.getPlayer().getLevel() == 10) { // Open bracket but never close. Also if they are over level 10 they cannot become 1st job.
            cm.changeJob([501]); // Don't need the brackets; those are only used in terms of arrays. Also, I'm pretty sure the method is cm.changeJobById(int);
        else if (selection == 1)
			if (cm.getPlayer().getLevel() >= 30) { // Same here
            cm.changeJob([530]);
        else if (selection == 2)
			if (cm.getPlayer().getLevel() >= 70) { // Same; but closed incorrectly
            cm.changeJob([531]);
        else if (selection == 3)
			if (cm.getPlayer().getLevel() >= 120) {
            cm.changeJob([532]);
    }
    cm.dispose();
}

And here's what it would look like simply fixing your errors:

PHP:
function start() {
    cm.sendSimple("Would you like to become a #r Cannoneer? \r\n #L0# 1st Job Cannoneer #l \r\n #L1# 2nd Job Cannoneer #l \r\n #L2# 3rd Job Cannoneer #l \r\n #L3# 4th Job Cannoneer #l");
}

function action(mode, type, selection) {
    if (mode == 1) {
        if (selection == 0) {
			if (cm.getPlayer().getLevel() >= 10) {
				cm.changeJobById(501); 
			}
        } else if (selection == 1) {
			if (cm.getPlayer().getLevel() >= 30) {
				cm.changeJobById(530);
			}
        } else if (selection == 2) {
			if (cm.getPlayer().getLevel() >= 70) {
				cm.changeJobById(531);
			}
        } else if (selection == 3) {
			if (cm.getPlayer().getLevel() >= 120) {
				cm.changeJobById(532);
			}
		}
    }
    cm.dispose();
}

Though, it would be better to add checks and shorten. I.E:
PHP:
stuff = [[10, 0, 501], [30, 501, 530], [70, 530, 531], [120, 531, 532]];

function start() {
    cm.sendSimple("Would you like to become a #r Cannoneer? \r\n #L0# 1st Job Cannoneer #l \r\n #L1# 2nd Job Cannoneer #l \r\n #L2# 3rd Job Cannoneer #l \r\n #L3# 4th Job Cannoneer #l");
}

function action(mode, type, selection) {
    if (mode == 1) {
		if (cm.getPlayer().getLevel() >= stuff[selection][0] && cm.getPlayer().getJob().getId() == stuff[selection][1]) {
			cm.changeJob(stuff[selection][2]);
		} else {
			cm.sendOk(" Sorry.. you are either not a high enough level or you havn't made the previous job advancement. ");
		}
	}
	cm.dispose();
}
 
Upvote 0
Re: [Updated] Cannoneer Job Changing Player Command

I think it might just be easier if I used a player command similar to celino's for cannon job advance.
 
Upvote 0
Status
Not open for further replies.
Back