Template NPC

Newbie Spellweaver
Joined
May 13, 2008
Messages
90
Reaction score
4

This NPC is based on a NPC providing information.

​
Screen Shots​
tk7kyle - Template NPC - RaGEZONE Forums
The Script​
PHP:
//Choices
var text0 = "Text 0";
var text1 = "Text 1";
var text2 = "Text 2";
var text3 = "Text 3";
var text4 = "Text 4";
var text5 = "Text 5";
var text6 = "Text 6";
var text7 = "Text 7";
var text8 = "Text 8";
var text9 = "Text 9";
var text10 = "Text 10";
//Selected text
var selection0 = "Selection 0";
var selection1 = "Selection 1";
var selection2 = "Selection 2";
var selection3 = "Selection 3";
var selection4 = "Selection 4";
var selection5 = "Selection 5";
var selection6 = "Selection 6";
var selection7 = "Selection 7";
var selection8 = "Selection 8";
var selection9 = "Selection 9";
var selection10 = "Selection 10";
//other text
var status0text = "Status 0 text";
var status1text = "Status 1 text";
//Shouldn't Have to go pass this line.
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.sendNext(status0text);
    } else if (status == 1) {
        cm.sendSimple(""+status1text+"\r\n\r\n#L0#"+text0+"#l\r\n#L1#"+text1+"#l\r\n#L2#"+text2+"#l\r\n#L3#"+text3+"#l\r\n#L4#"+text4+"#l\r\n#L5#"+text5+"#l\r\n#L6#"+text6+"#l\r\n#L7#"+text7+"#l\r\n#L8#"+text8+"#l\r\n#L9#"+text9+"#l\r\n#L10#"+text10+"#l");
    } else if (status == 2) {
        if (selection == 0) {
            cm.sendOk(selection0);
            cm.dispose();
        }else if (selection == 1) {
            cm.sendOk(selection1);
            cm.dispose();
        }else if (selection == 2) {
            cm.sendOk(selection2);
            cm.dispose();
        }else if (selection == 3) {
            cm.sendOk(selection3);
            cm.dispose();
        }else if (selection == 4) {
            cm.sendOk(selection4);
            cm.dispose();
        }else if (selection == 5) {
            cm.sendOk(selection5);
            cm.dispose();
        }else if (selection == 6) {
            cm.sendOk(selection6);
            cm.dispose();
        }else if (selection == 7) {
            cm.sendOk(selection7);
            cm.dispose();
        }else if (selection == 8) {
            cm.sendOk(selection8);
            cm.dispose();
        }else if (selection == 9) {
            cm.sendOk(selection9);
            cm.dispose();
        }else if (selection == 10) {
            cm.sendOk(selection10);
            cm.dispose();
        }
    }else{
cm.dispose();
}
}
How to Edit​
Choices, self explanitory
Selected Text, if choice 3 is chosen, selected text 3 will be shown.
Status0text, the first text you will see when clicking the npc.
Status1text, the text above choices you will see when the choices are shown.
If you wanted to add more, it doesn't take a genius. If you own a brain you should be able to read the script and add as many as you want. Same thing if you ant to remove.
​
Thanks or leave a nice comment if you like :D
 
Sorry... typically I don't agree with invading someones' releases, but...

PHP:
var talk = new Array("talk 0", "talk 1", "talk 2", "talk 3", "talk 4", "talk 5", "talk 6", "talk 7", "talk 8", "talk 9", "talk 10");
var choice = new Array("Selection 0", "Selection 1", "Selection 2", "Selection 3", "Selection 4", "Selection 5", "Selection 6", "Selection 7", "Selection 8", "Selection 9", "Selection 10");
var openTalk = "Status 0 talk";
var nextTalk = "Status 1 talk";
status = 0;
function start() {
    cm.sendNext(openTalk);
}

function action(m,t,s) {
    if (m > 0)
        status++;
    else{
        cm.dispose();
		return;
    }
    if (status == 1) {
		var say = ""+nextTalk+"\r\n\r\n";
		for (var i=0;i<talk.length;i++)
			say += "#L"+i+"#"+talk[i]+"#l\r\n";
        cm.sendSimple(say);
    } else if (status == 2) {
		cm.sendOk(choice[s]);
		cm.dispose();
	}
}

It's so much cleaner this way.
 
Last edited:
I thought it was just easier when you have it going vertical.

In that case, here...

PHP:
var talk = new Array(
	"talk 0", 
	"talk 1", 
	"talk 2", 
	"talk 3", 
	"talk 4", 
	"talk 5", 
	"talk 6", 
	"talk 7", 
	"talk 8", 
	"talk 9", 
	"talk 10");
var choice = new Array(
	"Selection 0", 
	"Selection 1", 
	"Selection 2", 
	"Selection 3", 
	"Selection 4", 
	"Selection 5", 
	"Selection 6", 
	"Selection 7", 
	"Selection 8", 
	"Selection 9", 
	"Selection 10");
var openTalk = "Status 0 talk";
var nextTalk = "Status 1 talk";
status = 0;
function start() {
    cm.sendNext(openTalk);
}

function action(m,t,s) {
    if (m > 0)
        status++;
    else{
        cm.dispose();
        return;
    }
    if (status == 1) {
        var say = ""+nextTalk+"\r\n\r\n";
        for (var i=0;i<talk.length;i++)
            say += "#L"+i+"#"+talk[i]+"#l\r\n";
        cm.sendSimple(say);
    } else if (status == 2) {
        cm.sendOk(choice[s]);
        cm.dispose();
    }
}

You can use this as your release if you'd like.
 
ok what your failing to understand is. if you want to take something out or add something in. you have to do way way more work to take it out.

now if you did it in the array form, you just have to add a ',' and then add the text you want and it updates accordingly.
 
ok what your failing to understand is. if you want to take something out or add something in. you have to do way way more work to take it out.

now if you did it in the array form, you just have to add a ',' and then add the text you want and it updates accordingly.

Well, to be honest, it's just as easy to edit his as it is with mine. The only major difference is mine is half the size. His is still just as easy to edit simply because all you'd need to do is edit the strings attached to the variables. His script has 22 variables, mine has 4.
 
i never do good ****, ****.
Don't think like that, everyone has a way to shine to the world.
This is a good release, cause its a first release Ive seen with this topic, this will help out many Npc scripters and more, so you should thank yourself for bringing this up, ,any new people would be thanking you for this <3
Yours Truly, iAkira:8:
 
Haven't tested, should works.

Anyhow, this template is not based in shortening his code, but, to give more options.

typeAndTalk array variable defines in left side, the style of chat, and in the right one, the chat that will appear in his designed chat style.

AmountOfChats variable tells how much this will be done.

So fuckign simple, eh? :D

PHP:
typeAndTalk = [[cm.sendNext, "talk"], [cm.sendPrev, "talk"], [cm.sendNextPrev,  "text"], [cm.sendSimple, "text"], [cm.sendGetNumber, "text"], [cm.sendGetText, "text"], [cm.sendYesNo, "talk"], [cm.sendAcceptDecline, "talk"]];
amountOfChats = 5;
status = 0;

function start() {
    typeAndTalk[status][0](typeAndTalk[status][1]);
}

function action(mode ,type ,selection) {
    status++;
	if (mode == 0 && type == 0){
	    status -= 2;
	}
	if (status == 0) {
	    start();
		return;
	} else if (mode != 1){
	    if(mode == 0 && type != 4)
		    cm.sendNext("Bye.");
		cm.dispose();
        return;
	}
    if (status < amountOfChats) {
	    typeAndTalk[status][0](typeAndTalk[status][1]);
    } else
	    cm.dispose();
}
 
Last edited:
Back