AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   MOTM - Placement of huds (https://forums.alliedmods.net/showthread.php?t=10756)

onedamage 02-28-2005 07:56

MOTM - Placement of huds
 
Is it possible to manipulate the location of where messagse appear ?

What i mean, the code which i have provided here, has messages appearing in the Tsay area.
whenever an admin uses tsay, it goes over the motm message
whenever statsx disruption messages appear, also happens to go over the MOTM message.

what i'd like to do, is have the motm messages appear near the top left of the screen (just underneath the wide screen banner when dead), so that it cannot conflict (in appearance) with another message.

is there a way to do this ?
i have EKS hud placer plugin (http://forums.alliedmods.net/showthr...p?t=2054+place)
can i use this to find where on the screen i want the messages to appear, and then add/modify the command on where i want them placed ?

i guess what i'm asking is for anyone to confirm that i can go about this (the way i think) to modify the motm plugin.


This was provided by Asskicr, in another post on the forums.
http://forums.alliedmods.net/showthread.php?t=897

Code:
/* AMX Mod X script.  *  * (c) Copyright 2002-2003, Dio, Ludwig van, <Evil>deadBeat  *  *  amx_motm.sma     version 0.9.4                  Date: 20/7/2003  *  Author: Mark Bullen  *  Alias: <Evil>DeadBeat       Contact: <a href="http://www.evilrus.com/" target="_blank" rel="nofollow noopener">http://www.evilrus.com/</a>  *  *  Based upon the original AdminMOD MOTM plugin by Dio, and it's adaptation  *  for AMXMOD by Ludwig Van.  *  *  Optimisations and Streamlining of code by <Evil>deadBeat  *  *  + Read MOTM file(s) from Disk to RAM at map start  *  + Check that Random Colours are Bright Enough  *  + Add custom MOTM files for each Map  *  - Strip out extra functionality that most people won't use ;-)  *  *  Displays a list of messages on each players HUD and Console, which are  *  loaded at the start of each map from  *  ".../cstrike/addons/amxx/custom/motm/default.txt".  *  *  Each line in this file is treated as a message, line-breaks are indicated  *  by inserting '^n' in the line  *  *  Messages can be shown in a variety of colours by placing '!' and a the  *  colour name at the start of the line. You may choose from '!red ',  *  '!green ','!blue ', '!white ', '!yellow ' and '!purple '.  *  *  There is also a '!random ' colour should you want to jazz things up.  *  *  Example MOTM File Contents:  *  *  !red    This Message is shown in RED  *  !white  This Message is shown in WHITE  *  !random This Message is shown in a Random Colour  *  !green  This Message is shown in Green ^n and is on Two Lines  *  *  *  Custom Messages for the current map will be loaded based upon the mapname  *  from ".../cstrike/addons/amx/motm/<mapname>.txt" and shown before the  *  default messages - this is to ensure that they are seen should the map  *  only be played for a short period of time.  *  *  *  PLUGIN VARIABLES OF NOTE:  *  *  Messages are shown in order at interval 'MOTM_TIME' (seconds) for duration  *  'MOTM_DURATION' (seconds).  *  *  The maximum number of messages to be shown is 'MAX_MOTM' and the maximum  *  size of each message is 'MAX_MOTM_LEN'  *  *  CONFIG FILES:  *  *  .../cstrike/addons/amxx/custom/motm/default.txt     Default Messages for all Maps  *  .../cstrike/addons/amxx/custom/motm/<mapname>.txt   Custom Messsage for <mapname>  *  *  CLIENT COMMANDS:  *  *  - NONE -  *  *  ADMIN COMMANDS:  *  *  - NONE -  *  *  CVARS:  *  *  motm_counter    used internally by MOTM Plugin, no need to change it!  *  ***************************************************************************/ #include <amxmodx> #include <amxmisc> new Float:MOTM_TIME = 60.0  // seconds between messages new Float:MOTM_DURATION = 10.0  // how long they last // Minimum Intensity for MOTM Messages - squared! new MOTM_MIN_INTENSITY_SQ = 140 * 140 // directory where custom MOTM Messages are stored new MOTM_Directory[200] // max number of words in word list #define MAX_MOTM 64 // max length of each message #define MAX_MOTM_LEN 96 new g_motmText[MAX_MOTM][MAX_MOTM_LEN] new g_motmNum /**************************************************************************  *  * show_motm()  *  * Display the Message of the Moment (MOTM) on each players HUD  *  * Uses server cvar 'motm_counter' to keep track of which MOTM was shown  * last. When list of MOTM's is exhausted, will automatically restart from  * begining.  *  *************************************************************************/ public show_motm() {     new strMessage[MAX_MOTM_LEN]     new pMessage[MAX_MOTM_LEN]     new counter = get_cvar_num("motm_counter")     new Red = 0     new Green = 255     new Blue = 0     new IntensitySQ     new colorlen     // reset MOTM counter if we've reached the end of the list     if (counter > g_motmNum) {         counter = 0;     }     // Get the current MOTM Message     copy(strMessage, MAX_MOTM_LEN,g_motmText[counter])     // update MOTM Counter stored in server cvar     set_cvar_num("motm_counter", ++counter)     // Check to see if the Message had a "!" which indicates that     // the next part is a colour reference that we need to process     if (equal(strMessage, "!", 1)) {         new strColor[16]         // Get the colour reference         copy(pMessage,MAX_MOTM_LEN,strMessage)         parse(pMessage, strColor, 16)         colorlen = strlen(strColor) + 1         if (equali(strColor,"!red",4)) {             Red = 250             Green = 10             Blue =10         } else if (equali(strColor, "!blue",5)) {             Red = 10             Green = 10             Blue = 250         } else if (equali(strColor, "!green",6)) {             Red = 10             Green = 250             Blue = 10         } else if (equali(strColor, "!white",6)) {             Red = 250             Green = 250             Blue = 250         } else if (equali(strColor, "!yellow",7)) {             Red = 250             Green = 250             Blue = 10         } else if (equali(strColor, "!purple",7)) {             Red = 250             Green = 10             Blue = 250         } else if (equali(strColor, "!random",7)) {         // Pick a random colour, but check that it will be visible.             do {                 Red = random(256)                 Green = random(256)                 Blue = random(256)             // Check that Random Colour will be visible on the             // screen - calculate the intensity and check it             // is above our minimum                 IntensitySQ = ((Red * Red) +                            (Green * Green) +                            (Blue * Blue))             } while (IntensitySQ <= MOTM_MIN_INTENSITY_SQ)         } else {             // Default Colour             Red = 0             Green = 100             Blue = 200         }     }     // Replace instances of ^^n with ^n to show line-breaks     new linec = strlen(strMessage) / 6     if (linec > 10) linec = 10     for(new a = 1; a < linec; a++) replace(strMessage, 192, "^^n", "^n")     // Display the MOTM message on the HUD     set_hudmessage(Red, Green, Blue, 0.05, 0.65, 0, 0.02,                MOTM_DURATION, 1.01, 1.1, 3)     show_hudmessage(0, "%s", strMessage[colorlen])     // Replace ^n line breaks with spaces for display on clients console.     for(new a = 1; a < linec; a++) replace(strMessage,192,"^n"," ")     client_print(0, print_console, strMessage[colorlen])     return PLUGIN_HANDLED } /**************************************************************************  *  * readMOTM()  *  * Read in a list of Messages from a configfile and store them in the MOTM  * array 'g_motmText[][]  *  * NOTE: will only read config-files from the MOTM_Directory and will  * automatically append ".txt" to the end of the config file.  *  * Default MOTM_Directory is ".../cstrike/addons/amxx/custom/motm/"  *  *************************************************************************/ public readMOTM(configfile[]) {     //GET DIRECTORY     get_customdir(MOTM_Directory,199)     format(MOTM_Directory,199,"%s/motm/",MOTM_Directory)     new iLen, iCount = 0     new filename[128]     //GET FILE     iLen = format(filename, 127,"%s%s.txt",MOTM_Directory, configfile)     if (file_exists(filename)) {         // Loop through file, reading in each line, stop if we run         // out of space in our MOTM list or the file is empty         while ((g_motmNum < MAX_MOTM) &&                (read_file(filename,                           iCount++,                           g_motmText[g_motmNum],                           MAX_MOTM_LEN,                           iLen))) {             ++g_motmNum         }     } } /**************************************************************************  *  * plugin_init()  *  * Initialise the plugin. Read all MOTM Messages from Disk to RAM at the  * start each map so that we don't need to do any disk access during the  * game, which should reduce the loading (== lag) on the server  *  * If a custom MOTM Message File exists for the  * current map, read that in and store it in the MOTM list first, then try  * to read the default MOTM file  *  * Establish task to periodically update the MOTM Message  * on the screen  *  *************************************************************************/ public plugin_init() {     g_motmNum = 0 // record of how many Messages we have to cycle through     // Try to read a custom MOTM file for the current map     new currentmap[32]     get_mapname(currentmap, 31)         readMOTM(currentmap)     // reset counter show custom MOTM's     if (g_motmNum) set_cvar_num("motm_counter", 0)     // Read the default MOTM file, this will be shown on every map     readMOTM("default")     // register our MOTM message counter     register_cvar("motm_counter","0")     // set a task to get our MOTM's updated on the screen     set_task(MOTM_TIME, "show_motm", 250, "", 0, "a", 99999)     // Register ourselves with AMX     register_plugin("Message Of The Moment Plugin",             "0.9.4","<Evil>deadBeat")     return PLUGIN_CONTINUE }

Edited for 'small' display, as pointed out by EKS (thks dude, i just learned something else too !!!)

EKS 02-28-2005 09:19

First off when posting code, use [small].

small set_hudmessage(Red, Green, Blue, 0.05, 0.65, 0, 0.02,
MOTM_DURATION, 1.01, 1.1, 3)
Is the functions that contols where the message is placed and its color.
the number 0.05 and 0.65 are the 2d cords on where the message is places. Use my plugin to find the best spot for you, or just guess :)

onedamage 02-28-2005 12:39

Thank you EKS, i'll do it and get it customized as i want.

time to read some scripting tutorials and learn what else i can screw up :lol:


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

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