PDA

View Full Version : Server Info


Tank
12-30-2008, 12:52 PM
If this is posted in the wrong section, apologies, please point me to where I should post it.

Goodday,

I figured since everyone always shares their plugins I do the same. However, my knowledge of coding and the knowledge of coding of people posting plugins I use is a difference between water and fire.

However I would like to get some feedback on my coding style. What am I doing wrong and what could be better. I also notice everything is always hardcoded for me, hardly use pcvars and therefor I would also like to learn how I could code plugins so they are more for general use, not just for me.

================================================== =======
Tank's Server Info (version 0.1 07-11-2008)

Server Info - information:
================================================== =========
Author : |B.A.M| The Tank #AoS.nl
Version: 0.1
Date : 07-11-2008

Tank's Server Info:

A menu based plugin for providing all sorts of info to the client.
Due to the fact that for some people using a MOTD way of providing
information is too slow I wrote this plugin. It's fully multi-lingual
making it a nice plugin for international servers/communities.

Although it's basicly written for my own clan/server I think with
some help it can be easily changed over to your needs. I tried to
alter the plugin as best I could to make it as general as possible.

================================================== =========
Server Info - Features:
================================================== =========
- Fully multi-lingual supported (not all translated yet)

================================================== =========
Server Info - To do:
================================================== =========
- Ask around for better information providing then just through
chat. Been thinking about making small tutorials in console print.

================================================== =========
Server Info - !!!!!!ERRORS!!!!!
================================================== =========..
No errors to report

================================================== =========
Server Info - Commands:
================================================== =========
- say /serverinfo to open the menu
- say_team /serverinfo to open the menu

================================================== =========
Server Info - Installation:
================================================== =========
- Compile the tanks_serverinfo.sma | An online compiler can be found here:
http:www.amxmodx.org/webcompiler.cgi
- Copy tanks_serverinfo.amxx into your addons\amxmodx\plugins folder
- Add tanks_serverinfo.amxx to the bottom of your addons\amxmodx\configs\plugins.ini
- Place serverinfo.txt into dod/addons/amxmodx/data/lang/
- Change the map or restart your server to start using the plugin!

================================================== =========
Server Info - Notes & Credits:
================================================== =========
- dodplugins.net for always having the information ready when needed, much appriciated.
- h0 noMan for helping me out a lot with this plugin
- Helping me with menu's
- ZOR for helping me understand what I was doing
- Also helped me on the multi lingual part of the plugin
- Synthetic for always being able to answer my questions when having a few.
================================================== =========

Dr.G
12-30-2008, 01:43 PM
GJ! i might grap some of that menu code :)

================================================== =========
BAM Info - To do:
================================================== =========
- Ask around for better information providing then just through
chat. Been thinking about making small tutorials in console print.



I made something like this long ago, but i did it with showing a motd, and that showed a small website where u able to click around and see all the diffrent stuff info about plugins etc. The main reason i did it like that was because i didnt know anything about codeing.. But might be and idea u can use for tutorials...

Tank
12-30-2008, 01:51 PM
I always used GHC Custom Message plugin which did the same. However, the moment I open a MOTD (could be the huge amount of miles between me and my server) I could built a replica of an old war ship and still have time left before it opened.

I also heared this complaints with others, so I figured to keep it as basic as possible. I also figured that pointing them to /baminfo with full language support would be quicker then trying as a Dutchy to explain in English to a spanish player who doesn't speak English that he can't shoot that ceiling with a bazooka.

Dr.G
12-30-2008, 02:01 PM
lol yea good point... well i linked to a www addresse when i did it, and that wasnt slow.. good luck with it...

Tank
12-30-2008, 02:07 PM
I'll think I try what you posted on a different computer and a different internet connection and see if it's still slow. Some stuff just doesn't work for me and I never liked doing work which doesn't benefit me :D

Thanks for the advice, I'll surely look into that.

Zor
12-30-2008, 03:16 PM
If you change this to something more dynamic, like insdead of BAM Info, Server Info and let the people change it to whatever they want in the Library files it would be much better. Then you can post it in Server Management forum.

Also you should use the Library file for your Menu Headings. This way you keep it completely dynamic.

You could Eliminate these defines:
#define mainmenu "\yB.A.M Information Center:^n" // Main menu
#define rulesmenu "\yB.A.M Rules: No Racism, No Hacking, No Glitching (nade or zooka)^n\yB.A.M Rules: No Excessive Wall Spamming^n" // Rules menu
#define pluginsmenu "\yInformation on all plugins running :^n" // Plugins menu
#define bindkeymenu "\yInformation on how to bind a key :^n" // Bindkey menu
#define faqmenu "\yFrequently Asked Questions :^n" // F.A.Q Menu

Add the following to your Library TXT:
MAINMENU = "\yB.A.M Information Center:^n"
RULESMENU = "\yB.A.M Rules: No Racism, No Hacking, No Glitching (nade or zooka)^n\yB.A.M Rules: No Excessive Wall Spamming^n"
PLUGINSMENU = "\yInformation on all plugins running :^n"
BINDKEYMENU = "\yInformation on how to bind a key :^n"
FAQMENU = "\yFrequently Asked Questions :^n"

Change your Menu Designators to the following:
//Menu registration
new mainmenu[128], rulesmenu[128], pluginsmenu[128], bindkeymenu[128], faqmenu[128]
vformat(mainmenu, 127, "%L", id, MAINMENU)
vformat(rulesmenu, 127, "%L", id, RULESMENU)
vformat(pluginsmenu, 127, "%L", id, PLUGINSMENU)
vformat(bindkeymenu, 127, "%L", id, BINDKEYMENU)
vformat(faqmenu, 127, "%L", id, FAQMENU)
register_menucmd(register_menuid(mainmenu), 1023, "func_choice_main")
register_menucmd(register_menuid(rulesmenu), 1023, "func_choice_rules")
register_menucmd(register_menuid(pluginsmenu), 1023, "func_choice_plugins")
register_menucmd(register_menuid(bindkeymenu), 1023, "func_choice_bindkey")
register_menucmd(register_menuid(faqmenu), 1023, "func_choice_faq")

Seems like a bit more work, but it will make adjusting things just so much more simpler for the untrained coder to put on their servers.

Cheers!

Tank
12-30-2008, 04:37 PM
More work or not, I posted it to learn how to make this more versatile for everyone to use. Besides that I gladly learn new stuff.

New version should be up in a few. I'll post here to make sure I did it the right way. Im learning and slowly getting there but some extra checking never hurts.

edit:
I adjusted the plugin:
- named the plugin from Tank's BAM Info to Tank's Server Info (and all the stuff related to BAM into server, also goes for the say commands).
- made the adjustment posted by Zor

Im working on changing the language file around so it doesn't show all info about my server but basicly general pointers on what that line should hold.

Any idea if I can generalise this even more? Im kinda stuck on that due to the use of the menu's. The menu's titles, the menu items and the amount of client prints are all hardcoded.

I have one question though, I checked this out:
vformat ( buffer[], len, const fmt[], vararg )

I know what len stands for but thats the only one. Can someone perhaps translate the short words to what they need to be, like wId is weaponindex, const fmt[] stands for constant....

Zor
12-31-2008, 01:32 PM
Ok if I understand what you mean here is the translation, very programize:

vformat ( buffer[], len, const fmt[], vararg )

vformat - Name of the function
buffer - Is the string memory you want filled
len - Length of buffers memory address eg: temp[128] len = 127 ( 0 - 127 = 128 )
const fmt - This is the formated string part eg: "Hello my name is %s I am %d years old"
vararg - This is the arguments to add into format, for above eg: , "zor", 36 Or you can give it arguments eg: new name[] = "Zor", age = 36 then have them replace the above "zor" and 36

Hope this explains everything?

Cheers!

Tank
01-01-2009, 06:55 PM
Yes it does. Any idea where I can find information on those abbriviations (spelling)? I'm having a lot of difficulties with all the functions to implement them in the right way because I dont know what the abriviations stands for.

EDIT:
I finished the changes that needed to be done on the plugin however now it won't compile.

The changes I made were:
================================================== =========
Server Info - Changelog:
================================================== =========
- Friday 2 January 2008:
-Added a new function to go to a second page in a menu
-Also added the option for multi lingual title menu's
-Finished the plugins section
================================================== =========*/

These are the compilers error I get:

temp.sma(103) : error 017: undefined symbol "id"
temp.sma(103) : error 017: undefined symbol "MAINMENU"
temp.sma(104) : error 017: undefined symbol "id"
temp.sma(104) : error 017: undefined symbol "RULESMENU"
temp.sma(105) : error 017: undefined symbol "id"
temp.sma(105) : error 017: undefined symbol "PLUGINSMENU"
temp.sma(106) : error 017: undefined symbol "id"
temp.sma(106) : error 017: undefined symbol "PLUGINSMENU"
temp.sma(107) : error 017: undefined symbol "id"
temp.sma(107) : error 017: undefined symbol "BINDKEYMENU"
temp.sma(108) : error 017: undefined symbol "id"
temp.sma(108) : error 017: undefined symbol "FAQMENU"
temp.sma(108 -- 110) : error 088: number of arguments does not match definition
temp.sma(108 -- 110) : fatal error 107: too many error messages on one line


Normally when I get this it's often because I forgot to include a module but all the functions used come up at amxmodx.org as just amxmodx module. Could someone perhaps help me on this bug?