[Solved][HELP] NPC Script

Status
Not open for further replies.
Socius Decennalis
Decennium
Joined
Apr 25, 2010
Messages
489
Reaction score
58
Could you help me? I know the text is in another language, most tried everything else ever speaks missing something, but I m I created something wrong? Code below, very precise. ;/

PHP:
/*
 * @autor JavaScriptz ;3
 * LeaderMS 2012
 * NPC - xx
 * Pet System
 */

// Variaveis
var servidor = "#bLeaderMS#k";
var leaderpoints = 0;
var tetris = 0;
var whitre = 0;
var status = 0;
var votePoints = 0;
// Fim

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

function action(mode, type, selection) {
    if (mode == -1) {
        cm.dispose();
    } else {
        if (mode == 0 && status == 0) {
            cm.dispose();

        }
        if (mode == 1)
            status++;
        else
            status--;
        if (status == 0) {
        cm.sendYesNo("Ola #b#h ##k, eu sou o #bPet System #k do " + servidor + ".\r\nGostaria de adquirir algum pet?\r\n\r\n#rLembrando que e necessario#k \r\n#bTetris#k - " + tetris + "\r\n#bVotePoints#k - " + votePoints + "\r\n#bLeaderPonts#k - " + leaderpoints + "\r\n#bWhitre Scroll#k - " + whitre + "\r\n\r\n#eDeseja prosseguir com sua compra?");
        }
        else if (status == 1) {
        cm.sendSimple("Por favor, escolha o pet.#b\r\n#L0##v5000000# - #bBrown Kitty \r\n#L1##v5000001# - #bBrown Puppy\r\n#L2##v5000002# - #bPink Bunny\r\n#L3##v5000003# - #bMini Kargo\r\n#L4##v5000004# - #bBlack Kitty\r\n#L5##v5000079# - #bBlack Kitty\r\n#L6##v5000005# - #bWhite Bunny\r\n#L7##v5000006# - #bHusky\r\n#L8##v5000007# - #bBlack Pig\r\n#L9##v5000008# - #bPanda\r\n#L10##v5000009# - #bDino Boy\r\n#L11##v5000010# - #bDino Girl\r\n#L12##v5000011# - #bMonkey\r\n#L13##v5000078# - #bMonkey\r\n#L14##v5000012# - #bWhite Tiger");

         } else if (status == 2) {
            if (selection === 0) {
                if(cm.getLeaderPoints() >= leaderpoints && cm.getVotePoints() <= votePoints && cm.haveItem(4030002, tetris) && cm.haveItem(2340000, whitre)){
                    cm.gainLeaderPoints(-leaderpoints); // Remove leaderpoints
                    cm.gainItem(4030002, -tetris); // Remove Tetris
                    cm.gainItem(2340000, -whitre); // Remove Write
                    cm.setVotePoints(-votePoints); // Remove Votes Points
                    cm.gainItem(5000000, 1); // Entrega pet (Brown Kitty)
                    cm.sendOk("Obrigado , aproveite seu novo item no " + servidor + ".");
                } else {
                cm.sendOk("Desculpe, voce nao tem todos o items necessarios!");
                cm.dispose();
                }

            } else {
                cm.sendOk("Tudo bem, volte mais tarde.");
                cm.dispose();

                }
            }
         }
      }
 
Last edited by a moderator:
Re: [HELP] NPC Script

What is the error you get?

If it's incorrect it will give a error telling you which line when trying to execute it.
 
Upvote 0
Re: [HELP] NPC Script

Well to be honest, this script is pretty bad.

Way to big, should use arrays to make it much more easier and better.
I personally am not going to read through that book up there (script) but there must be something there comes up, check your bat.
 
Upvote 0
Re: [HELP] NPC Script

Well to be honest, this script is pretty bad.

Way to big, should use arrays to make it much more easier and better.
I personally am not going to read through that book up there (script) but there must be something there comes up, check your bat.

Explaining.

Well in my ide not appear any error in the code.
However when I'm in the game I click the NPC, with all necessary items to get a pet, it returns me with the message:
                 Else {}
                 cm.sendOk ("Sorry, you do not have all the items needed!");
                 cm.dispose ();

I wonder if the code is wrong, why have all items.
And I'm sorry for the bad language.
 
Upvote 0
Re: [HELP] NPC Script

Well if it says that then the code is truly screwed, so many syntex errors that are not meant to be there.

I truly would just tell you to re-write the script, and use arrays, and maybe you're learn from your mistakes. I could do the script for you but then you learn nothing and I have no intentions of feeding you when you could learn.

But a little hint, check where you place "{, }" it's wrong, add a few ";" to where they're meant to be.
 
Upvote 0
Re: [HELP] NPC Script

Lol MacRS, you couldn't have just helped him? Literally nothing you said was useful. Just saying "check .bat" and "use arrays" helps WAY less than fixing his script. Also, had you just looked over his script, you would have seen the errors and it really wasn't very hard to fix.

Here you go Gabriel.
PHP:
status = 0;
servidor = "#bLeaderMS#k";
leaderpoints = 0;
tetris = 0;
whitre = 0;
votePoints = 0;

function start() {
	cm.sendYesNo("Ola #b#h ##k, eu sou o #bPet System #k do " + servidor + ".\r\nGostaria de adquirir algum pet?\r\n\r\n#rLembrando que e necessario#k \r\n#bTetris#k - " + tetris + "\r\n#bVotePoints#k - " + votePoints + "\r\n#bLeaderPonts#k - " + leaderpoints + "\r\n#bWhitre Scroll#k - " + whitre + "\r\n\r\n#eDeseja prosseguir com sua compra?");
}

function action(mode, type, selection) {
	status++;
	if (mode != 1) {
		cm.dispose();
		return;
	}
	if (status == 1) {
		cm.sendSimple("Por favor, escolha o pet.#b\r\n#L0##v5000000# - #bBrown Kitty \r\n#L1##v5000001# - #bBrown Puppy\r\n#L2##v5000002# - #bPink Bunny\r\n#L3##v5000003# - #bMini Kargo\r\n#L4##v5000004# - #bBlack Kitty\r\n#L5##v5000079# - #bBlack Kitty\r\n#L6##v5000005# - #bWhite Bunny\r\n#L7##v5000006# - #bHusky\r\n#L8##v5000007# - #bBlack Pig\r\n#L9##v5000008# - #bPanda\r\n#L10##v5000009# - #bDino Boy\r\n#L11##v5000010# - #bDino Girl\r\n#L12##v5000011# - #bMonkey\r\n#L13##v5000078# - #bMonkey\r\n#L14##v5000012# - #bWhite Tiger");
	} else if (status == 2) {
		if (cm.getLeaderPoints() >= leaderpoints && cm.getVotePoints() >= votePoints && cm.haveItem(4030002, tetris) && cm.haveItem(2340000, whitre) && cm.canHold(5000000)) {
			var pets = [5000000, 5000001, 5000002, 5000003, 5000004, 5000079, 5000005, 5000006, 5000007, 5000008, 5000009, 5000010, 5000011, 5000078, 5000012];
			cm.gainLeaderPoints(-leaderpoints); // Remove Leaderpoints
			cm.gainItem(4030002, -tetris); // Remove Tetris
            cm.gainItem(2340000, -whitre); // Remove Write
            cm.setVotePoints((cm.getPlayer().getVotePoints() - votePoints)); // Remove Votes Points
			cm.gainItem(pets[selection]); // Entrega pet
			cm.sendOk("Obrigado , aproveite seu novo item no " + servidor + ".");
		} else {
			cm.sendOk("Desculpe, voce nao tem todos o items necessarios!");
		}
		cm.dispose();
	}
}

If by some fat chance it doesn't work, try to post here with as much detail regarding the broken part as you can, hopefully somebody will help you then. lol.
 
Upvote 0
Re: [HELP] NPC Script

What I said in the above post could of helped lol. What I said was the errors.
Using arrays for such a large script like this would of been better anyway.

But I did read some of it, and the errors were easy but I'm not going to spoon the guy. Should just try give them hints so they have some idea how to fix it alone.

Simple fix, but also a way for him to learn how to fix basic errors.
 
Upvote 0
Re: [HELP] NPC Script

Lol MacRS, you couldn't have just helped him? Literally nothing you said was useful. Just saying "check .bat" and "use arrays" helps WAY less than fixing his script. Also, had you just looked over his script, you would have seen the errors and it really wasn't very hard to fix.

Here you go Gabriel.
PHP:
status = 0;
servidor = "#bLeaderMS#k";
leaderpoints = 0;
tetris = 0;
whitre = 0;
votePoints = 0;

function start() {
	cm.sendYesNo("Ola #b#h ##k, eu sou o #bPet System #k do " + servidor + ".\r\nGostaria de adquirir algum pet?\r\n\r\n#rLembrando que e necessario#k \r\n#bTetris#k - " + tetris + "\r\n#bVotePoints#k - " + votePoints + "\r\n#bLeaderPonts#k - " + leaderpoints + "\r\n#bWhitre Scroll#k - " + whitre + "\r\n\r\n#eDeseja prosseguir com sua compra?");
}

function action(mode, type, selection) {
	status++;
	if (mode != 1) {
		cm.dispose();
		return;
	}
	if (status == 1) {
		cm.sendSimple("Por favor, escolha o pet.#b\r\n#L0##v5000000# - #bBrown Kitty \r\n#L1##v5000001# - #bBrown Puppy\r\n#L2##v5000002# - #bPink Bunny\r\n#L3##v5000003# - #bMini Kargo\r\n#L4##v5000004# - #bBlack Kitty\r\n#L5##v5000079# - #bBlack Kitty\r\n#L6##v5000005# - #bWhite Bunny\r\n#L7##v5000006# - #bHusky\r\n#L8##v5000007# - #bBlack Pig\r\n#L9##v5000008# - #bPanda\r\n#L10##v5000009# - #bDino Boy\r\n#L11##v5000010# - #bDino Girl\r\n#L12##v5000011# - #bMonkey\r\n#L13##v5000078# - #bMonkey\r\n#L14##v5000012# - #bWhite Tiger");
	} else if (status == 2) {
		if (cm.getLeaderPoints() >= leaderpoints && cm.getVotePoints() >= votePoints && cm.haveItem(4030002, tetris) && cm.haveItem(2340000, whitre) && cm.canHold(5000000)) {
			var pets = [5000000, 5000001, 5000002, 5000003, 5000004, 5000079, 5000005, 5000006, 5000007, 5000008, 5000009, 5000010, 5000011, 5000078, 5000012];
			cm.gainLeaderPoints(-leaderpoints); // Remove Leaderpoints
			cm.gainItem(4030002, -tetris); // Remove Tetris
            cm.gainItem(2340000, -whitre); // Remove Write
            cm.setVotePoints((cm.getPlayer().getVotePoints() - votePoints)); // Remove Votes Points
			cm.gainItem(pets[selection]); // Entrega pet
			cm.sendOk("Obrigado , aproveite seu novo item no " + servidor + ".");
		} else {
			cm.sendOk("Desculpe, voce nao tem todos o items necessarios!");
		}
		cm.dispose();
	}
}

If by some fat chance it doesn't work, try to post here with as much detail regarding the broken part as you can, hopefully somebody will help you then. lol.

Yes it works thank you, I am not very good with arrays, so that no pardon VotePoints unlike when I get change ..
 
Upvote 0
Status
Not open for further replies.
Back