check player for item
I've been trying to figure out how to write a quest plugin that checks the player to see if they have an item and returns true if the item is found. So say I do something like this:
Code:
if(plugin::check_hasitem(1001)) {$npc->Say("$name has a Cloth Cap");} Code:
#checks to see if player has item Heres the code I've been using on a npc to test to see if it works. The reason I don't want to use something like this is because it adds alot of useless code if I can get it working as a plugin. Code:
sub EVENT_SAY { |
without otherwise checking your code, when you create a subroutine file for plugins you must end it with a 1; so that when it loads it indicates it loaded correctly. You do not have a 1; at the end of your file so the system will assume there was an error loading them and ignore them.
Code:
sub check_hasitem { |
I still get the same problem even with putting a 1; at the end of the file. Here is what im doing for testing, I've made a npc with the quest script:
Code:
sub EVENT_SAY { Code:
[Status] Script error: qst189031::EVENT_SAY - Perl runtime error: Can't call method "GetItemIDAt" on an undefined value at plugins/check_hasitem.pl line 9. |
Well that was fun :)
since you are changing packages you do need to pass the $client reference to the plugin, but in order to be usable by the plugin it has to be blessed. So: Code:
sub check_hasitem { Code:
if(plugin::check_hasitem($client, 1001)) { |
Thank you very much Darkonig that what was I needed but couldn't figure out how to do, got the plugin working fine now.
|
Thank you both. I am now using this plugin and I love it.
|
I didn't think anyone would be using this so I didn't post the updated one I'm using. In my first post I forgot to change the < to <= after it checks the inventory, therefore it won't check the last slots for the bank, shared bank, and containers. So it should look like this:
Code:
#checks to see if player has item |
nice!
nice code! this could be very useful when PEQ implements 1.5 and 2.0 epics..
could do a check to see if epic 1.0 is in inventory, bank, etc and if so then your able to start 1.5, then once 1.5 is completed, repeat and check if 1.5 in where ever then your able to start 2.0 epic. cool beans, cool bean. |
All times are GMT -4. The time now is 11:53 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.