Jump to content
  • 0

Better performance for infinite loop


nguyenhuy123

Question


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  21
  • Reputation:   1
  • Joined:  08/24/19
  • Last Seen:  

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
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

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


-	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
  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  21
  • Reputation:   1
  • Joined:  08/24/19
  • Last Seen:  

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.

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