/*
 * Bud-froggy Productions -- April 22, 2001
 * Rainbow -- Using Karels ideas and dll code :D
 * Multicolored csays!!!
 * Thx to yensid for random trouble shooting :)
 */
 
/*
 * Format: admin_rainbow startingcolor endingcolor message
 * example: admin_rainbow r c The Frawg did it again
 * will print "The frawg did it again" starting in red and finnishing in cyan
 */
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
#define ACCESS_RSAY 64
 
new STRING_VERSION[MAX_DATA_LENGTH] = "2.50.c";
 
public admin_rsay(HLCommand,HLData,HLUserName,UserIndex)
{
    new Command[MAX_COMMAND_LENGTH];
    new Data[MAX_DATA_LENGTH];
    new User[MAX_NAME_LENGTH];
    new Color[MAX_DATA_LENGTH];
    new Color1[MAX_DATA_LENGTH];
    new Color2[MAX_DATA_LENGTH];
    new Message[MAX_DATA_LENGTH];
    new FullMessage[MAX_DATA_LENGTH];
 
 
    new iRedStart;
    new iGreenStart;
    new iBlueStart;
    new iRedEnd;
    new iGreenEnd;
    new iBlueEnd;
 
    new Color1exists = 0;
    new Color2exists = 0;
 
    convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
    convert_string(HLData,Data,MAX_DATA_LENGTH);
    convert_string(HLUserName,User,MAX_NAME_LENGTH);
 
    strbreak(Data,Color1,Color,MAX_DATA_LENGTH);
    strbreak(Color,Color2,Message,MAX_DATA_LENGTH);
 
    /* Go through colors and find the start and ending colors */
 
    if (streq (Color1,"r")==1)          /* red 1 */
    {
        iRedStart = 255;
        iGreenStart = 10;
        iBlueStart = 10;
        Color1exists = 1;
    } if (streq (Color2,"r")==1) {          /* red 2 */
        iRedEnd = 255;
        iGreenEnd = 10;
        iBlueEnd = 10;
        Color2exists = 1;
 
    } if (streq (Color1,"g")==1) {      /* green 1 */
        iRedStart = 10;
        iGreenStart = 255;
        iBlueStart = 10;
        Color1exists = 1;
    } if (streq (Color2,"g")==1) {      /* green 2 */
        iRedEnd = 10;
        iGreenEnd = 255;
        iBlueEnd = 10;
        Color2exists = 1;
 
    } if (streq (Color1,"b")==1) {      /* blue 1 */
        iRedStart = 10;
        iGreenStart = 10;
        iBlueStart = 255;
        Color1exists = 1;
    } if (streq (Color2,"b")==1) {      /* blue 2 */
        iRedEnd = 10;
        iGreenEnd = 10;
        iBlueEnd = 255;
        Color2exists = 1;
 
    } if (streq (Color1,"c")==1) {      /* cyan 1 */
        iRedStart = 10;
        iGreenStart = 255;
        iBlueStart = 255;
        Color1exists = 1;
    } if (streq (Color2,"c")==1) {      /* cyan 2 */
        iRedEnd = 10;
        iGreenEnd = 255;
        iBlueEnd = 255;
        Color2exists = 1;
 
    } if (streq (Color1,"m")==1) {      /* magenta 1 */
        iRedStart = 255;
        iGreenStart = 10;
        iBlueStart = 255;
        Color1exists = 1;
    } if (streq (Color2,"m")==1) {      /* magenta 2 */
        iRedEnd = 255;
        iGreenEnd = 10;
        iBlueEnd = 255;
        Color2exists = 1;
 
    } if (streq (Color1,"w")==1) {      /* white 1 */
        iRedStart = 255;
        iGreenStart = 255;
        iBlueStart = 255;
        Color1exists = 1;
    } if (streq (Color2,"w")==1) {      /* white 2 */
        iRedEnd = 255;
        iGreenEnd = 255;
        iBlueEnd = 255;
        Color2exists = 1;
 
    } if (streq (Color1,"p")==1) {      /* pink 1 */
        iRedStart = 252;
        iGreenStart = 60;
        iBlueStart = 200;
        Color1exists = 1;
    } if (streq (Color2,"p")==1) {      /* pink 2 */
        iRedEnd = 252;
        iGreenEnd = 60;
        iBlueEnd = 200;
        Color2exists = 1;
 
    } if (streq (Color1,"o")==1) {      /* orange 1 */
        iRedStart = 255;
        iGreenStart = 100;
        iBlueStart = 10;
        Color1exists = 1;
    } if (streq (Color2,"o")==1) {      /* orange 2 */
        iRedEnd = 255;
        iGreenEnd = 100;
        iBlueEnd = 10;
        Color2exists = 1;
 
    } if (streq (Color1,"t")==1) {      /* USELESS will make text fade in */
        iRedStart = 0;
        iGreenStart = 0;
        iBlueStart = 0;
        Color1exists = 1;
    } if (streq (Color2,"t")==1) {      /* transparent (make the text fade out also) */
        iRedEnd = 0;
        iGreenEnd = 0;
        iBlueEnd = 0;
        Color2exists = 1;
    }
 
    if (Color1exists == 1 && Color2exists==1)
    {
        rainbow( Message, 6, iRedStart, iGreenStart, iBlueStart, iRedEnd, iGreenEnd, iBlueEnd);
 
 
    } else {        /* We have to put everything back on to the Message... */
 
        snprintf(FullMessage, MAX_DATA_LENGTH, "%s %s %s", Color1, Color2, Message);
        iRedStart = 255;
        iGreenStart = 10;
        iBlueStart = 10;
        iRedEnd = 10;
        iGreenEnd = 10;
        iBlueEnd = 255;
 
        rainbow( FullMessage, 6, iRedStart, iGreenStart, iBlueStart, iRedEnd, iGreenEnd, iBlueEnd);
    }
 
 
    log_command(User,Command,Data);
    return PLUGIN_HANDLED;
}
 
public plugin_init() {
    plugin_registerinfo("Rainbow Colors!","No more boring csays :]",STRING_VERSION);
    plugin_registercmd("admin_rsay", "admin_rsay", ACCESS_RSAY, "admin_rsay <C1> <C2> <Message>  Print rainbow fading csays");
    return PLUGIN_CONTINUE;
}