Buffing PERL Script (Formatting)
Hey all, it's me again =D. I wondered if anyone could help me with some formatting on a buffing NPC I am working on. See, if it doesn't work, I will end up redoing around 4000-5000 lines of code, so, I dont really want to continue with it until I know it works, hehe. I already did the first 5000 lines of code for categories and pricing and stuff, this is the part where u give him money.
Code:
sub EVENT_ITEM xteam_leader@yahoo.com it is probably about 100 kb now and is in a notepad, lol. Soooo much code, been working for hours on it so far. |
Hmm, all these nested if / elsif / else ... not too easy to work on.
Why not try a different scheme : store values for your quest in an array, and test them. Much easier to read and modify imho : Code:
|
hehe, well, I already wrote about 200 lines with nesting =\ and not quite sure if I want to redo all of it, hehe, just wanted to know if it was possible that it would work =D. Ty though for the help. And you are right, it is very hard programming in the way I set it up, lol, very very very hard. I am counting it by patterns now, only way I recognize syntax and stuffs, lol
{ { { elsif } } } like that, if it doesn't look like that, or whatever pattern I am on, hehe, then I didn't do it yet, lol. It looks more like 2 horns, here: Code:
elsif($ulevel > 89) |
try selfcast(spellid);, ive never gotten cast() to work.
|
The way you wrote it, it will always cost either 100 or 200 plat, higher levels won't be able to buy anything. Because if level is 99 $ulevel < 10 will be false and the next check $ulevel > 9 will be true, so it will skip all the other elsifs even though it fails the $ulevel < 20. You need to either combine these into one line as elsif($ulevel > 9 && $ ulevel < 20) or just get rid of the ($ulevel > 9) because if it ever gets to that else their level must be over 9 regardless.
|
How it is set-up is that it first checks to see if you meet the first req, then it throws another at you and if you fail that one, it skips all of that and goes through the rest of the code. This is how code works, if you meet a requirement, then you go to that, but if you don't, you skip it. So, you meet that req, but the second one you dont meet, so then you go back and into another elsif.
But, if you are right, would this be able to fix it? Code:
elsif($ulevel < 100) |
Yeah that way should work the way you want. And you also don't need the double {'s at the beginning and end, but again they shouldn't hurt.
|
You were right, lol, I am redoing all 5079 lines, lol, been working about 1 1/2 hours now and a bit more than halfway done, hehe. Tx alot, I was being stupid =P
|
It doesn't work, lol.
Anyone Wanna help, I have lots and lots of errors, I think 5: Bareword found where operator expected at Untitled line 120, near "if($text=~/ShapeChange30" Lines 110-125: Code:
{ Lines 47-101: Code:
if($text=~/ShapeChange25) Lines 115-125: Code:
} Lines 120-130: Code:
if($text=~/ShapeChange30) http://<br /> <a href="http://www.r...html</a><br /> Or http://<br /> <a href="http://www.r...html</a><br /> |
you didn't close the match pattern in the if clause :
Code:
if($text=~/ShapeChange30) Code:
if($text=~/ShapeChange30/) This might not solve all your pbs, but it's a start imho. i hope this helps. |
Lol, tx, I didn't see that at all, =P, lol. I feel blind now, lol, and it would actually be something like if($text=~/ShapeChange/i), that way doesn't have to match the caps. once again thx, I can't believe I didn't see that I forgot to do that. When you are typing a 10,000 line code file, you sometimes forget some of the small things, ehhe.
|
THE BUFFER NPC IS NOW DONE!
|
Glancing at the script, just a couple of insights. Take it for what you will:
For your level range checking, you do not need as many checks. Consider the following: Code:
if ($x >= 10 && $x <= 20) Code:
if ($x > 30) Code:
if($text=~/hail/i) Good effort on your script. I would suggest practicing with perl a bit more, and then attempt to redesign it. People have a habit of not wanting to redo or throw out their code, but in the end it will give you a better result, and likely increase your skills. |
Hey all, for some reason, this script isn't really working. The NPC is buffing itself instead of the players =/. Any ideas?
Code:
quest::castspell($userid,spell) Also, thx moonie. The code is already done though and works perfectly except for the above =/. I could have sworn it was $userid... |
Quote:
|
All times are GMT -4. The time now is 05:04 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.