AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [INC] PriorityCenterText (0x06) (https://forums.alliedmods.net/showthread.php?t=256007)

Chdata 01-23-2015 00:13

[INC] PriorityCenterText (0x06)
 
2 Attachment(s)
Only one message can be shown in center text at a time via PrintCenterText().

PriorityCenterText() allows that space to be given different priority levels that prevent new messages from overwriting what's already there.

Center text sent via these functions have the following attributes:
  • Messages of higher priority cannot be overwritten by messages of lower priority.
  • Messages of equal priority can overwrite each other.
  • Priority reverts to the minimum value (-2147483648) after 5.0 seconds.
An example of where I use this:
  • Versus Saxton Hale constantly displays the boss's health to the last player by sending CenterText in a repeated timer. This prevents messages like "You were just backstabbed!" from appearing because the health center text immediately overwrites it. PriorityCenterText allows the backstab message to have higher priority and not be overwritten for the 5 seconds it lasts.
There is currently nothing to make the priority text work between separate plugins.
(For example, if a new version of CSAY was made and you wanted it to be compatible with VSH - priority won't be checked between different plugins).
PHP Code:

/** 
 * Prints a center text message to a specific client with a specific level of "priority"
 *  
 * @param iClient            Client ent index. 
 * @param iPriority          Priority level of message.
 * @param szFormat           Message to send (and formatting rules).
 * @noreturn 
 */
stock PriorityCenterText(iClientiPriority MIN_INT, const String:szFormat[], any:...)

/** 
 * Prints a center text message to everyone with a specific level of "priority"
 * This will set the priority of all clients and works in tandem with PriorityCenterText()
 *  
 * @param iPriority          Priority level of message.
 * @param szFormat           Message to send (and formatting rules).
 * @noreturn 
 */
stock PriorityCenterTextAll(iPriority MIN_INT, const String:szFormat[], any:...)

/** 
 * Prints a center text message to everyone with a specific level of "priority"
 * This will override the priority of the functions above by maxing out priority for all clients
 * In other words, this version ignores priority and is guaranteed to overwrite messages sent from the functions above
 * It does have its own internal priority though which can be used against itself
 *  
 * @param iPriority          Priority level of message.
 * @param szFormat           Message to send (and formatting rules).
 * @noreturn 
 */
stock PriorityCenterTextAllEx(iPriority MIN_INT+1, const String:szFormat[], any:...) 

Full source here (same as the attached .inc)
Spoiler

For people interested in GitHub:
https://github.com/Chdata/SM-INC-PriorityCenterText

friagram 01-24-2015 04:32

Re: [INC] PriorityCenterText (0x02)
 
Centertext is a usermsg, priority is one of the vars. you could just se the priority to something using a static var, and compare the optional var to that, rather than calling printcentertext.

Atleast, i think priority is a var, it is for some of the other usermsgs, like the one in the upper left.

Chdata 01-24-2015 05:10

Re: [INC] PriorityCenterText (0x02)
 
Also note I'm aware of this bug in the timing of revertpriority:

Code:

/* NEEDTOUPDATE
    2 5 -1 > 3
    3
    4 5  3 > 5
    5
    6
    7 2  5 > -1
    9 4 -1 >  3
*/

Edit: That should be fixed now.

Code:

/* NEEDTOUPDATE
    2 5 -1 > 3
    3
    4 5  3 > 5
    5
    6
    7 2 5 >  3 // technically now 5 priority only lasts 3 seconds instead of 5 but it reverts properly now
    9 4 3 > -1
*/


Chdata 01-26-2015 03:31

Re: [INC] PriorityCenterText (0x04)
 
Welp fixed the timing thing. Include should work entirely as intended now.

Aside from not having cross plugin capability. If anyone has a suggestion for that...!


All times are GMT -4. The time now is 23:21.

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