Jump to content
  • 0

Need help with this script


Kidlatsv

Question


  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  26
  • Reputation:   0
  • Joined:  09/19/17
  • Last Seen:  

I need help, obviously I SUCK at scripting, I made this and have been trying, for hours, to figure out what's wrong with it, so I need a little help.

Quote

mag_dun01,127,123,3    script    Dancing Flame    802,{
npctalk "Greetings, hero, please approach.";
    sleep 60000;
    end;

    mes "[Dancing Flame]";
    mes "I am a fire elemental, and I have a proposal for you, "+strcharinfo(0)+".";
    menu "What is it?",l_option1,"I don't have for this, sorry.",l_option2;
    close;

l_option2
        mes "[Dancing Flame]";
        mes "That's too bad, come back when you change your mind."
        close;

l_option1
        mes "[Dancing Flame]";
        mes "I know of thy quest to save Midgard and I wish to help you on your journey."
        next;
        mes "[Dancing Flame]";
        mes "In order to aid you I shall make a headgear imbued with some of my powers, which will surely be of great use to you."
        next;
        mes "["+strcharinfo(0)+":]";
        mes "What headgear would that be?";
        next;
        mes "[Dancing Flame]";
        mes "...a ^00c000Flaming Ten-Gallon hat^0000000.";
        next;
        mes "[Dancing Flame]";
        mes "It won't come for free though."
        next;
        mes "[Dancing Flame]";
        mes "I will need you to collect items which I require in order to make the headgear for you.";
        next;
        mes "["+strcharinfo(0)+".]";
        mes "What do you need?";
        next;
        mes "[Dancing Flame]";
        mes "I need the following items:"
        mes "^00FF00_______________________________^000000";
        mes "A Cowboy Hat;";
        mes "100 Live Coals;";
        mes "85 Burning Hearts;";
        mes "70 Burning Hairs;";
        mes "55 Burning Horseshoes;";
        mes "40 Flaming Hearts;";
        mes "25 Red Gemstones; and";
        mes "10 Shards of Fire Essences.";
        mes "Bring me these items and I sh-all make the headgear for you, now go.";
            set #10gallonstarted,1;
            close;

if (#10gallonstarted == 1) {
    mes "[Dancing Flame]";
    mes "You have returned, have you collected the items I require?"
    next;
    mes "["+strcharinfo(0)+".]";
    mes "Yes, I have!";
    next;
    mes "[Dancing Flame]";
    mes "Very well then, let's check...";
    next;
        if(countitem(2248) < 1) goto l_noitems;
        if(countitem(7098) < 100) goto l_noitems;
        if(countitem(7097) < 85) goto l_noitems;
        if(countitem(7122) < 70) goto l_noitems;
        if(countitem(7120) < 55) goto l_noitems;
        if(countitem(994) < 40) goto l_noitems;
        if(countitem(716) < 25) goto l_noitems;
        if(countitem(7426) < 10) goto l_noitems;
        delitem 2248,1;
        delitem 7098,100;
        delitem 7097,85;
        delitem 7122,70;
        delitem 7120,55;
        delitem 994,40;
        delitem 716,25;
        delitem 7426,10;
    mes "[Dancing Flame]";
    mes "Excellent, you have collected all that I require!";
    mes "May it serve you well.";
        getitem 18940,1;
    next;
    mes "[Dancing Flame]";
    mes "If you wish for me to make you another, all you have to do is bring me the required items again.";
    close;

l_noitems;
        "I'm sorry, but you need to collect more of the required items.";
        close;
    }

OnPCLoadMapEvent:
    showevent 1,0;
    end;
}

Please be gentle, and pardon the poor dialogue.

Edited by Kidlatsv
Link to comment
Share on other sites

13 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  626
  • Reputation:   188
  • Joined:  11/19/11
  • Last Seen:  

Let me guess it end when you talk to the npc without progressing further?

That's because you end it with you're npctalk, there was an command for that when an player is an area of I remember correctly, can't check it cuz I'm not at home at the moment. 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  26
  • Reputation:   0
  • Joined:  09/19/17
  • Last Seen:  

no, it won't even play out because the mapserver says there's a syntax error.

 

plus, this is not automatic conversation that I am trying to do, just the npc saying random stuff like a player saying something in general chat.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  626
  • Reputation:   188
  • Joined:  11/19/11
  • Last Seen:  

Oh, okay but could tell us which line it is about the syntax error, best would be an screenshot.

Edit: I think I saw you're errors:

L_option1 & 2 needs an : afterwards and l_noitems is an ; instead of :

Edit 2: After checking again I saw that in most of your mes there is an ; missing at the end.

Edit 3: Here is now the corrected script with some additional changes:
If I didn't miss an missing ; for an mes myself, it should work.

mag_dun01,127,123,3    script    Dancing Flame    802,{

    mes "[Dancing Flame]";
    mes "I am a fire elemental, and I have a proposal for you, "+strcharinfo(0)+".";
    menu "What is it?",l_option1,"I don't have for this, sorry.",l_option2;
    close;

    /* < Start of commented block, this will not be read by the server
    2nd Option and no need for labels here:
    if(select("What is it?:- I don't have time for this, sorry.") == 2) {
        mes "[Dancing Flame]";
        mes "That's too bad, come back when you change your mind.";
        close;
    
    }
    mes "[Dancing Flame]";
    mes "I know of thy quest to save Midgard and I wish to help you on your journey.";
    < Rest of the Code >
    */ // < End of commented block
    
l_option2:
        mes "[Dancing Flame]";
        mes "That's too bad, come back when you change your mind.";
        close;

l_option1:
        mes "[Dancing Flame]";
        mes "I know of thy quest to save Midgard and I wish to help you on your journey.";
        next;
        mes "[Dancing Flame]";
        mes "In order to aid you I shall make a headgear imbued with some of my powers, which will surely be of great use to you.";
        next;
        mes "["+strcharinfo(0)+":]";
        mes "What headgear would that be?";
        next;
        mes "[Dancing Flame]";
        mes "...a ^00c000Flaming Ten-Gallon hat^0000000.";
        next;
        mes "[Dancing Flame]";
        mes "It won't come for free though.";
        next;
        mes "[Dancing Flame]";
        mes "I will need you to collect items which I require in order to make the headgear for you.";
        next;
        mes "["+strcharinfo(0)+":]";
        mes "What do you need?";
        next;
        mes "[Dancing Flame]";
        mes "I need the following items:";
        mes "^00FF00_______________________________^000000";
        mes "A Cowboy Hat;";
        mes "100 Live Coals;";
        mes "85 Burning Hearts;";
        mes "70 Burning Hairs;";
        mes "55 Burning Horseshoes;";
        mes "40 Flaming Hearts;";
        mes "25 Red Gemstones; and";
        mes "10 Shards of Fire Essences.";
        mes "Bring me these items and I sh-all make the headgear for you, now go.";
            set #10gallonstarted,1;
            close;

if (#10gallonstarted == 1) {
    mes "[Dancing Flame]";
    mes "You have returned, have you collected the items I require?";
    next;
    mes "["+strcharinfo(0)+".]";
    mes "Yes, I have!";
    next;
    mes "[Dancing Flame]";
    mes "Very well then, let's check...";
    next;
        if(countitem(2248) < 1) goto l_noitems;
        if(countitem(7098) < 100) goto l_noitems;
        if(countitem(7097) < 85) goto l_noitems;
        if(countitem(7122) < 70) goto l_noitems;
        if(countitem(7120) < 55) goto l_noitems;
        if(countitem(994) < 40) goto l_noitems;
        if(countitem(716) < 25) goto l_noitems;
        if(countitem(7426) < 10) goto l_noitems;
        delitem 2248,1;
        delitem 7098,100;
        delitem 7097,85;
        delitem 7122,70;
        delitem 7120,55;
        delitem 994,40;
        delitem 716,25;
        delitem 7426,10;
    mes "[Dancing Flame]";
    mes "Excellent, you have collected all that I require!";
    mes "May it serve you well.";
        getitem 18940,1;
    next;
    mes "[Dancing Flame]";
    mes "If you wish for me to make you another, all you have to do is bring me the required items again.";
    close;

l_noitems:
        "I'm sorry, but you need to collect more of the required items.";
        close;
    }

OnPCLoadMapEvent:
    showevent 1,0;
    end;
    
// OnInit means that this will be executed on Server Start or @reloadscript
// while(1) is an loop and the one defines "true", because the () is like an if check
OnInit:
while(1) {
    npctalk "Greetings, hero, please approach.";
    sleep 60000;
}
end;

}

Edited by llchrisll
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  26
  • Reputation:   0
  • Joined:  09/19/17
  • Last Seen:  

Thank you! I'll test it as soon as I'm able.

I'm having trouble with syntax and when I should be placing { (squiggles?)

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  281
  • Reputation:   14
  • Joined:  10/14/13
  • Last Seen:  

On 10/4/2017 at 12:04 AM, Kidlatsv said:

I need help, obviously I SUCK at scripting, I made this and have been trying, for hours, to figure out what's wrong with it, so I need a little help.

Please be gentle, and pardon the poor dialogue.

 

@Kidlatsv Im not a good scripter but tried optimized your script a bit. I haven't tried to run it in-game.
I hope this solves your problem, good luck! ;)

mag_dun01,127,123,3	script	Dancing Flame	802,{
	if (!#10gallonstarted){
		mes .npc$;
		mes "I am a fire elemental, and I have a proposal for you, "+strcharinfo(0)+".";
		next;
		if (select("What is it?","I don't have for this, sorry.") != 1){
			mes .npc$;
			mes "That's too bad, come back when you change your mind.";
			close;
		}
		mes .npc$;
		mes "I know of thy quest to save Midgard and I wish to help you on your journey.";
		next;
		mes .npc$;
		mes "In order to aid you I shall make a headgear imbued with some of my powers, which will surely be of great use to you.";
		next;
		mes "["+strcharinfo(0)+":]";
		mes "What headgear would that be?";
		next;
		mes .npc$;
		mes "...a ^00c000"+getitemname(.rewardid)+"^0000000.";
		next;
		mes .npc$;
		mes "It won't come for free though.";
		next;
		mes .npc$;
		mes "I will need you to collect items which I require in order to make the headgear for you.";
		next;
		mes "["+strcharinfo(0)+".]";
		mes "What do you need?";
		next;
		mes .npc$;
		mes "I need the following items:";
		mes "^00FF00_______________________________^000000";
		for ( .@i = 0; .@i < getarraysize(.require); .@i += 2 ){
			mes .require[.@i+1]+" "+getitemname(.require[.@i]);
		}
		mes "Bring me these items and I sh-all make the headgear for you, now go.";
		#10gallonstarted = 1;
		close;
	}
	mes .npc$;
	mes "You have returned, have you collected the items I require?";
	next;
	mes "["+strcharinfo(0)+".]";
	mes "Yes, I have!";
	next;
	mes .npc$;
	mes "Very well then, let's check...";
	next;
	for ( .@i = 0; .@i < getarraysize(.require); .@i += 2 ){
		if (countitem(.require[.@i]) < .require[.@i+1]){
			.@count++;
		}
	}
	if (.@count){
		mes "I'm sorry, but you need to collect more of the required items.";
		close;
	}
	for ( .@j = 0; .@j < getarraysize(.require); .@j += 2 ){
		delitem .require[.@j], .require[.@j+1];
	}
	mes .npc$;
	mes "Excellent, you have collected all that I require!";
	mes "May it serve you well.";
	getitem .rewardid, 1;
	next;
	mes .npc$;
	mes "If you wish for me to make you another, all you have to do is bring me the required items again.";
	close;


OnPCLoadMapEvent:
    showevent 1,0;
    end;
	
OnInit:
	// CONFIGURATION
	// set this to your npc name
	.npc$ = "[Dancing Flame]";
	
	// set this to your reward item id
	.rewardid = 18940;
	
	// item requirements syntax: <item id>, <item amount>, <item id>, <item amount>,...
	setarray .require[0], 2248, 1, 7098, 100, 7097, 85, 7122, 70, 7120, 55, 994, 40, 716, 25, 7426, 10;
	
	while(1){
		npctalk "Greetings, hero, please approach.";
		sleep2 60000;
	}
	end;
}

 

Edited by Aureon
change sleep to sleep2
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  26
  • Reputation:   0
  • Joined:  09/19/17
  • Last Seen:  

Thank you guys a lot for the help, I really appreciate it, I'm actually learning a lot right now about how to script and optimization.

@Aureon, I'll try yours ASAP, the shorter a script gets, the better :D

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  626
  • Reputation:   188
  • Joined:  11/19/11
  • Last Seen:  

6 minutes ago, Kidlatsv said:

Thank you guys a lot for the help, I really appreciate it, I'm actually learning a lot right now about how to script and optimization.

@Aureon, I'll try yours ASAP, the shorter a script gets, the better :D

Well I was  about to the same but giving an optimized script all of hidden in case you wouldn't understand wouldn't be good, I guess.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  26
  • Reputation:   0
  • Joined:  09/19/17
  • Last Seen:  

I understand most of the changes, except for these parts, I read the documentation but can't really understand it:

 

for ( .@i = 0; .@i < getarraysize(.require); .@i += 2 ){
			mes .require[.@i+1]+" "+getitemname(.require[.@i]);

and this part especially:

	for ( .@j = 0; .@j < getarraysize(.require); .@j += 2 ){
		delitem .require[.@j], .require[.@j+1];
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  80
  • Reputation:   1
  • Joined:  10/08/13
  • Last Seen:  

The first is a for loop that is iterating through the array of required items to check that you have the required items and the correct amount. If you don’t have all of the required it’s its going to display the message that you still require some items.

If everything checks out in the first for loop it will move on to the second one which is going to iterate through the array and del the required item and the amount from your inventory

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  626
  • Reputation:   188
  • Joined:  11/19/11
  • Last Seen:  

31 minutes ago, Kidlatsv said:

I understand most of the changes, except for these parts, I read the documentation but can't really understand it:

 


for ( .@i = 0; .@i < getarraysize(.require); .@i += 2 ){
			mes .require[.@i+1]+" "+getitemname(.require[.@i]);

and this part especially:


	for ( .@j = 0; .@j < getarraysize(.require); .@j += 2 ){
		delitem .require[.@j], .require[.@j+1];

For is like the while, an loop, .require is the array which was set in OnInit and holds the requirements for the exchange. With for() he goes through that array and let it read the content of it and delete the items when everything is collected.

Edit: Oceanid was faster ;).

Edited by llchrisll
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  26
  • Reputation:   0
  • Joined:  09/19/17
  • Last Seen:  

Thank you a lot guys, really, you were of great help!

last question, when do I place a these  {   }  that's the remaining thing I really REALLY don't get.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  281
  • Reputation:   14
  • Joined:  10/14/13
  • Last Seen:  

4 minutes ago, Kidlatsv said:

Thank you a lot guys, really, you were of great help!

last question, when do I place a these  {   }  that's the remaining thing I really REALLY don't get.

I suggest you to read this part ;) 
thispartanswerswhen and thispartanswershow

  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  26
  • Reputation:   0
  • Joined:  09/19/17
  • Last Seen:  

I love you

1 minute ago, Aureon said:

I suggest you to read this part ;) 
thispartanswerswhen and thispartanswershow

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...