Shawn's NPC Help Thread.

Status
Not open for further replies.
Joined
Oct 15, 2008
Messages
2,898
Reaction score
1,131
Yes, I've decided to make one as well. Most of you know me as the main helper when it comes to NPCs. I have had a few names since joining RaGEZONE about 2 years ago. I was formerly DevonsDaddy, as well as bboy242. I started as a noob, and still consider myself a noob :) Basically, I'll be taking all requests on creating/fixing NPC scripts. Unlike the previously posted threads that were similar to this, I will be checking/working on this every day. Anyways, here are the requirements.


If you are asking me to fix your NPC script, you must:
  • Use [.php]NPC script here[./php] tags (remove the . in both)
  • Show the method of any method I ask if I need to see it to understand how it works
  • Show the bat error you get from talking to it
  • If no bat error is present, state where it messes up

If you are asking me to create an NPC for you, you must:
  • Give a detailed description of what you want it to do. This includes:
    1. What items are involved
    2. How many items are required to get the "prize"
    3. If it will be warping a single player, or a party
    4. Anything really that has to do with what the NPC should do
  • post any errors that occur from testing it after I finish the script

Regardless of me creating a script from nothing, or fixing another script, do not remove the credits I place on the script. I am not an asshole that removes others credits. If I fix a script, I state it was edited by me. I expect the same respect. Normally, I would be picky and ask people to at least give an attempt with their scripts first, but I won't for this thread. If you are one of those people that would like to try learning, here are a few places to learn NPCs, including a tutorial by me.


This thread is mainly for NPC scripts. I could attempt to help with other errors, but I will not promise I can help them get fixed. It's been a long time since I've had a test server running.

Alright people, get to beggin *cough* I mean... asking/requesting *cough*!!!


EDIT: Please do not edit your posts unless you are the last person that posted and are preventing a double post. By editing your posts, I am forced to sift through each reply, trying to remember what was last said, so I know if your post is updated or not. That's not something I want to, nor am interested in doing. Also, any script that I give you, before you test it, make sure you

@dispose


yourself first. Sometimes, a member will get a fully working script, then say it's not working because their character is still "stuck" from when they talked to their NPC. Then time is wasted because I have to look at the script again and verify if it has any problems and yea... save me a headache, will ya? :)
 
Last edited:
Npc's are scripted in Javascript with an extension of .js. The source coding are written in Java, with an obvious extension of .java. There are several tutorials on the subject if you wish to learn. Just refer to the first post in this thread, Shawn gives links to three of the best out there.
 
Upvote 0
hello shawn sorry if i bump old threads.
but i was wondering could you make an Item upgrader npc
where you can exchange 5 tetris for an low potetentional
25 tetris for big potentional
100 tetris for extreme potentional
this potentional works as follow
if you choose like low potentional you can choose an item of your choose and get random stats on it between 20-200
low potentional ( 20-200) the stats needs to be 20-200
big potentional( 200-100) the same story
Extreme potetentional( 1000-2000) the same again
the random stats is include weapon att and magic att so like
Work gloves : low potetentional : 50 all stats and 50 weapon att and magic att
i hope you cna make this and sorry if i bump old threads
 
Upvote 0
Hi Shawn
Could you help me check where i did wrong in this script i'm trying to make it work but when i tried it failed. If u could help me with my mistakes that would be appreciated and I need the cm to look for the Reborns, If u could add it in for me thanks!
PHP:
var status;

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection)
    if (mode == 1) {
        status++;
    }else{
        status--;
    }		

    if (status == 0) {
            cm.sendSimple("Hello. I am the Item Trader NPC! What would u like to do? Requirements for GM skills:10,000 Rebirth 1,000 Golden Eggs 1,000 Maple Golden Leafs 13537 Maple Leafs 25 vote points\r\n\#L0#Buy GM Skills#l\r\n\#L1#Nothing#l\r\n\#L2#Change Me Back to a beginner#l");
        } else if (selection == 0) {
    if  (cm.haveItem(4031284, 1000) && cm.haveItem(4001168, 1000) && cm.haveItem(4001126, 13537) && cm.getVotePoints() > 25) {
        cm.gainItem(4031284, -1000) && cm.gainItem(4001168, -1000) && cm.gainItem(4001126, -13537) && cm.setVotePoints(-25) && cm.changeJob(900);
        cm.sendOk("You have gained the skills! To Change Back go click the change me back to a beginner function");
        cm.dispose();
        } else if (selection == 1) {
		cm.sendOk("Alright, see ya! Come back if you want to trade items for GM skills! :)");
        cm.dispose();
        } else if (selection == 2) {
        cm.getJobId();
        if  (job == 900)  {
        cm.changeJobById(0);
        cm.sendOk("You have become a Beginner");
		cm.dispose();
        }
    }
}
 
Upvote 0
I don't think Shawn does this thread anymore. And it's a simple fix. Just advance the status when you make selections. There were also a lot of other errors, such as forgetting to end your commands with " ; " and having closing + ending brackets.

PHP:
var status = 0;

function start() {
	status = -1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		cm.dispose();
	} else {
		if (mode == 0) {
			cm.sendOk("Come back later then, when you are ready to talk ...");
			cm.dispose();
			return;
		}
		}
		if (mode == 1)
			status++;
		else
			status--;
	if (status == 0) {
            cm.sendSimple("Hello. I am the Item Trader NPC! What would u like to do? Requirements for GM skills:10,000 Rebirth 1,000 Golden Eggs 1,000 Maple Golden Leafs 13537 Maple Leafs 25 vote points\r\n\#L0#Buy GM Skills#l\r\n\#L1#Nothing#l\r\n\#L2#Change Me Back to a beginner#l");
    } else if (status == 1) {
	if (selection == 0) {
		if  (cm.haveItem(4031284, 1000) && cm.haveItem(4001168, 1000) && cm.haveItem(4001126, 13537) && cm.getVotePoints() >= 25) {
				cm.gainItem(4031284, -1000);
				cm.gainItem(4001168, -1000); 
				cm.gainItem(4001126, -13537);
				cm.setVotePoints(-25); 
				cm.changeJobById(900);
				cm.sendOk("You have gained the skills! To Change Back go click the change me back to a beginner function");
		}
    } else if (selection == 1) {
				cm.sendOk("Alright, see ya! Come back if you want to trade items for GM skills! :)");
    } else if (selection == 2) {
			if (cm.getJobId()==900) {
				cm.changeJobById(0);
				cm.sendOk("You have become a Beginner");
			}
		}
	cm.dispose();
	}
}
 
Upvote 0
Joined
Jun 23, 2012
Messages
554
Reaction score
70
PHP:
var status = 0;

function start() {
	status = -1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		cm.dispose();
	} else {
		if (mode == 0) {
			cm.sendOk("Come back later then, when you are ready to talk ...");
			cm.dispose();
			return;
		}
		}
		if (mode == 1)
			status++;
		else
			status--;
	if (status == 0) {
            cm.sendSimple("Hello. I am the Item Trader NPC! What would u like to do? Requirements for GM skills:10,000 Rebirth 1,000 Golden Eggs 1,000 Maple Golden Leafs 13537 Maple Leafs 25 vote points\r\n\#L0#Buy GM Skills#l\r\n\#L1#Nothing#l\r\n\#L2#Change Me Back to a beginner#l");
    } else if (status == 1) {
	if (selection == 0) {
		if  (cm.haveItem(4031284, 1000) && cm.haveItem(4001168, 1000) && cm.haveItem(4001126, 13537) && cm.getVotePoints() >= 25) {
				cm.gainItem(4031284, -1000);
				cm.gainItem(4001168, -1000); 
				cm.gainItem(4001126, -13537);
				cm.setVotePoints(-25); 
				cm.changeJobById(900);
				cm.sendOk("You have gained the skills! To Change Back go click the change me back to a beginner function");
		}
    } else if (selection == 1) {
				cm.sendOk("Alright, see ya! Come back if you want to trade items for GM skills! :)");
    } else if (selection == 2) {
			if (cm.getJobId()==900) {
				cm.changeJobById(0);
				cm.sendOk("You have become a Beginner");
			}
		}
	cm.dispose();
	}
}
 
Upvote 0
Hi Shawn
Could you help me check where i did wrong in this script i'm trying to make it work but when i tried it failed. If u could help me with my mistakes that would be appreciated and I need the cm to look for the Reborns, If u could add it in for me thanks!
PHP:
var status;

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection)
    if (mode == 1) {
        status++;
    }else{
        status--;
    }		

    if (status == 0) {
            cm.sendSimple("Hello. I am the Item Trader NPC! What would u like to do? Requirements for GM skills:10,000 Rebirth 1,000 Golden Eggs 1,000 Maple Golden Leafs 13537 Maple Leafs 25 vote points\r\n\#L0#Buy GM Skills#l\r\n\#L1#Nothing#l\r\n\#L2#Change Me Back to a beginner#l");
        } else if (selection == 0) {
    if  (cm.haveItem(4031284, 1000) && cm.haveItem(4001168, 1000) && cm.haveItem(4001126, 13537) && cm.getVotePoints() > 25) {
        cm.gainItem(4031284, -1000) && cm.gainItem(4001168, -1000) && cm.gainItem(4001126, -13537) && cm.setVotePoints(-25) && cm.changeJob(900);
        cm.sendOk("You have gained the skills! To Change Back go click the change me back to a beginner function");
        cm.dispose();
        } else if (selection == 1) {
		cm.sendOk("Alright, see ya! Come back if you want to trade items for GM skills! :)");
        cm.dispose();
        } else if (selection == 2) {
        cm.getJobId();
        if  (job == 900)  {
        cm.changeJobById(0);
        cm.sendOk("You have become a Beginner");
		cm.dispose();
        }
    }
}

Alright, first of all, rather than bringing up an old thread, just make your own next time. Second, I'm not 100% sure if the script I fixed would even work since I'm not sure that cm.haveItem(itemid, amount) exists, I can't remember, it's been awhile since I've made an NPC script. And what's the point of the check in the last selection? Does it really matter whether or not they're a GM if they wanna become the beginner class but whatever. Anyways, if it works awesome, otherwise make a new thread rather than posting in here.
PHP:
var status;

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == 1) {
		status++;
	} else {
		cm.dispose();
		return;
	}
    if (status == 0) {
		cm.sendSimple("Hello. I am the Item Trader NPC! What would u like to do? Requirements for GM skills:10,000 Rebirth 1,000 Golden Eggs 1,000 Maple Golden Leafs 13537 Maple Leafs 25 vote points\r\n\#L0#Buy GM Skills#l\r\n\#L1#Nothing#l\r\n\#L2#Change Me Back to a beginner#l");
	} else if (status == 1) {
		if (selection == 0) {
			if  (cm.haveItem(4031284, 1000) && cm.haveItem(4001168, 1000) && cm.haveItem(4001126, 13537) && cm.getVotePoints() > 25) {
				cm.gainItem(4031284, -1000);
				cm.gainItem(4001168, -1000);
				cm.gainItem(4001126, -13537);
				cm.setVotePoints(cm.getVotePoints() - 25);
				cm.changeJob(900);
				cm.sendOk("You have gained the skills! To Change Back go click the change me back to a beginner function");
				cm.dispose();
			} else {
				cm.sendOk("Please make sure you have all the items needed.");
				cm.dispose();
			}
        } else if (selection == 1) {
			cm.sendOk("Alright, see ya! Come back if you want to trade items for GM skills! :)");
			cm.dispose();
        } else if (selection == 2) {
			if (cm.getJobId() == 900)  {
				cm.changeJobById(0);
				cm.sendOk("You have become a Beginner");
				cm.dispose();
			} else {
				cm.sendOk("You must be the GM class to convert to a beginner.");
				cm.dispose();
			}
		}
    }
}
 
Upvote 0
Status
Not open for further replies.
Back