Raised This Month: $12 Target: $400
 3% 

Problem with client_print_color


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Grav3yardman
Member
Join Date: Oct 2021
Old 10-29-2021 , 12:17   Problem with client_print_color
Reply With Quote #1

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 }
*/
Grav3yardman is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 10-29-2021 , 12:24   Re: Problem with client_print_color
Reply With Quote #2

Quote:
Originally Posted by Grav3yardman View Post
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
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
Grav3yardman
Member
Join Date: Oct 2021
Old 10-29-2021 , 12:42   Re: Problem with client_print_color
Reply With Quote #3

Can you explain what I need to do because I am a noob in this?
Grav3yardman is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 10-29-2021 , 12:47   Re: Problem with client_print_color
Reply With Quote #4

Example:

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


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


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
Grav3yardman
Member
Join Date: Oct 2021
Old 10-29-2021 , 12:56   Re: Problem with client_print_color
Reply With Quote #5

I did just like you but I got 4 errors
Grav3yardman is offline
Grav3yardman
Member
Join Date: Oct 2021
Old 10-29-2021 , 12:56   Re: Problem with client_print_color
Reply With Quote #6

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 }
*/
Grav3yardman is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 10-29-2021 , 12:58   Re: Problem with client_print_color
Reply With Quote #7

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


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
Grav3yardman
Member
Join Date: Oct 2021
Old 10-29-2021 , 13:01   Re: Problem with client_print_color
Reply With Quote #8

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 is offline
Grav3yardman
Member
Join Date: Oct 2021
Old 10-29-2021 , 13:40   Re: Problem with client_print_color
Reply With Quote #9

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"

Last edited by Grav3yardman; 10-29-2021 at 13:55.
Grav3yardman is offline
Grav3yardman
Member
Join Date: Oct 2021
Old 10-30-2021 , 08:36   Re: Problem with client_print_color
Reply With Quote #10

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();
  }
 }
}

Last edited by Grav3yardman; 10-30-2021 at 08:36.
Grav3yardman is offline
Reply


Thread Tools
Display Modes

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 01:28.


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