check_hasitem issue or just bad Perl Code
The below quest works but has issues.
Quest purpose: give info on updated a item and then take items and update. The quest works fine taking turn-ins and giving the updated item. The issue is checking to see which item the person has so the NPC responds with proper instuctions. It works fine if the person has the 1st-3rd updated item, if they have the 4th udated item or higher it bugs the client so bad you have to kill it (mouse functions die etc). So to many calls to "check_hasitem"? Code:
############################################### Gaf |
Heya Gaflack,
I don't know much about the check_hasitem method however I thought I would suggest a slightly different approach to what you are trying to achieve. Note that I wrote this quickly and as I am no perl expert there are probably some errors! Code:
%ITEM_RESPONSE = ( |
So I got curious and had a look at the server side methods that are called from check_hasitem. I do not believe there is anything there which could cause the client to lock up so badly.
Also, something I failed to include in my code snippet and should also be included in your original code is a return / break after the check_hasitem has succeeded. Once you have found the item, there is no need to continue searching. |
he was using elseif so it will automatically stop the entire if block once a match hits.
But yeah, in a loop you need a break to get out early. |
Sorvani is right! Its late here :p
|
Thanks for the post Drajor.
I did a little testing last night and it seems that when I try the script it not only kills the client it kills any other client I have running. Very Strange. Things I am going to test: Check that multi-client kill issue with different PC's and different Clients. I am thinking it is a zone issue since 2 clients were killed. Replace items checked with standard Vendor items (maybe one of my items is messed up in the database). Thanks, Gaf |
You should also take the hail check out of every line and simply wrap all the hand in checks in a single is hail like Drajor did in the loop example.
Code:
if($text=~/hail/i) { Code:
sub EVENT_ITEM { |
Thanks for the post sorvani.
I really appreciate that you took the time to not just say 'your code is lame' but to show where to improve. After 20+ years away from any coding any help is a blessing. There are lots of us trolls out here who learn tons from posts where you show a better way to do something. I will redo my quest then see if it kills my clients before I make my other tests. Thanks again, Gaf |
If all the clients in the zone are disconnected then it sounds like the zone is crashing. Look in the world server logs to see if this is the case, and the appropriate zone server log to see if there is any useful information logged about why it is crashing.
|
Ran some more checks and zone is crashing, clients in other zones ok. Check Processor during hails of npc with different quest items. Processor load goes from 1%, 10%, 12%, 13%, 100% (5sec), 100% 20sec, 100% till zone dies and clients crash. This was with item on client from 1st in list to 6th in list.
So it seems that the more I call check_hasitem the harder the load on the processor until it dies. Going to replace created items with standard vendor items and retest. Edit: I thought of it after, hailing with no quest items kills client as server processor is maxed. Still I replace all items in script with standard vendor items and it does not change the results. I replace the check_hasitem with a replacement that c0ncrete sent me, no difference. BTW, tested on Titanium, SOD and UF. I just replace the code with a 'Hail with click-able links' but would love to figure out what I am doing wrong. Thanks, Gaf |
If the zone process is using 100% cpu for an extended period of time it is likely in an endless loop. You'd need to attach a debugger to it and break to see where.
|
All times are GMT -4. The time now is 09:04 PM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.