Raised This Month: $51 Target: $400
 12% 

Motd Say 0.3 - ( 11 September 2016 )


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   ALL        Category:   Admin Commands       
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 01-25-2016 , 03:48   Motd Say 0.3 - ( 11 September 2016 )
Reply With Quote #1

Motd Say




.: Description :.

This plugin is allow admins to print a motd message for alerting players from server.
Command message are in html format.


.: Admin Command :.
Code:
// Display to all tero:
amx_msay #T "The message" "Title of the motd window"
amx_msay #TE "The message" "Title of the motd window"
amx_msay #TERO "The message" "Title of the motd window"
amx_msay #TERROR "The message" "Title of the motd window"
amx_msay #TERRORIST "The message" "Title of the motd window"

// Display to all ct:
amx_msay #C "The message" "Title of the motd window"
amx_msay #CT "The message" "Title of the motd window"
amx_msay #COUNTER "The message" "Title of the motd window"

// Display to all spectators:
amx_msay #S "The message" "Title of the motd window"
amx_msay #SPEC "The message" "Title of the motd window"
amx_msay #SPECTATOR "The message" "Title of the motd window"
amx_msay #SPECTATORS "The message" "Title of the motd window"

// Display to all players:
amx_msay #A "The message" "Title of the motd window"
amx_msay #ALL "The message" "Title of the motd window"

// Display only to all admins:
amx_msay #AD "The message" "Title of the motd window"
amx_msay #ADMIN "The message" "Title of the motd window"
amx_msay #ADMINS "The message" "Title of the motd window"

// Display to only one single player:
amx_msay Player "<b> The </b> message." "Title of the motd window"
.: Modules / Requirements :.
  • CStrike
  • AMXmisc

.: Credit's :.
.: Changelog :.
  • V0.3:
    + Removed return from INSIDE of the loop ( sorry ).
    + Added "ceh" flags for each time when using in a different way get_players().
  • V0.2:
    + Add an "prevent" if the player will not use Arg3 will be used the default tag.
    +Code optimization
    +Added more tags.
  • V0.1: First release.

.: Downloands :.
Quote:
VERSION | DOWNLOANDS
v0.1 | 2
v0.2 | 84
Attached Files
File Type: sma Get Plugin or Get Source (MotdSay.sma - 692 views - 3.0 KB)

Last edited by Craxor; 09-11-2016 at 13:15.
Craxor is offline
Send a message via ICQ to Craxor
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 01-25-2016 , 11:26   Re: Motd Say 0.1 - ( 25 January 2016 )
Reply With Quote #2

Hey, nice, but do not declare variables within for. Declare them out of it, unless they are static:
Code:
            ...             get_players(Players,num,"ceh","TERRORIST");                         for (i=0; i<num; i++)             {                 new buffer[255];                                 ...
And you repeated this below 4 times, inside if's and for's, but just do it once before enter to those blocks, as they are all the same. And at this case, you are reformatting they within a for, but all the formatting is the same to all for loops, this is bad:
Code:
            ...             for (i=0; i<num; i++)             {                 new buffer[255];                 formatex( buffer, charsmax( buffer ), "<center> <b> <font size = 5 color = blue >Message from admin</font><font size = 4 color = green> %s</font> </b> <p><b><u><font size = 2 color white >Message</u></b>: %s <font >", szName, Arg2 );                 ...
And as this message below is the same all the time, create a preprocessor macro to it. To write their names only once is good because it avoids/lets you changing/modifying they at one place and forgetting to do/changing it on the others they are used:
Code:
        show_motd( Player, buffer, "* Admin Private Motd Message *" );
Example:
Code:
#define PRIVATE_MESSAGE_TITLE "* Admin Private Motd Message *"         ...         show_motd( Player, buffer, PRIVATE_MESSAGE_TITLE );
__________________
Plugin: Sublime Text - ITE , Galileo
Multi-Mod: Manager / Plugin / Server

Support me on Patreon, Ko-fi, Liberapay or Open Collective

Last edited by addons_zz; 01-25-2016 at 11:32. Reason: spelling fix
addons_zz is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-25-2016 , 18:44   Re: Motd Say 0.1 - ( 25 January 2016 )
Reply With Quote #3

addons_zz, why are you so obsessed with the preprocessor??? In this case, the MOTD title should be defined as a constant variable, not using the preprocessor.

PHP Code:
new const szMOTDTitle[] = "Title of MOTD Here" 
Even more appropriate would be to have it set by cvar.
__________________

Last edited by fysiks; 01-25-2016 at 18:45.
fysiks is offline
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 01-25-2016 , 21:41   Re: Motd Say 0.1 - ( 25 January 2016 )
Reply With Quote #4

Sorry, I forgot that using the preprocessor would create various strings instead of just one as when using the constant. Hence, using more memory. In Pawn, if you define a constant value, it is declared only once on the memory, instead of multi-times as when using the preprocessor. Some times you may want it to behave like that because you modify the same string at different locations, but this is not the case.

This happens because the preprocessor place the string multiple times on the code, then create various strings. And when do you use the constant, it is declared only one time and when it is needed to be used, it is called by its address. See more information about strings on these links:
  1. Part 2 - Characters, Arrays of characters (strings)
  2. Pawn Tutorial#Strings
  3. Strings as arrays, as pointers, and string.h

Actually, use a cvar and let to the admin an option to provide as an default title, that is used when the admin do not specify one. But here, it cannot to be a constant value, as is is need to change, so just declare it as a normal variable and updated it on plugin_cfg() reading the cvar. Example:
Code:
// Display to all terror:
amx_msay #T "The message" "The title"
amx_msay #T "The message"
Code:
new cvar_motd_title new szMOTDTitle[32] /*  * Called just after server activation.  */ public plugin_init() {     cvar_motd_title = register_cvar( "amx_motd_title", "* Admin Private Motd Message *" )    } /*  * Called when all plugins went through plugin_init()  */ public plugin_cfg() {      get_pcvar_string( cvar_motd_title, szMOTDTitle, charsmax( szMOTDTitle ) ); }
__________________
Plugin: Sublime Text - ITE , Galileo
Multi-Mod: Manager / Plugin / Server

Support me on Patreon, Ko-fi, Liberapay or Open Collective

Last edited by addons_zz; 01-29-2016 at 06:38. Reason: improved cvar example
addons_zz is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 01-26-2016 , 00:37   Re: Motd Say 0.2 - ( 26 January 2016 )
Reply With Quote #5

Update.

All changes done, No .. i won't create a cvar just for motd title :[ ... i do it with a const Var.

Edit: heck i do something with that, if the players will not use the 3nd argument( "The motd window title" ) will be used as default the next format: "* Admin Private Motd Message *"

- Added spectator message support + more tags.

Tested everything and work fine ... waiting for more suggestions/ideas, thank you addons

Last edited by Craxor; 01-26-2016 at 03:12.
Craxor is offline
Send a message via ICQ to Craxor
Mario AR.
Senior Member
Join Date: May 2011
Location: Lima, Perú
Old 02-13-2016 , 09:34   Re: Motd Say 0.2 - ( 26 January 2016 )
Reply With Quote #6

Nice idea

As a suggestion, you can use
PHP Code:
if (arg[1] == 't' || arg[1] == 'T'
instead of
PHP Code:
if( equaliArg1[1], "T" ) || equaliArg1[1], "TE" ) || equaliArg1[1], "TERO" )|| equaliArg1[1], "TERROR" )|| equaliArg1[1], "TERRORIST" ) ) 
(Same for CT and ALL).
Mario AR. is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 02-14-2016 , 03:41   Re: Motd Say 0.2 - ( 26 January 2016 )
Reply With Quote #7

Quote:
Originally Posted by Mario AR. View Post
Nice idea

As a suggestion, you can use
PHP Code:
if (arg[1] == 't' || arg[1] == 'T'
instead of
PHP Code:
if( equaliArg1[1], "T" ) || equaliArg1[1], "TE" ) || equaliArg1[1], "TERO" )|| equaliArg1[1], "TERROR" )|| equaliArg1[1], "TERRORIST" ) ) 
(Same for CT and ALL).
I will add this days, now i feel tired...

If this work will be cool! I will avoid using equal() Natives much more times.

But are you sure it's a good idea compare strings using equal operator "==" instead of equal native? I'm out of knowledge here so i need hear some experts opinion!

Experts_come_to_my_thread( 0, TimeToCome=10mins );

Last edited by Craxor; 02-14-2016 at 03:42.
Craxor is offline
Send a message via ICQ to Craxor
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-14-2016 , 03:58   Re: Motd Say 0.2 - ( 26 January 2016 )
Reply With Quote #8

"==" operator works because he was comparing characters, not strings. Character is just a single cell value, enclosed within single quotes.
PHP Code:
if(arg[1] == 't')
// same as the following, look at http://asciitable.com for more info
if(arg[1] == 116
basically checks if the second character is 't'. It's not same as checking if 2 strings are equal.

Last edited by klippy; 02-14-2016 at 03:59.
klippy is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 02-14-2016 , 04:05   Re: Motd Say 0.2 - ( 26 January 2016 )
Reply With Quote #9

Quote:
Originally Posted by KliPPy View Post
"==" operator works because he was comparing characters, not strings. Character is just a single cell value, enclosed within single quotes.
PHP Code:
if(arg[1] == 't')
// same as the following, look at http://asciitable.com for more info
if(arg[1] == 116
basically checks if the second character is 't'. It's not same as checking if 2 strings are equal.
OO yes, you're right, i just observe that, sorry i feel so tired...

Ok.. Now i undesrtand, but no, i wiill not add this, i wanna have more tags.

As an modification,i can add only for the first "T" and an "T" and compare characters( That's have no sens :O )

Just an example:

Code:
if( Arg[1] == 't'|| Arg1[1] == 'T' || equali( Arg1[1], "TE" ) || equali( Arg1[1], "TERO" )|| equali( Arg1[1], "TERROR" )|| equali( Arg1[1], "TERRORIST" ) )

Opinions?

Last edited by Craxor; 02-14-2016 at 04:06.
Craxor is offline
Send a message via ICQ to Craxor
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-14-2016 , 15:42   Re: Motd Say 0.2 - ( 26 January 2016 )
Reply With Quote #10

Quote:
Originally Posted by Craxor View Post
Just an example:

Code:
if( Arg[1] == 't'|| Arg1[1] == 'T' || equali( Arg1[1], "TE" ) || equali( Arg1[1], "TERO" )|| equali( Arg1[1], "TERROR" )|| equali( Arg1[1], "TERRORIST" ) )

Opinions?
It depends on what you are actually wanting to detect. All of your equali() checks will never happen because the 'T' check will return true first in all of those cases.

What do you actually want to be the condition to be?
__________________
fysiks is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:58.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode