Raised This Month: $ Target: $400
 0% 

[SOLVED] How to add colorchat to this ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
T-z3P
Senior Member
Join Date: Apr 2008
Location: Iasi, Romania
Old 04-04-2011 , 15:09   [SOLVED] How to add colorchat to this ?
Reply With Quote #1

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

__________________



Last edited by T-z3P; 04-05-2011 at 10:50.
T-z3P is offline
Send a message via Yahoo to T-z3P Send a message via Skype™ to T-z3P
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-04-2011 , 16:06   Re: [HELP] How to add colorchat to this ?
Reply With Quote #2

http://forums.alliedmods.net/showthread.php?t=94960
__________________
fysiks is offline
T-z3P
Senior Member
Join Date: Apr 2008
Location: Iasi, Romania
Old 04-05-2011 , 01:11   Re: [HELP] How to add colorchat to this ?
Reply With Quote #3

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


T-z3P is offline
Send a message via Yahoo to T-z3P Send a message via Skype™ to T-z3P
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-05-2011 , 01:17   Re: [HELP] How to add colorchat to this ?
Reply With Quote #4

Quote:
Originally Posted by T-z3P View Post
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');
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-05-2011 , 01:29   Re: [HELP] How to add colorchat to this ?
Reply With Quote #5

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

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
T-z3P
Senior Member
Join Date: Apr 2008
Location: Iasi, Romania
Old 04-05-2011 , 08:33   Re: [HELP] How to add colorchat to this ?
Reply With Quote #6

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


T-z3P is offline
Send a message via Yahoo to T-z3P Send a message via Skype™ to T-z3P
wickedd
Veteran Member
Join Date: Nov 2009
Old 04-05-2011 , 08:56   Re: [HELP] How to add colorchat to this ?
Reply With Quote #7

Quote:
Originally Posted by T-z3P View Post
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
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
T-z3P
Senior Member
Join Date: Apr 2008
Location: Iasi, Romania
Old 04-05-2011 , 10:50   Re: [HELP] How to add colorchat to this ?
Reply With Quote #8

Oh , sorry . I've got only chatcolor.inc , withouth the colorchat plugin . Now is working fine .
__________________



Last edited by T-z3P; 04-05-2011 at 10:56.
T-z3P is offline
Send a message via Yahoo to T-z3P Send a message via Skype™ to T-z3P
Reply



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 14:29.


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