AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problem with client_print_color (https://forums.alliedmods.net/showthread.php?t=334952)

Grav3yardman 10-29-2021 12:17

Problem with client_print_color
 
Hi
I inserted colors for the text in the script. When I do the compile there are no errors, but when I log in to the server and type timeleft nothing happens (The text from the script that should be in color does not appear). Does anyone know what the problem is?
The code I use is:

Code:

#include<amxmodx>
#include<amxmisc>

new MaxRounds
new RoundCount

public plugin_init() {
       
        register_plugin("timeleft", "", "Muhammet Kaya")
        register_logevent("round_end", 2, "1=Round_End")
        register_event("TextMsg", "new_map_or_restart", "a", "2&#Game_C", "2&#Game_w")
        register_clcmd("say timeleft","ShowRoundsLeft")
        MaxRounds = get_cvar_pointer("mp_maxrounds")
}
public round_end()
{
        RoundCount++
}

public new_map_or_restart()
{
        RoundCount = 0
}
public ShowRoundsLeft(id)
{
        if(get_pcvar_num(MaxRounds) == 0)
        {
                client_print_color(id,print_chat, "!g[KGB] !nNema ogranicenja rundi!")
        }
        if(get_pcvar_num(MaxRounds) >0)
        {
                client_print_color(id,print_chat, "!g[KGB] !nPreostalo rundi: !t%d", get_pcvar_num(MaxRounds) - RoundCount)
        }
}


/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1050\\ f0\\ fs16 \n\\ par }
*/


iceeedr 10-29-2021 12:24

Re: Problem with client_print_color
 
Quote:

Originally Posted by Grav3yardman (Post 2761961)
Hi
I inserted colors for the text in the script. When I do the compile there are no errors, but when I log in to the server and type timeleft nothing happens (The text from the script that should be in color does not appear). Does anyone know what the problem is?
The code I use is:

Code:

#include<amxmodx>
#include<amxmisc>

new MaxRounds
new RoundCount

public plugin_init() {
       
        register_plugin("timeleft", "", "Muhammet Kaya")
        register_logevent("round_end", 2, "1=Round_End")
        register_event("TextMsg", "new_map_or_restart", "a", "2&#Game_C", "2&#Game_w")
        register_clcmd("say timeleft","ShowRoundsLeft")
        MaxRounds = get_cvar_pointer("mp_maxrounds")
}
public round_end()
{
        RoundCount++
}

public new_map_or_restart()
{
        RoundCount = 0
}
public ShowRoundsLeft(id)
{
        if(get_pcvar_num(MaxRounds) == 0)
        {
                client_print_color(id,print_chat, "!g[KGB] !nNema ogranicenja rundi!")
        }
        if(get_pcvar_num(MaxRounds) >0)
        {
                client_print_color(id,print_chat, "!g[KGB] !nPreostalo rundi: !t%d", get_pcvar_num(MaxRounds) - RoundCount)
        }
}


/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1050\\ f0\\ fs16 \n\\ par }
*/


https://www.amxmodx.org/api/amxmodx/client_print_color

Grav3yardman 10-29-2021 12:42

Re: Problem with client_print_color
 
Can you explain what I need to do because I am a noob in this?

iceeedr 10-29-2021 12:47

Re: Problem with client_print_color
 
Example:

Code:

client_print_color(id,print_chat, "!g[KGB] !nNema ogranicenja rundi!")
:arrow:

Code:

client_print_color(id,print_team_default, "^4[KGB] ^1Nema ogranicenja rundi!")

Grav3yardman 10-29-2021 12:56

Re: Problem with client_print_color
 
I did just like you but I got 4 errors

Grav3yardman 10-29-2021 12:56

Re: Problem with client_print_color
 
Code:

#include<amxmodx>
#include<amxmisc>
#include <chatcolor>

new MaxRounds
new RoundCount

public plugin_init() {
       
        register_plugin("timeleft", "", "Muhammet Kaya")
        register_logevent("round_end", 2, "1=Round_End")
        register_event("TextMsg", "new_map_or_restart", "a", "2&#Game_C", "2&#Game_w")
        register_clcmd("say timeleft","ShowRoundsLeft")
        MaxRounds = get_cvar_pointer("mp_maxrounds")
}
public round_end()
{
        RoundCount++
}

public new_map_or_restart()
{
        RoundCount = 0
}
public ShowRoundsLeft(id)
{
        if(get_pcvar_num(MaxRounds) == 0)
        {
                client_print_color(id,print_team_default, "^4[KGB] ^1Nema ogranicenja rundi!")
        }
        if(get_pcvar_num(MaxRounds) >0)
        {
                client_print_color(id,print_team_default, "^4[KGB] ^1Preostalo rundi: ^3%d", get_pcvar_num(MaxRounds) - RoundCount)
        }
}


/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1050\\ f0\\ fs16 \n\\ par }
*/


iceeedr 10-29-2021 12:58

Re: Problem with client_print_color
 
Now that I see you are using the "chatcolor" include

If you are using amx version 1.9 or higher, you don't need this include, if you are using 1.8.2 or lower put the include here so we can help.

Grav3yardman 10-29-2021 13:01

Re: Problem with client_print_color
 
I add this include but i dont know how to use it
Code:

#if defined _chatcolor_included
  #endinput
#endif
#define _chatcolor_included

#pragma reqlib chatcolor

/* ColorChat Support */
/* Replace in .sma line #include <colorchat> with #include <chatcolor> */
// #define NORMAL 0 // use client_print or start sentence with ^1 and set sender to same value as index
// #define GREEN 0 // start sentence with ^4
// #define TEAM_COLOR 0 // determine who is sender and set ti that id, or choose a color
#define RED Red
#define BLUE Blue
#define GREY Grey
#define ColorChat client_print_color
/* ColorChat Support */

enum
{
        Grey = 33,
        Red,
        Blue
}

/**
 * Sends coloured message to player. Set index to 0 to send text globaly..
 * An example would be: client_print_color(id, Red, "^4This is green ^3this is red, ^1this is your default chat text color");
 * Look at the above enum for second parameter lists when you don't pass a player index in it.
 *
 * @param index                        This is the player index (1 to maxplayer) you want to send the message, use 0 to send to all players.
 * @param sender                This is the player index you want to use the team color, see above enum if you want to force a color.
 * @param fmt                        Format string in which patterns gonna be replaced with argument list.
 *
 * @return                                Returns 1 if the message has been sent, 0 if the index specified is a not connected player, or if a global message has not been sent because there are no humans players.
 */
native client_print_color(index, sender, const fmt[], any:...);

/**
 * Coloured register_dictionary version
 *
 * @param filename                Dictionary file to register.
 *                                                The file should be in "addons/amxx/data/lang/"
 *                                                only the name needs to be given.
 *                                                (e.g. register_dictionary("file.txt") will be addons/amxx/data/file.txt).
 *
 * @return                                Returns 1 on success, 0 if register_dictionary has returned 0 or if file can't be opened.
 */
native register_dictionary_colored(const filename[]);


Grav3yardman 10-29-2021 13:40

Re: Problem with client_print_color
 
Do I need to delete this include or can I use it?
I get this error when I compile this
Quote:

fatal error 100: cannot read from file: "chatcolor"

Grav3yardman 10-30-2021 08:36

Re: Problem with client_print_color
 
I was able to fix the script even when the compile has no errors, but when I log in to the server and type timeleft (before that I type the command mp_maxrounds 15) it only shows me "[KGB] preostalo rundi 33" and that display every round.
Can anybody help?
Here is the script:
Code:

#include<amxmodx>
#include<amxmisc>

new MaxRounds
new RoundCount

public plugin_init() {
       
        register_plugin("timeleft", "", "Muhammet Kaya")
        register_logevent("round_end", 2, "1=Round_End")
        register_event("TextMsg", "new_map_or_restart", "a", "2&#Game_C", "2&#Game_w")
        register_clcmd("say timeleft","ShowRoundsLeft")
        MaxRounds = get_cvar_pointer("mp_maxrounds")
}
public round_end()
{
        RoundCount++
}

public new_map_or_restart()
{
        RoundCount = 0
}
public ShowRoundsLeft(id)
{
        if(get_pcvar_num(MaxRounds) == 0)
        {
                client_print_color(id,print_chat,"!g[KGB] !nNema ogranicenja rundi!")
        }
        if(get_pcvar_num(MaxRounds) >0)
        {
                client_print_color(id,print_chat,"!g[KGB] !nPreostalo rundi: !t%d", get_pcvar_num(MaxRounds) - RoundCount)
        }
}

stock client_print_color(id, type, const text[], any:...)
{
 if(type == print_chat)
 {
  new g_iMsgidSayText;
  g_iMsgidSayText = get_user_msgid("SayText");

  new szMsg[191], iPlayers[32], iCount = 1;
  vformat(szMsg, charsmax(szMsg), text, 3);

  replace_all(szMsg, charsmax(szMsg), "!g","^x04");
  replace_all(szMsg, charsmax(szMsg), "!n","^x01");
  replace_all(szMsg, charsmax(szMsg), "!t","^x03");

  if(id)
  iPlayers[0] = id;
  else
  get_players(iPlayers, iCount, "ch");

  for(new i = 0 ; i < iCount ; i++)
  {
  if(!is_user_connected(iPlayers[i]))
    continue;
 
  message_begin(MSG_ONE_UNRELIABLE, g_iMsgidSayText, _, iPlayers[i]);
  write_byte(iPlayers[i]);
  write_string(szMsg);
  message_end();
  }
 }
}



All times are GMT -4. The time now is 11:38.

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