Raised This Month: $ Target: $400
 0% 

[INC] PriorityCenterText (0x06)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 01-23-2015 , 00:13   [INC] PriorityCenterText (0x06)
Reply With Quote #1

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
Attached Files
File Type: inc prioritycentertext.inc (4.0 KB, 164 views)
__________________

Last edited by Chdata; 02-08-2015 at 10:33.
Chdata is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 01-24-2015 , 04:32   Re: [INC] PriorityCenterText (0x02)
Reply With Quote #2

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.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.

Last edited by friagram; 01-24-2015 at 04:33.
friagram is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 01-24-2015 , 05:10   Re: [INC] PriorityCenterText (0x02)
Reply With Quote #3

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
*/
__________________

Last edited by Chdata; 01-24-2015 at 19:21.
Chdata is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 01-26-2015 , 03:31   Re: [INC] PriorityCenterText (0x04)
Reply With Quote #4

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...!
__________________

Last edited by Chdata; 01-26-2015 at 03:34.
Chdata is offline
Reply


Thread Tools
Display Modes

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 23:21.


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