Jump to content
  • 0

Need Help my collector item script


hendra814

Question


  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  1167
  • Reputation:   159
  • Joined:  06/12/12
  • Last Seen:  

Need help, everytime player report to npc

item failed to be deleted and player not given the reward too.

here the scipt

Spoiler

prontera,164,219,4	script	Collector	116,{

oninit:
set .itemrew,0;
set .itemrewq,0;
set .itemcoll,0;
set .itemquan,0;

if (getgmlevel()>60) goto admin;
if (.help == 1) goto reward;


mes "Welcome "+strcharinfo(0)+",";
mes "I'm Collector rune midgard item";
switch(select("What item do you collect:Ok, nice to meet you")) {
	case 1:
	next;
	if (.itemcoll == 0) { mes "Sorry, I'm not collecting item for now."; end;}
	mes "please collect "+getitemname(.itemcoll)+" for "+.itemquan +" pcs.";
	mes "and i will reward you "+getitemname(.itemrew)+" for "+.itemrewq +" pcs.";
	set .help,1;
	end;
	
	case 2:
	next;
	mes "Okay, see you later.";
	end;
}

reward:
	set .amounts, countitem(.itemcoll);
	if ( .amounts!= .itemquan) {mes "the quantity item not enough.";}
	mes "Thanks for your help";
	mes "here my reward for you.";
	delitem .itemcoll,.itemquan;
	getitem .itemrew,itemrewq;
	set help,0;
	end;
	
admin:
mes "Welcome "+strcharinfo(0)+",";
mes "Please input what item for player to collect.";
next;
input .itemcoll;
set .itemcoll,.itemcoll;
next;
mes "Please input how many item to collect.";
next;
input .itemquan;
set .itemquan,.itemquan;
next;
mes "Please input what the reward item.";
input .itemrew;
set .itemrew,.itemrew;
next;
mes "Please input how many item reward.";
input .itemrewq;
set .itemrewq,.itemrewq;
next;
mes "Are you done?";
switch(select("Yes:No.")) {
	case 1:
	mes "Item to collect "+getitemname(.itemcoll)+" for "+.itemquan +" pcs.";
	mes "Item reward "+getitemname(.itemrew)+" for "+.itemrewq +" pcs.";
	end;
	
	case 2:
	mes "Okay, to re entry, please start form the begining.";
	end;
}
}

 

 

and here the error

image.png.db1f1d8ab432c6fd55793232a98e6db8.png

and is it posible to make this npc running for x period, like 1 day or 1 week

Thanks for any help

Edited by hendra814
Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • 0

  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   702
  • Joined:  12/21/14
  • Last Seen:  

at the first script 

getitem .itemrew,itemrewq;

it's .itemrewq not itemrewq 




prontera,164,219,4	script	Collector	116,{
	if (getgmlevel()>60) goto admin;
	if (.help == 1) goto reward;
	mes "Welcome "+strcharinfo(0)+",";
	mes "I'm Collector rune midgard item";
	switch(select("What item do you collect:Ok, nice to meet you")) {
		case 1:
		next;
		if (.itemcoll == 0) { mes "Sorry, I'm not collecting item for now."; end;}
		mes "please collect "+getitemname(.itemcoll)+" for "+.itemquan +" pcs.";
		mes "and i will reward you "+getitemname(.itemrew)+" for "+.itemrewq +" pcs.";
		set .help,1;
		end;
		
		case 2:
		next;
		mes "Okay, see you later.";
		end;
	}
	
reward:
	set .amounts, countitem(.itemcoll);
	if ( .amounts <= .itemquan) {mes "the quantity item not enough.";}
	mes "Thanks for your help";
	mes "here my reward for you.";
	delitem .itemcoll,.itemquan;
	getitem .itemrew,.itemrewq;
	set help,0;
end;
	
admin:
	mes "Welcome "+strcharinfo(0)+",";
	mes "Please input what item for player to collect.";
	next;
	input .itemcoll;
	//set .itemcoll,.itemcoll;
	next;
	mes "Please input how many item to collect.";
	next;
	input .itemquan;
	//set .itemquan,.itemquan;
	next;
	mes "Please input what the reward item.";
	input .itemrew;
	//set .itemrew,.itemrew;
	next;
	mes "Please input how many item reward.";
	input .itemrewq;
	//set .itemrewq,.itemrewq;
	next;
	mes "Are you done?";
	switch(select("Yes:No.")) {
		case 1:
		mes "Item to collect "+getitemname(.itemcoll)+" for "+.itemquan +" pcs.";
		mes "Item reward "+getitemname(.itemrew)+" for "+.itemrewq +" pcs.";
		end;
		
		case 2:
		mes "Okay, to re entry, please start form the begining.";
		end;
	}
end;

OnInit:
	set .itemrew,0;
	set .itemrewq,0;
	set .itemcoll,0;
	set .itemquan,0;
end;
}

 

Edited by sader1992
  • MVP 1
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

set .@amounts, countitem(.itemcoll);
if ( .@amounts!= .itemquan) {mes "the quantity item not enough.";}
//
input .@itemcoll; // changed to npc variable
set .itemcoll,.@itemcoll;
next;
input .@itemquan;
set .itemquan,.@itemquan;
next;
mes "Please input what the reward item.";
input .@itemrew;
set .itemrew,.@itemrew;
next;
mes "Please input how many item reward.";
input .@itemrewq;
set .itemrewq,.@itemrewq;

OnInit: //For dummy data
	set .itemcoll,771; //ID Maybe?
	set .itemquan,1;
	set .itemrew,1;
	set .itemrewq,2;

 

Edited by crazyarashi
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  1167
  • Reputation:   159
  • Joined:  06/12/12
  • Last Seen:  

1 hour ago, crazyarashi said:

set .@amounts, countitem(.itemcoll);
if ( .@amounts!= .itemquan) {mes "the quantity item not enough.";}
//
input .@itemcoll; // changed to npc variable
set .itemcoll,.@itemcoll;
next;
input .@itemquan;
set .itemquan,.@itemquan;
next;
mes "Please input what the reward item.";
input .@itemrew;
set .itemrew,.@itemrew;
next;
mes "Please input how many item reward.";
input .@itemrewq;
set .itemrewq,.@itemrewq;

OnInit: //For dummy data
	set .itemcoll,771; //ID Maybe?
	set .itemquan,1;
	set .itemrew,1;
	set .itemrewq,2;

 

new problem can't countitem from variable .itemcoll

in doc_script countitem script only for item id or item name.

any idea to solve thie problem?

Spoiler

prontera,164,219,4	script	Collector	116,{

set .amounts, countitem(".itemcoll");

if (getgmlevel()>60) goto admin;
if (.help == 1) goto reward;

mes "Welcome "+strcharinfo(0)+",";
mes "I'm Collector rune midgard item";
switch(select("What item do you collect:Ok, nice to meet you")) {
	case 1:
	next;
	if (.itemcoll == 0) { mes "Sorry, I'm not collecting item for now."; end;}
	mes "please collect "+getitemname(.itemcoll)+" for "+.itemquan +" pcs.";
	mes "and i will reward you "+getitemname(.itemrew)+" for "+.itemrewq +" pcs.";
	set .help,1;
	end;
	
	case 2:
	next;
	mes "Okay, see you later.";
	end;
}

reward:
	if ( .amounts != .itemquan) {mes "the quantity item not enough."; end;}
	mes "Thanks for your help";
	mes "here my reward for you.";
	delitem .itemcoll,.itemquan;
	getitem .itemrew,itemrewq;
	set help,0;
	end;
	
admin:
mes "Welcome "+strcharinfo(0)+",";
mes "Please input what item for player to collect.";
next;
input ivalue;
set .itemcoll, ivalue;
next;
mes "Please input how many item to collect.";
next;
input ivalueq;
set .itemquan, ivalueq;
next;
mes "Please input what the reward item.";
input rvalue;
set .itemrew, rvalue;
next;
mes "Please input how many item reward.";
input rvalueq;
set .itemrewq, rvalueq;
next;
mes "Are you done?";
switch(select("Yes:No.")) {
	case 1:
	mes "Item to collect "+getitemname(.itemcoll)+" for "+.itemquan +" pcs.";
	mes "Item reward "+getitemname(.itemrew)+" for "+.itemrewq +" pcs.";
	end;
	
	case 2:
	mes "Okay, to re entry, please start form the begining.";
	end;
}
oninit:
set .itemcoll,7539; //item to collect
set .itemquan,1;	//item collect quantity
set .itemrew,7539;	//item reward
set .itemrewq,10;	//item reward quantity
}

 

 

Edited by hendra814
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  1167
  • Reputation:   159
  • Joined:  06/12/12
  • Last Seen:  

5 minutes ago, sader1992 said:

at the first script 


getitem .itemrew,itemrewq;

it's .itemrewq not itemrewq 

 

@sader1992

Thanks for this.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  1167
  • Reputation:   159
  • Joined:  06/12/12
  • Last Seen:  

6 hours ago, sader1992 said:

at the first script 


getitem .itemrew,itemrewq;

it's .itemrewq not itemrewq 





prontera,164,219,4	script	Collector	116,{
	if (getgmlevel()>60) goto admin;
	if (.help == 1) goto reward;
	mes "Welcome "+strcharinfo(0)+",";
	mes "I'm Collector rune midgard item";
	switch(select("What item do you collect:Ok, nice to meet you")) {
		case 1:
		next;
		if (.itemcoll == 0) { mes "Sorry, I'm not collecting item for now."; end;}
		mes "please collect "+getitemname(.itemcoll)+" for "+.itemquan +" pcs.";
		mes "and i will reward you "+getitemname(.itemrew)+" for "+.itemrewq +" pcs.";
		set .help,1;
		end;
		
		case 2:
		next;
		mes "Okay, see you later.";
		end;
	}
	
reward:
	set .amounts, countitem(.itemcoll);
	if ( .amounts <= .itemquan) {mes "the quantity item not enough.";}
	mes "Thanks for your help";
	mes "here my reward for you.";
	delitem .itemcoll,.itemquan;
	getitem .itemrew,.itemrewq;
	set help,0;
end;
	
admin:
	mes "Welcome "+strcharinfo(0)+",";
	mes "Please input what item for player to collect.";
	next;
	input .itemcoll;
	//set .itemcoll,.itemcoll;
	next;
	mes "Please input how many item to collect.";
	next;
	input .itemquan;
	//set .itemquan,.itemquan;
	next;
	mes "Please input what the reward item.";
	input .itemrew;
	//set .itemrew,.itemrew;
	next;
	mes "Please input how many item reward.";
	input .itemrewq;
	//set .itemrewq,.itemrewq;
	next;
	mes "Are you done?";
	switch(select("Yes:No.")) {
		case 1:
		mes "Item to collect "+getitemname(.itemcoll)+" for "+.itemquan +" pcs.";
		mes "Item reward "+getitemname(.itemrew)+" for "+.itemrewq +" pcs.";
		end;
		
		case 2:
		mes "Okay, to re entry, please start form the begining.";
		end;
	}
end;

OnInit:
	set .itemrew,0;
	set .itemrewq,0;
	set .itemcoll,0;
	set .itemquan,0;
end;
}

 

Need small fixing

set help,0; fix into set .help,0;

but it's okay. over all the script run like i want.

Thank you very much Sader.

Link to comment
Share on other sites

  • 0

  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   702
  • Joined:  12/21/14
  • Last Seen:  

2 hours ago, hendra814 said:

set help,0; fix into set .help,0;

you welcome

i would suggest changing .help to help

.help = npc variable << so .help for you is the same .help for every player (if your .help 500 then every player have it 500)

help = char variable << this are unique for each character

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  1167
  • Reputation:   159
  • Joined:  06/12/12
  • Last Seen:  

6 hours ago, sader1992 said:

you welcome

i would suggest changing .help to help

.help = npc variable << so .help for you is the same .help for every player (if your .help 500 then every player have it 500)

help = char variable << this are unique for each character

so i must change all .help into help right?

Link to comment
Share on other sites

  • 0

  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   702
  • Joined:  12/21/14
  • Last Seen:  

11 minutes ago, hendra814 said:

so i must change all .help into help right?

yes

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  1167
  • Reputation:   159
  • Joined:  06/12/12
  • Last Seen:  

2 hours ago, sader1992 said:

yes

ok, i already change and add some modification

here my lastest script

Spoiler

prontera,164,219,4	script	Collector	116,{
	if (getgmlevel()>60) goto admin;
	if (help == 1) goto reward;
	mes "Welcome "+strcharinfo(0)+",";
	mes "I'm Collector rune midgard item";
	switch(select("What item do you collect:Ok, nice to meet you")) {
		case 1:
		next;
		if (.itemcoll == 0) { mes "Sorry, I'm not collecting item for now."; end;}
		mes "Please collect "+getitemname(.itemcoll)+" for "+.itemquan +" pcs.";
		mes "and i will reward you "+getitemname(.itemrew)+" for "+.itemrewq +" pcs.";
		mes "Are you could help me to collect the items?";
		switch(select("Ok, I'll help you:Sorry, i couldn't help you")) {
			case 1:
			next;
			mes "Thank you very much";
			mes "I'll waiting for you come again";
			set help,1;
			end;

			case 2:
			next;
			mes "Okay, see you later.";
			end;
		}
		
		case 2:
		next;
		mes "Okay, see you later.";
		end;
	}
	
reward:
	mes "Welcome "+strcharinfo(0)+",";
	mes "are you already collect the items?";
	switch(select("Yes, here the items:Sorry, i want abort the request")) {
		case 1:
		next;
		set .amounts, countitem(.itemcoll);
		if ( .amounts < .itemquan) {mes "the quantity item not enough.";end;}
		mes "Thanks for your help";
		mes "here my reward for you.";
		delitem .itemcoll,.itemquan;
		getitem .itemrew,.itemrewq;
		set help,0;
		end;
		
		case 2:
		mes "Okay, see you later.";
		set help,0;
		end;
	}
	
admin:
	mes "Welcome "+strcharinfo(0)+",";
	mes "Choose what are you want to do";
	switch(select("input item to collect and reward:View summary")) {
		case 1:
		mes "Please input what item for player to collect.";
		next;
		input .itemcoll;
		next;
		mes "Please input how many item to collect.";
		next;
		input .itemquan;
		next;
		mes "Please input what the reward item.";
		input .itemrew;
		next;
		mes "Please input how many item reward.";
		input .itemrewq;
		next;
		mes "Are you done?";
		switch(select("Yes:No.")) {
			case 1:
			next;
			mes "Item to collect "+getitemname(.itemcoll)+" for "+.itemquan +" pcs.";
			mes "Item reward "+getitemname(.itemrew)+" for "+.itemrewq +" pcs.";
			end;
			
			case 2:
			mes "Okay, to re entry, please start form the begining.";
			end;
		}

		case 2:
		next;
		mes "Item to collect "+getitemname(.itemcoll)+" for "+.itemquan +" pcs.";
		mes "Item reward "+getitemname(.itemrew)+" for "+.itemrewq +" pcs.";
		end;
	}
end;

OnInit:
	set .itemrew,0;
	set .itemrewq,0;
	set .itemcoll,0;
	set .itemquan,0;
end;
}

 

 

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

  • 0

  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   702
  • Joined:  12/21/14
  • Last Seen:  

just on line 39

set .amounts, countitem(.itemcoll);
if ( .amounts < .itemquan) 

to

if ( countitem(.itemcoll) < .itemquan) 

or

set .@amounts, countitem(.itemcoll);
if ( .@amounts < .itemquan) 

the first one may do a problem if 2 players speak with the npc at the same time

Link to comment
Share on other sites

  • 0

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

Just a small personal opinion, but I would use for 2 menu options an if(select()) like:

if(select("Yes:No") == 1) {
	//Yes
	} else {
	//No
	}

Better than using an switch, but like I said, personal opinion. ?

Regards,

Chris

Edited by llchrisll
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  1167
  • Reputation:   159
  • Joined:  06/12/12
  • Last Seen:  

On 9/28/2017 at 9:17 PM, sader1992 said:

just on line 39


set .amounts, countitem(.itemcoll);
if ( .amounts < .itemquan) 

to


if ( countitem(.itemcoll) < .itemquan) 

or


set .@amounts, countitem(.itemcoll);
if ( .@amounts < .itemquan) 

the first one may do a problem if 2 players speak with the npc at the same time

Thanks @sader for already change it.

On 9/28/2017 at 9:30 PM, llchrisll said:

Just a small personal opinion, but I would use for 2 menu options an if(select()) like:


if(select("Yes:No") == 1) {
	//Yes
	} else {
	//No
	}

Better than using an switch, but like I said, personal opinion. ?

Regards,

Chris

ok will try it.

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...