Jump to content
  • 0

How to limit one person per npc talk?


Talon

Question


  • Group:  Members
  • Topic Count:  24
  • Topics Per Day:  0.01
  • Content Count:  78
  • Reputation:   1
  • Joined:  09/01/14
  • Last Seen:  

I need help on a script that limits only one person talk to the npc once it's been using [progress bar casting], it's for my fishing game, but I'm not sure how can I make it works.. I've tried.. 

 

if (.using != 1){

set .using, 1;

 

it works when someone's talking to it, ...but this stopped all the duplicated NPCs once someone's using... and if the person walk away during un-finish progress, the NPC itself will be stopped functioning... So... I'm looking for a better scripts/ codes for this...  /ic

Please give me some tips if you have the knowledge for this?  /pat  Maybe strcharinfo(0), setnpctimer (getnpctimer(0) -15000); ??

Edited by Talon
Link to comment
Share on other sites

10 answers to this question

Recommended Posts


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  


if ( getd( ".npc_"+getnpcid(0) ) ) {

mes "NPC is busy now.";

}

else {

setd( ".npc_"+getnpcid(0) ),getcharid(3);

attachnpctimer;

initnpctimer;

mes "You using me.";

progressbar "0xFFFFFF",5;

mes "Done";

setd( ".npc_"+getnpcid(0) ),0;

stopnpctimer;

}

close;

OnTimer1000:

.@is_occupied = getd( ".npc_"+getnpcid(0) );

if ( .@is_occupied && .@is_occupied == playerattached() ) {

attachnpctimer;

initnpctimer;

}

else {

OnTimerQuit:

stopnpctimer;

setd( ".npc_"+getnpcid(0) ),0;

}

end;

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

The approach with NPC variables will work, but just make the variable name unique (probably using 'setd'/'getd'). For example, as long as the NPC's hidden name doesn't have spaces in it (ex. "Fishing#01"), you can do:

setd ".using"+strnpcinfo(2), x;
getd(".using"+strnpcinfo(2))
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

This can also be done with an array. Up to 128 npcs.

prontera,100,100,5	script	Fishing#0	100,{
	.@a = atoi( strnpcinfo(2) );
	if( .init[ .@a ] ) end;
	.init[ .@a ] = 1;
	progressbar "0xFF0000",5;
	getitem 501,1;
	.init[ .@a ] = 0;
}

prontera,101,100,5	duplicate(Fishing#0)	Fishing#1	100
prontera,102,100,5	duplicate(Fishing#0)	Fishing#2	100
prontera,103,100,5	duplicate(Fishing#0)	Fishing#3	100
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  24
  • Topics Per Day:  0.01
  • Content Count:  78
  • Reputation:   1
  • Joined:  09/01/14
  • Last Seen:  

Thanks for the replies guys, I'm still having issue on this, I've tested myself, this script still stopped the NPC being talkable when player cancelled the talk during progress bar loading...?

 

This can also be done with an array. Up to 128 npcs.

prontera,100,100,5	script	Fishing#0	100,{
	.@a = atoi( strnpcinfo(2) );
	if( .init[ .@a ] ) end;
	.init[ .@a ] = 1;
	progressbar "0xFF0000",5;
	getitem 501,1;
	.init[ .@a ] = 0;
}

prontera,101,100,5	duplicate(Fishing#0)	Fishing#1	100
prontera,102,100,5	duplicate(Fishing#0)	Fishing#2	100
prontera,103,100,5	duplicate(Fishing#0)	Fishing#3	100

Maybe a set timer will help this? Any idea? Sorry I'm still a learner :(

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  53
  • Topics Per Day:  0.01
  • Content Count:  411
  • Reputation:   261
  • Joined:  04/25/12
  • Last Seen:  

I need help on a script that limits only one person talk to the npc once it's been using [progress bar casting], it's for my fishing game, but I'm not sure how can I make it works.. I've tried.. 

 

if (.using != 1){

set .using, 1;

 

it works when someone's talking to it, ...but this stopped all the duplicated NPCs once someone's using... and if the person walk away during un-finish progress, the NPC itself will be stopped functioning... So... I'm looking for a better scripts/ codes for this...  /ic

Please give me some tips if you have the knowledge for this?  /pat  Maybe strcharinfo(0), setnpctimer (getnpctimer(0) -15000); ??

 

I don't know if this will work, cause I dont remeber if when PcLogout remember still the @

 
if(@spoke==1){
end;
}
if($spoke==1;){
mes "Only one person can talk with me!";
}else{
set @spoke,1;
set $spoke,1;
progressbar "0xFF0000",5;
sleep2 5000;
set $spoke,0;
set @spoke,0;
dispbottom "Fished!";
end;
}
end;
 
OnPCLogoutEvent:
if(@spoke==1){
set spoke,0;
set $spoke,0;
}
end;
 
OnInit:
set $spoke,0;
end;
Edited by Zell
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   76
  • Joined:  06/13/13
  • Last Seen:  

why don't you do pcblockmove to the player currently talking to npc ?

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

or maybe some trick like this ?? 

to avoid npc being occupied by 1 players just in case if they loged out accidently.

not working, refer last post


if ( getd( ".npc_"+getnpcid() ) ) {
	mes "NPC is busy now.";
}
else {
	setd( ".npc_"+getnpcid() ),getcharid(3);
	initnpctimer;
	mes "You using me.";
	progressbar "0xFFFFFF",5;
	mes "Done";
	setd( ".npc_"+getnpcid() ),0;
	stopnpctimer;
}
close;

OnTimer1000:
	.@is_occupied = getd( ".npc_"+getnpcid() );
	if ( .@is_occupied && .@is_occupied == playerattached() ) {
		initnpctimer;
	}
	else {
OnTimerQuit:
		stopnpctimer;
		setd( ".npc_"+getnpcid() ),0;
	}
	end;
	
  

i didnt test the script.

Edited by Emistry
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

or maybe some trick like this ?? 

to avoid npc being occupied by 1 players just in case if they loged out accidently.

 

i didnt test the script.

initnpctimer;

Doesn't automatically attach the player.

 

Also even if the player was attached it wouldn't matter because the timer is a different instance of that npc all together.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  24
  • Topics Per Day:  0.01
  • Content Count:  78
  • Reputation:   1
  • Joined:  09/01/14
  • Last Seen:  

why don't you do pcblockmove to the player currently talking to npc ?

I've tried pbblockmove won't work on progressbar, it will cancel the progress...

 

 

or maybe some trick like this ?? 

to avoid npc being occupied by 1 players just in case if they loged out accidently.


if ( getd( ".npc_"+getnpcid() ) ) {
	mes "NPC is busy now.";
}
else {
	setd( ".npc_"+getnpcid() ),getcharid(3);
	initnpctimer;
	mes "You using me.";
	progressbar "0xFFFFFF",5;
	mes "Done";
	setd( ".npc_"+getnpcid() ),0;
	stopnpctimer;
}
close;

OnTimer1000:
	.@is_occupied = getd( ".npc_"+getnpcid() );
	if ( .@is_occupied && .@is_occupied == playerattached() ) {
		initnpctimer;
	}
	else {
OnTimerQuit:
		stopnpctimer;
		setd( ".npc_"+getnpcid() ),0;
	}
	end;
	
 

i didnt test the script.

Something went wrong on this, copied from cmd

script error on npc/custom/fishing_test_v1.txt line 2

    parse_callfunc: not enough arguments, expected ','
     1 : {
*    2 : if ( getd( ".npc_"+getnpcid(')' ) ) {
     3 :        mes "NPC is busy now.";
 
 

 

 

I need help on a script that limits only one person talk to the npc once it's been using [progress bar casting], it's for my fishing game, but I'm not sure how can I make it works.. I've tried.. 

 

if (.using != 1){

set .using, 1;

 

it works when someone's talking to it, ...but this stopped all the duplicated NPCs once someone's using... and if the person walk away during un-finish progress, the NPC itself will be stopped functioning... So... I'm looking for a better scripts/ codes for this...  /ic

Please give me some tips if you have the knowledge for this?  /pat  Maybe strcharinfo(0), setnpctimer (getnpctimer(0) -15000); ??

 

I don't know if this will work, cause I dont remeber if when PcLogout remember still the @

 
if(@spoke==1){
end;
}
if($spoke==1;){
mes "Only one person can talk with me!";
}else{
set @spoke,1;
set $spoke,1;
progressbar "0xFF0000",5;
sleep2 5000;
set $spoke,0;
set @spoke,0;
dispbottom "Fished!";
end;
}
end;
 
OnPCLogoutEvent:
if(@spoke==1){
set spoke,0;
set $spoke,0;
}
end;
 
OnInit:
set $spoke,0;
end;

This one almost works, but progress bar will stop once the char walked away, I've tried with pcblockmove getcharid(3),1; it won't be able to move around but when I click away, progressbar stopped working. Char has to relog to fix...

 

Thanks for the replies guys, I'm still looking for solution /ic  

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  24
  • Topics Per Day:  0.01
  • Content Count:  78
  • Reputation:   1
  • Joined:  09/01/14
  • Last Seen:  

Thank you guys  /lv  I feel loved. It took me more than 5 hours to figured out yesterday, here's the scripts I've used.

if (getd(".using"+strnpcinfo(2))){
	message strcharinfo(0), "Using..";
	end;
}

// When fishing
setd ".using"+strnpcinfo(2), 1;
attachnpctimer;
initnpctimer;

// After a successful fish

setd ".using"+strnpcinfo(2),0;
stopnpctimer;


// And added something I didn't even know what it was.. but it does the job actually xDD, thanks for the tips, after combining them, it works somehow lol!...

OnTimer2000:
if (getd(".using"+strnpcinfo(2))){
setd ".using"+strnpcinfo(2),0;
stopnpctimer;
detachnpctimer;
}
end;

OnPCLogoutEvent:
if (getd(".using"+strnpcinfo(2))){
setd ".using"+strnpcinfo(2),0;
}
end;
 
OnInit:
setd ".using"+strnpcinfo(2),0;
end;

/ic  /ic  /ic  Many thanks!   /lv  /lv  /lv

 

Thanks to: Emistry, Skorm, Zell, Euphy and who helped me!

Edited by Talon
  • Upvote 1
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...