Trade and Item to NPC 
		
		
		Here is my script I have worked a few hours one and cannot seem to get it to work. The NPC will not respond to 'Refuse' nor will he give an item when selected. The potions; however, work fine. Any help would be much appreciated. 
	Code: 
	sub EVENT_SAY | 
		
 This post really did a number on my phone (ever since width was changed on the site).  Anyway. 
	Your formatting is tricking you I believe. All those elsif's belong to the original if. That said. Let's assume that: Code: 
	$text = "Your format looks a little off"Code: 
	if ($text =~ /look/i) {/look/ is the pattern (NOT string) that it's looking for. So even though our text variable was "looks" the pattern "look" is still there. The lowercase i after the match operator tells us to "i"gnore case. Interesting test for you: Assuming $text equals potions. Code: 
	sub EVENT_SAY {Code: 
	sub EVENT_SAY {I had a hell of time knowing where I was in my post above. And I dont suspect reviewing it will be any easier. I'm sure someone will come along and correct me if I'm off somewhere, I hope they do anyway.  | 
		
 Thank you for the response Ghanja. I was told elsif would help to prevent memory leaks which is why I use them constantly; I have been scripting for may be 2 months. I will look into the perl regular expressions and see if I cannot clean the script up somewhat. 
	 | 
		
 Untested, but should do what you want it to:  
	Code: 
	sub EVENT_SAY { | 
		
 Quote: 
	
 "if" is a conditional, and as such will be checked each time "elsif" is also a conditional that if the originating if was not true, will be checked/considered, stopping upon the first met condition of that if/elsif nesting. The use of them is a bit much, yes, though the problem was in your regex, not the large number of elsif's. Krab has provided a hash / iteration method, also using length, substr, new regex operator, etc. Plenty to digest, but, beneficial as you'll hopefully learn from it.  | 
		
 Quote: 
	
  | 
		
 That works beautifully Kingly thank you for the rework. Thank you Ghanja for pointing me to regular expressions. I had meant not ill will towards you by saying I had only been scripting 2 months just letting you know the extent of my ability. With your mention of expressions and Kinglys example I do have a lot to digest. Thank you both. 
	 | 
| All times are GMT -4. The time now is 11:01 PM. | 
	Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.