Advanced chat plugin

Everything related to modding, mapping and software or hacks

Rate this plugin! (Your explanations will be appreciated)

Excellent!
3
100%
Good!
0
No votes
Nothing special.
0
No votes
Bad.
0
No votes
Useless bullshit!
0
No votes
 
Total votes : 3

Advanced chat plugin

Postby Xandros » Tue Aug 26, 2014 1:03 pm

Good time of day, Noxers!

Today i decided to post something very useful and here is my addon, that allows command usage for non-sysop players via usual chat.
Advanced chat plugin.

Current version is: 2.0

System Requirements:
Nox Unimod or equivalent with 2 argument console print reaction (text,color) and Lua version 5.1

How to find out which lua version used in your client:
  1. Open in-game console (F1 by default)
  2. Write
    Code: Select all
    print(_VERSION)
    and press ENTER.
  3. Result will appear in your console,

Download link (MediaFire. 4.84 KB): http://www.mediafire.com/download/v17otneel58g62r/advchatcmds

All bug reports you may leave here or send via e-mail: germanapps@gmail.com


How to install this addon:
Download addon file, place it into your Nox directory and load it by adding this line:
Code: Select all
dofile('advchatcmds')

into you autoexec.lua file.
Addon configuration:
WARNING!

This lua script designed as module, not just as usual lua script. That means, that there NO NEED TO CHANGE THIS SCRIPT! This script working perfectly without your intervention in source code!!! Just PLACE and USE!

How to configure. There is a list of command with detailed explanations how to use it:
Image
(copy-pasted from developer's documentation file, because there is no table tag)

How to use:
You need to add commands into commands database. Use this command:
Code: Select all
sv_addchatcmd('/yourcommand', targetfunctionname)

to add your command, where "/yourcommand" is binding for targetfunction. Please note, that "/" character required only to prevent accedental targetfunction calls. You may replace "/" character with "!" or "@" or any other non-letter and non-numeric character.
WARNING! Commands are Case-Sensetive! "/Votemap" is NOT the same as "/votemap".
Targetfunction will receive two arguments: caller's nickname and string with chat arguments. Targetfunction may have 3 or more variables, but only first two arguments will receive data; other n-2 arguments will be NIL. If you dont need argument string, use one argument function. If you dont need any Advanced chat information, you may use functions without arguments.
Example:
We have a function:
Code: Select all
function test(u,args)
print('User '..u..' called this function with args |'..args..'|');
end

and we made a bind
Code: Select all
sv_addchatcmd("/test",test)

So, if player Xandros says: /test function will return username and command arguments (empty string).
Image
There Xandros says /test <text> and here is the result
Image

If you dont need certain command, you may delete it with this function:
Code: Select all
sv_removechatcmd("/yourcommand")

You may remove command anytime you need - there is no need to turn off plugin before removing binds.

If you are refreshing command list (you changed game mode for example), you may use this command to clear your database:
Code: Select all
sv_clearchatcmds()


Next function useful for admins. Its providing information about plugin engine state and plugin version.
To show information about plugin use this function:
Code: Select all
sv_advchatinfo()

Please note, that information will appear in server's console.

To get plugin version string use
Code: Select all
sv_advchatversion()

This command will be useful, if you made a mod for certain version of Advanced chat plugin.

Next function will be useful for admins, when they are restarting server scripts without server's shutdown. Use this command:
Code: Select all
sv_advchatunload()

to unload all variables and functions. Basically this function sets every engine object to NIL. Please note, that this function is not launching garbadge collector.


About reactions:
Reactions are useful for admins only - modders do not receive any benifits from the use of reactions, except ADVCHAT_ONCOMPLETE reaction.
Reaction is a special variable, that contains function of certain type. Reactions are helping to find out why "that goddamn thing is not working properly" and only one of them just redirect internal Unimod reaction from plugin function to specified function to prevent so-called "reaction break". "Reaction break" is blocking reaction use for any other functions/modules.
To use reaction, you DONT NEED TO CHANGE DEFAULT REACTION INSIDE PLUGIN! You should use "function override" feature of lua.
To override function you need to declare a new function with the same name as function-to-override or just assign unnamed function to function-to-override.
Example:
MY_FUNC() - is function to override. We need to override it with function that have one argument.
First way to override function:
Code: Select all
function MY_FUNC(arg)
--New function code here
end

Second way to override function
Code: Select all
MY_FUNC = function(arg)
--New function code here
end

I prefer the second way, because its much easier to understand.

Addon reaction usage:
Example of ADVCHAT_DISABLED usage:
Code: Select all
ADVCHAT_DISABLED = function()
print("Advanced chat is disabled")
end

Example of ADVCHAT_NOCOMMANDS usage:
Code: Select all
ADVCHAT_NOCOMMANDS = function()
print('WARNING: No commands found. Chat commands engine will be turned off');
sv_advchat = 0;
end

This function will turn off this plugin, if commands database is empty

ADVCHAT_INVALID_ARGS_DATATYPE
This reaction raises, when chat console print function got arguments with wrong datatypes.
This reaction required 2 arguments - var, type_s, where var is a numeric variable with 0-1 range (1-invalid datatype detected for text message, 0 invalid datatype detected for color attribute) and type_s - datatype of received argument.
Usually there is no need to change this reaction. Leave it as is.

ADVCHAT_INVALID_COMMAND
This reaction required 1 argument - text. text variable will got user's message, where is no command. This reaction is empty by default.

ADVCHAT_ONCOMPLETE is the most important reaction for modders. When you override this reaction, you may use console print reaction for your own needs. This reaction require 2 arguments - "text" and "color". How to use console reaction read in Unimod documentation.


This plugin is destributing "as is". The author is not responsible for any damage caused as a consequence of improper use or plugin modification.

And last thing - dont remove credits. Dont be a morons like BolgenOS "developer". Thank you.
Thats all. If you have a question, suggestion or criticism, post it here.
Last edited by Xandros on Fri Sep 05, 2014 10:53 am, edited 7 times in total.
Nox Unimod scripter.
My plugins:
Advanced chat plugin.
Antiblock system
User avatar
Xandros
Novice
Posts: 135
Joined: Sun Jul 13, 2014 3:45 pm
Location: Russian Federation. Moscow.

Re: Advanced chat plugin

Postby illidans4 » Tue Aug 26, 2014 2:23 pm

Nice, quite useful.
User avatar
illidans4
Administrator
Administrator
Posts: 60
Joined: Thu Apr 03, 2014 10:08 pm

Re: Advanced chat plugin

Postby Xandros » Mon Jan 26, 2015 2:54 pm

Advanced chat plugin.

Current version is: 2.1

What is in this update:
-Fixed bug that gives user a message of disabled advchat when he joined server.
-Fixed unload function which is not detaching "Advanced chat" engine from onConPrint function.

How to update:
Download file using link from the first post and replace your old file with new one. (for dedicated servers) Reload pluging by doing:
Code: Select all
dofile('advchatcmds')


Download link:
http://www.mediafire.com/download/v17ot ... dvchatcmds
Nox Unimod scripter.
My plugins:
Advanced chat plugin.
Antiblock system
User avatar
Xandros
Novice
Posts: 135
Joined: Sun Jul 13, 2014 3:45 pm
Location: Russian Federation. Moscow.


Return to Modding & Mapping

Who is online

Users browsing this forum: No registered users and 1 guest

cron