• 0
Sign in to follow this  
nguyenhuy123

Better performance for infinite loop

Question

Hi all, currently im using this piece of code to do infinite loop that show a permanent effect on npc. I wonder if this way is good for performance if i duplicate many npc like this in an instance( about 50 each instance)? If not, is there anyway better than this (coding and not edit the map as i want to flexible in changing the position)?

 

-	script	Dump	HIDDEN_WARP_NPC,{ 
	OnInstanceInit:
		while(1) {
			disablenpc(instance_npcname(strnpcinfo(0)));
			sleep 130;
			enablenpc(instance_npcname(strnpcinfo(0)));
			misceffect 696;
			sleep rand(150,250);
		}
}

 

Edited by nguyenhuy123

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

-	script	effect_timer_npc	HIDDEN_WARP_NPC,{
	OnTimer1000:
		donpcevent "::OnEffect696"; // will trigger all npc that has this event label
	OnInit:
		initnpctimer;
		end;
}

-	script	effect_npc	HIDDEN_WARP_NPC,{ 
	OnEffect696:
		enablenpc(strnpcinfo(3));
		misceffect 696;
		sleep rand(150,250);
		disablenpc(strnpcinfo(3));
		end;
}

prontera,1,1,4	duplicate(effect_npc)	#effect_npc_1	HIDDEN_WARP_NPC
prontera,1,1,4	duplicate(effect_npc)	#effect_npc_2	HIDDEN_WARP_NPC
prontera,1,1,4	duplicate(effect_npc)	#effect_npc_3	HIDDEN_WARP_NPC

 

  • Upvote 2

Share this post


Link to post
Share on other sites
  • 0
On 12/4/2019 at 12:39 PM, Emistry said:

-	script	effect_timer_npc	HIDDEN_WARP_NPC,{
	OnTimer1000:
		donpcevent "::OnEffect696"; // will trigger all npc that has this event label
	OnInit:
		initnpctimer;
		end;
}

-	script	effect_npc	HIDDEN_WARP_NPC,{ 
	OnEffect696:
		enablenpc(strnpcinfo(3));
		misceffect 696;
		sleep rand(150,250);
		disablenpc(strnpcinfo(3));
		end;
}

prontera,1,1,4	duplicate(effect_npc)	#effect_npc_1	HIDDEN_WARP_NPC
prontera,1,1,4	duplicate(effect_npc)	#effect_npc_2	HIDDEN_WARP_NPC
prontera,1,1,4	duplicate(effect_npc)	#effect_npc_3	HIDDEN_WARP_NPC

 

Thanks @Emistry, this way is so clever.

Share this post


Link to post
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.

Loading...
Sign in to follow this