Bank Vault mod - Multiple plugin trouble/Forwards - bot behaviour
4 Attachment(s)
Hi all!
I am working on a new plugin: bank_vault. This will have an inventory as a part of the game, where people could buy items. The items would be in separate plugins, could be registrated with a native from the main plugin. The trouble is, I don't know how I should tell bots to buy items, because every plugin handles it's own items separately. As far as I thinked of: The money message is being hooked, and as soon as a bot has enough money, then it can buy items. But how to choose which items? How to tell other plugins in the same forward that some othe plugin already spent some of the bot's money. Any ideas on this? I attached the source code so far... Thanks in advance for your answers. |
Re: Bank Vault mod - Multiple plugin trouble/Forwards - bot behaviour
OMG! Not a single answer after a week? Damn...
|
Re: Bank Vault mod - Multiple plugin trouble/Forwards - bot behaviour
Quote:
Edit: Well it is simple. You should make the main plugin (core plugin) handle the item buy! You register the price, etc. and make a native for the buy, that can be used by other plugins and even by the core. You register all the extensions in an array and make the original plugin check if a bot has enough money and after that do a buy. To notify other plugins about money change the best way is with cs_set_user_money. Edit2: I released a plugin a night before that does what I have said above. http://forums.alliedmods.net/showthread.php?t=134691 Check the native/forwards parts and how they are used. Also the inc file should help. :wink: |
Re: Bank Vault mod - Multiple plugin trouble/Forwards - bot behaviour
Hi there Lulu! I think I've solved your problem using the ideas you gave in your first comment. Step by step here it is:
First of all, there are two type of items defined in your plugin: 1) items that are usable by bots( purse, or any upgrades ) 2) items that bots cannot use( crowbar, satchel charges, or any weapons ) Then you need to specify some priority, when can a bot buy an item: 1) immediately, when sufficiant money is gathered( purse upgrade ) 2) it can wait, till round start( building upgrades, withdrawing, depositing money from the bank ) 3) never( items, that are disabled to bots due to their lack of ability to use it ) Lastly you need to specify the amount, that needs to be bought at a time: 1) buy as much as possible( max out ) 2) buy only 1 at a time Then you can set some properties of the items: 1) Can it be dropped 2) How long does it lasts 3) Who can buy it All the above are like this: PHP Code:
|
Re: Bank Vault mod - Multiple plugin trouble/Forwards - bot behaviour
All right Lulu, as you feared, you need to store the above datas all in your main plugin. But that gives you some advantages too, you don't need to send out so many external forwards to check who has a certain item, you can simply use the datas as a lookup table( precache them as nesesery ).
In your main plugin, set up some enums to give your data a structure: PHP Code:
To register your item, use a function like this: PHP Code:
For example when someone buys the item purse2k, then you can print out a message( from the purse2k's plugin ): You can now store up to 2000 dollars. Hope this helps, Lulu. |
Re: Bank Vault mod - Multiple plugin trouble/Forwards - bot behaviour
Thanks a lot, Lulu, helped me a lot, but there is one more trouble. This plugin will keep growing and growing... How can I maintain it, if it is so big? It will propably run over 3k lines?
All right, I have the answer, no need to this talking to myself thing: Put the parts of your plugins to separate inline files, that you include when nesesery. Like in pokemod: You can include anything with this line: PHP Code:
|
Re: Bank Vault mod - Multiple plugin trouble/Forwards - bot behaviour
I do find it quite amusing that you help yourself. One of the few people.
|
Re: Bank Vault mod - Multiple plugin trouble/Forwards - bot behaviour
If I've found a working solution, then why not share it with you guys?
To be honest, I sat on my ass for a while(2 days), started the whole plugin from scratch, and finally came up with the idea of this: Am I getting worried, that my plugin will use too much memory? With these new ideas and methods, the plugin is slightly over 60kB, but then again, check the ZombiePlague mod: more than 300k??? I have plenty of space to waste, until I reach ZP's size.( It is funny: ZP. Those are the first letters of a hungarian party place: Zöld Pardon( Green Excuse me :S ), so every time I see ZP, I can only think of that... :) Plus I save memory on storing properties of items in bits and not on bytes. And thirdly, who cares? It's the 21th century, dammit... To be compleately honest, I DO care about memory, because I am used to coding in pascal and assembly, where memory is quite limited( <1MB ) |
Re: Bank Vault mod - Multiple plugin trouble/Forwards - bot behaviour
Quote:
|
Re: Bank Vault mod - Multiple plugin trouble/Forwards - bot behaviour
Yep, you know why? I tell you why.
The program is getting bigger and bigger. Working fine. Perfectly. No errors, no warnings. Then I add a few more code. Still works. Then I add something like a menu. Then when I add a bot, the whole hl crashes without an error. Then I remove the things I've edited recently, starting to comment them out, and still has the bug( appeared at the menu ). Then I need to comment out everything almost, and then I realise: I've mistyped a letter in a string, eg. in a forward declaration. 1 flippin' character. That happens lesser then the other version, where I give up the whole thing in the middle of commenting, and just start a new file, and copy paste the working codes from the buggy to the new. It is simpler to me. Note to self: USE SVN, MORON!( Yep, I should... ) So I am lazy to debug. I hate errors which are not syntactical errors. And I hate debugging them, so I use this method, and I got used to it. Any idea on how to avoid these kind of problems? Edit: I'm doing that right now :D |
| All times are GMT -4. The time now is 00:12. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.