AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] How to add colorchat to this ? (https://forums.alliedmods.net/showthread.php?t=154230)

T-z3P 04-04-2011 15:09

[SOLVED] How to add colorchat to this ?
 
Hi . How to add colorchat to this ?

Something like this (the red text is team-color) :
Code:

Last maps played are: fy_dust, fy_snow, de_dust2, de_nuke, cs_italy
PHP Code:

#include <amxmodx>

#define MAX_MAPS    5

new g_MapNames[MAX_MAPS][34]

public 
plugin_init() 
{
    
register_plugin("last played maps""0.2""ConnorMcLeod")
    
register_clcmd("amx_lastmaps""lastmapsCmd")
    
register_clcmd("say /lastmaps""lastmapsSayCmd")
}

public 
plugin_cfg() 
{
    new 
szLastMapsFile[64]
    
    
get_localinfo("amxx_configsdir"szLastMapsFile63)
    
format(szLastMapsFile63"%s/lastmaps.txt"szLastMapsFile)

    new 
File fopen(szLastMapsFile"rt")
    new 
i
    
new Temp[34]
    if(
File)
    {
        for(
i=0i<MAX_MAPSi++)
        {
            if(!
feof(File))
            {
                
fgets(FileTemp33)
                
replace(Temp33"^n""")
                
formatex(g_MapNames[i], 33Temp)
            }
        }
        
fclose(File)
    }

    
delete_file(szLastMapsFile)

    new 
CurrentMap[34]
    
get_mapname(CurrentMap33)

    
File fopen(szLastMapsFile"wt")
    if(
File)
    {
        
formatex(Temp33"%s^n"CurrentMap)
        
fputs(FileTemp)
        for(
i=0i<MAX_MAPS-1i++)
        {
            
CurrentMap g_MapNames[i]
            if(!
CurrentMap[0])
                break
            
formatex(Temp33"%s^n"CurrentMap)
            
fputs(FileTemp)
            
// ?? fprintf
        
}
        
fclose(File)
    }
}

public 
lastmapsCmd(id
{
    new 
LastMaps[256], n
    n 
+= formatex(LastMaps[n], 255-n"Last maps played are :")
    for(new 
ii<MAX_MAPSi++)
    {
        if(!
g_MapNames[i][0])
            break
        
+= formatex(LastMaps[n], 255-n"^n%s"g_MapNames[i])
    }
    
client_print(idprint_consoleLastMaps)
    return 
PLUGIN_HANDLED
}

public 
lastmapsSayCmd(id
{
    new 
LastMaps[192]
    new 
formatex(LastMaps[n], 191-n"Last maps played are :")
    for(new 
ii<MAX_MAPSi++)
    {
        if(!
g_MapNames[i][0])
        {
            
+= formatex(LastMaps[n-1], 191-n+1".")
            break
        }
        
+= formatex(LastMaps[n], 191-n" %s%s"g_MapNames[i], i+== MAX_MAPS "." ",")
    }
    
client_print(idprint_chatLastMaps)
    return 
PLUGIN_CONTINUE



fysiks 04-04-2011 16:06

Re: [HELP] How to add colorchat to this ?
 
http://forums.alliedmods.net/showthread.php?t=94960

T-z3P 04-05-2011 01:11

Re: [HELP] How to add colorchat to this ?
 
I know Connor's stock . I've tried this and it's not working (spaces appear in front of the 'last' word and after ':' and there is no color in the message) :
PHP Code:

+= formatex(LastMaps[n], 255-n"^x04Last maps played are :^x03"

PS : I don't really know how to use the stock here .

Exolent[jNr] 04-05-2011 01:17

Re: [HELP] How to add colorchat to this ?
 
Quote:

Originally Posted by T-z3P (Post 1444643)
I know Connor's stock . I've tried this and it's not working (spaces appear in front of the 'last' word and after ':' and there is no color in the message) :
PHP Code:

+= formatex(LastMaps[n], 255-n"^x04Last maps played are :^x03"

PS : I don't really know how to use the stock here .

Sometimes, color codes can be broken with text that is following the end of it because it is combined to the color code so it turns into something other than a color code.
To fix this, you can insert it as a character by formatting instead of including it in the string.

Example:
Code:
formatex(string, charsmax(string), "%cThis is green%c and this is normal.", '^x04', '^x03');

ConnorMcLeod 04-05-2011 01:29

Re: [HELP] How to add colorchat to this ?
 
PHP Code:

#include <amxmodx>
#include <chatcolor>

#define MAX_MAPS    5

new g_szMapNames[MAX_MAPS][32]

public 
plugin_init() 
{
    
register_plugin("last played maps""0.3.0""ConnorMcLeod")
    
register_clcmd("amx_lastmaps""lastmapsCmd")
    
register_clcmd("say /lastmaps""lastmapsSayCmd")
}

public 
plugin_cfg() 
{
    new 
szLastMapsFile[64]

    
get_localinfo("amxx_configsdir"szLastMapsFilecharsmax(szLastMapsFile))
    
add(szLastMapsFilecharsmax(szLastMapsFile), "/lastmaps.txt")

    new 
File fopen(szLastMapsFile"rt")
    new 
i
    
new szTemp[32]
    if(
File)
    {
        for(
i=0i<MAX_MAPSi++)
        {
            if(!
feof(File))
            {
                
fgets(FileszTempcharsmax(szTemp))
                
trim(szTemp)
                
formatex(g_szMapNames[i], charsmax(g_szMapNames[]), szTemp)
            }
        }
        
fclose(File)
    }

    new 
szCurrentMap[32]
    
get_mapname(szCurrentMapcharsmax(szCurrentMap))

    
File fopen(szLastMapsFile"wt")
    if(
File)
    {
        
fprintf(File"%s^n"szCurrentMap)
        for(
i=0i<MAX_MAPS-1i++)
        {
            if( !
copy(szCurrentMapcharsmax(szCurrentMap), g_szMapNames[i]) )
            {
                break
            }
            
fprintf(File"%s^n"szCurrentMap)
        }
        
fclose(File)
    }
}

public 
lastmapsCmd(id
{
    new 
LastMaps[256]
    new 
formatex(LastMapscharsmax(LastMaps), "Last maps played are :")
    for(new 
ii<MAX_MAPSi++)
    {
        if(!
g_szMapNames[i][0])
        {
            break
        }
        
+= formatex(LastMaps[n], charsmax(LastMaps)-n"^n%s"g_szMapNames[i])
    }
    
client_print(idprint_consoleLastMaps)
    return 
PLUGIN_HANDLED
}

public 
lastmapsSayCmd(id
{
    new 
LastMaps[192]
    new 
formatex(LastMapscharsmax(LastMaps), "^4Last maps played are :^3")
    for(new 
ii<MAX_MAPSi++)
    {
        if(!
g_szMapNames[i][0])
        {
            
LastMaps[--n] = '.'
            
break
        }
        
+= formatex(LastMaps[n], charsmax(LastMaps)-n" %s%c"g_szMapNames[i], i+== MAX_MAPS '.' ',')
    }
    
client_print_color(idDontChangeLastMaps)
    return 
PLUGIN_CONTINUE



T-z3P 04-05-2011 08:33

Re: [HELP] How to add colorchat to this ?
 
Thank you all for your answers .

@ Connor : Compiled ok , but I have this error
Code:

L 04/05/2011 - 15:30:18: [AMXX] Plugin "last_maps.amxx" failed to load: Module/Library "chatcolor" required for plugin.  Check modules.ini.

wickedd 04-05-2011 08:56

Re: [HELP] How to add colorchat to this ?
 
Quote:

Originally Posted by T-z3P (Post 1444726)
Thank you all for your answers .

@ Connor : Compiled ok , but I have this error
Code:

L 04/05/2011 - 15:30:18: [AMXX] Plugin "last_maps.amxx" failed to load: Module/Library "chatcolor" required for plugin.  Check modules.ini.

You need ColorChat native and stock :)

T-z3P 04-05-2011 10:50

Re: [HELP] How to add colorchat to this ?
 
Oh , sorry . I've got only chatcolor.inc , withouth the colorchat plugin . Now is working fine .


All times are GMT -4. The time now is 14:29.

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