Trying to Create a Summonitem Proxy
I am looking to create a NPC that acts as a #summonitem proxy. I want to keep my players access limited to the default commands, and not give them access to any special commands. Since they have #itemsearch by default I would like to create an NPC that allows them to recieve an item of their choice by saying to him the item ID number. Once I get the basic event down I was thinking of turning it into some sort of quest with a handin and then he gives you the option to have him summon you any item in the game. Or just sticking him in a really hard location to get to. Not sure yet...
Example: Code:
Player: Hail "NPC" How do I make it so the NPC reads the item number that the player says and summons the item for the player? quest::summonitem("12345") - would be the static way $say = player text quest::summonitem("$say") - dynamic way |
I should start by saying that I have limited experience with perl or regular expressions.
Something like that, but instead of using quotations: Code:
$say = player text Code:
quest::summonitem($say); Code:
if($text=~/\d{1,6}/) { edit: not sure what would happen if someone said for example '10061 13001', I think it might call summonitem(10061 13001) which should return an error. Also, you probably want to check the return value of summonitem (if it has one) and see if it found the item or not, if not the npc could say that there was no item found. |
It would be 10x easier just to lower the status requirement for summon item instead. You can change the command's status individually to suit your needs, meaning you can give them access to just summon item if you like. I configure mine in command.cpp but I believe if you are using current EQEMU code, you can simply change the status in the database.
It is either in the rules table or there is a table called commands that lists these status levels in your database. The default status level for a player is 10 so change it to 10 and you're good to go. |
Thanks pyfon for the reply. I will see what I can do with your suggestion.
Yeormon, I know I can just change the command in the DB but whats the fun in that. At least this way I can give players the ability to summon items but I can control it a bit more than just giving them the command. I could create this into a quest where they have to do a turn in in order to be able to summon one item of thier choice. Or have the NPC spawn on the death of a very high level raid encounter. I was trying to get a bit creative with it. This way the players will have to work for it, but it is still obtainable. Just giving out #summonitem to everyone can ruin the game for someone fast. But if you have a character that you maxed out, and you finally can get to the NPC then you have earned it! |
Ok this works but I need to polish the quest a bit since it returns the following after everything you say to the npc even hails. But I just wanted to see if the item summon funtion works before I ironed out the details and it does.
Code:
No such item: 0 Code:
############# Thanks for the help pfyon! |
I should also note that someone who says '1some2thing som3et45hing' might get it picked up as id 12345, I suggest you look up perl regular expressions on google and do some testing.
|
Yup I will have to fix the script to get rid of the errors and to make it a bit cleaner like you say. Just wanted to figure out if it was possible or not first, and ... well ... it looks like it is!
|
You could replace the if statements after the first one with elsif statements. It's what I do whenever I work on quests unless I need it to check the text more than once separately.
The way I figure, if someone says (for example) "hail items summoned", I only want the hail text, not both the hail and items summoned. It also reduces server load (slightly) by not needing to evaluate every if, it just stops when something evaluates true. This would keep the number checking code from being executed when they say hail or items summoned, which is a start. Other stuff would still trigger it though. |
elsif worked perfectly thanks!
|
How can you make it store a text string? Been thinking about a bot to do guilds.
|
here is the final quest I came up with that works with no errors. Thanks again to pfyon for the help.
Code:
############# But it works! |
Quote:
Code:
$myString = $text; Code:
if($text =~/<some regex to check guildname>/i) Kinda getting over my head with regular expressions and perl in this thread, I'm just waiting for someone who actually uses it regularly to come in and say "no, that's all wrong". :p Also, not sure if it's good programming practice with perl, but you could declare the variable as a global variable (outside EVENT_SAY, like at the top of the script) so it can be accessed from other events. |
Yeah, I figure it is possible, but I'm not sure what the expression should be to store the variable, but after reading what you put I think just using a say and storing it should be sufficient, but then it will be slightly more difficult to give instructions on how to use it....
As you said, hopefully someone better at the ins and outs of perl will chime in =p |
These should help as references:
Regular expression examples - Wikipedia, the free encyclopedia Perl regular expressions for the common man Here's the finished product: Code:
############# |
Thanks AndMetal for cleaning up the regex stuff.
|
All times are GMT -4. The time now is 09:03 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.