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

CPrintToChat not working ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
d22tny
New Member
Join Date: Sep 2019
Old 09-20-2019 , 19:32   CPrintToChat not working ?
Reply With Quote #1

Hey guys, i'm trying to make a !vipmenu option, where a vip player can select a weapon for the round.

i have this code :

Code:
#define PLUGIN_AUTHOR "d22tny" 
#define PLUGIN_VERSION "1.0.0" 

#include <sourcemod> 
#include <sdktools> 
#include <colors>

int round;
bool isNotUsed;

public Plugin myinfo =
{
	name = "VIP Menu",
	author = PLUGIN_AUTHOR,
	version = PLUGIN_VERSION,
	description = "weapons for vip", 
	url = "www.laleagane.ro" 
};

public void OnPluginStart()
{
	HookEvent("round_start", roundstart);
	RegAdminCmd("sm_vipmenu", arme, ADMFLAG_CUSTOM1, "Comanda pentru arme VIP"); 
}

public void OnMapStart()
{
	round = 0;
}

public Action roundstart(Handle event, const char[] name, bool dontBroadcast){
	round++;
	isNotUsed = true;
}

public Action arme(int client, int args)
{
	Menu vipmenu = new Menu(VIPMenu_Handler, MENU_ACTIONS_ALL);
	vipmenu.SetTitle("Meniu Arme");
	vipmenu.AddItem("AK47", "AK47");
	vipmenu.AddItem("M4A4", "M4A4");
	vipmenu.AddItem("M4A1-S", "M4A1-S");
	vipmenu.AddItem("AWP", "AWP");
	vipmenu.ExitButton = true;
	vipmenu.Display(client, MENU_TIME_FOREVER);
	
	return Plugin_Handled;
}

public int VIPMenu_Handler(Menu vipmenu, MenuAction action, int param1, int param2)
{
	char choice[32];
	vipmenu.GetItem(param2, choice, sizeof(choice));
	if (action == MenuAction_Select)
	{
		if (StrEqual(choice, "AK47"))
		{
			if(round!=1 && round!= 17 && round!=2 && isNotUsed){
			GivePlayerItem(param1, "weapon_ak47");
			CPrintToChat(param1, "{blue}[Nordic] {red}Ai ales {purple}AK47 {green}!");
			isNotUsed = false;
			} else {
				CPrintToChat(param1, "{blue}[Nordic] {red}Nu poti lua arma {purple}{green}!");
			}
		}
		else if (StrEqual(choice, "M4A4"))
		{
			if(round!=1 && round!= 17 && round!=2 && isNotUsed){
			GivePlayerItem(param1, "weapon_m4a4");
			CPrintToChat(param1, "{blue}[Nordic] {red}Ai ales {purple}M4A4 {green}!");
			isNotUsed = false;
			} else {
				CPrintToChat(param1, "{blue}[Nordic] {red}Nu poti lua arma {purple}{green}!");
			}
		}
		else if (StrEqual(choice, "M4A1-S"))
		{
			if(round!=1 && round!= 17 && round!=2 && isNotUsed){
			GivePlayerItem(param1, "weapon_m4a1_silencer");
			CPrintToChat(param1, "{blue}[Nordic] {red}Ai ales {purple}M4A1 {green}!");
			isNotUsed = false;
			} else {
				CPrintToChat(param1, "{blue}[Nordic] {red}Nu poti lua arma {purple}{green}!");
			}
		}
		else if (StrEqual(choice, "AWP"))
		{	
			if(round!=1 && round!= 17 && round!=2 && isNotUsed){
			GivePlayerItem(param1, "weapon_AWP");
			CPrintToChat(param1, "{blue}[Nordic] {red}Ai ales {purple}AWP {green}!");
			isNotUsed = false;
		} 
			else 
			{
				CPrintToChat(param1, "{blue}[Nordic] {red}Nu poti lua arma {purple}{green}!");
			}
		}
	}
	else if (action == MenuAction_End)
	{
		delete vipmenu;
	}
}
it works, but CPrintToChat does nothing, i get the weapon when using the menu but nothing appears in chat.

and also.. my way of making it usable once per round it's not working.. any ideas ??

Last edited by d22tny; 09-20-2019 at 19:38.
d22tny is offline
TheBOSS
Member
Join Date: Nov 2018
Old 09-21-2019 , 04:11   Re: CPrintToChat not working ?
Reply With Quote #2

#include <csgocolors>

https://gitlab.com/Zipcore/CSGO-Colo...csgocolors.inc

Last edited by TheBOSS; 09-21-2019 at 04:14.
TheBOSS is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 09-21-2019 , 05:12   Re: CPrintToChat not working ?
Reply With Quote #3

You can use only PrintToChat with \x01, \x02 etc colors.

PHP Code:

PrintToChat
(param1" \x0A[Nordic] \x07Ai ales \x03AK47 \x04!"); 
Also, you have a bug within your plugin. Only one vip can use the menu per round.
isNotUsed variable should be isNotUsed[MAXPLAYERS + 1]; so every vip can use the menu only once per round.

Use this:
Spoiler
__________________
Ilusion9 is offline
d22tny
New Member
Join Date: Sep 2019
Old 09-21-2019 , 08:55   Re: CPrintToChat not working ?
Reply With Quote #4

Quote:
Originally Posted by Ilusion9 View Post
You can use only PrintToChat with \x01, \x02 etc colors.

PHP Code:

PrintToChat
(param1" \x0A[Nordic] \x07Ai ales \x03AK47 \x04!"); 
Also, you have a bug within your plugin. Only one vip can use the menu per round.
isNotUsed variable should be isNotUsed[MAXPLAYERS + 1]; so every vip can use the menu only once per round.

Use this:
Spoiler
THANK YOU MATE! i had no idea how to use this PrintToChat function ))
also i was able to get how many weapons i wanted per round, but i figured it out, you never set the bool to true, i managed to set it after you choose a weapon it's true.
thanks mate
d22tny is offline
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 09-22-2019 , 05:49   Re: CPrintToChat not working ?
Reply With Quote #5

Hey!

So I have something bad to say to you. Since panorama version was released, SourceMod updated and then CPrintToChat only allowed only 1 color per chat message, so if more than 1 color it will pick the first one!

So now the best way to get colors is to use some \x'es colors ID's.

Here are the codes that work at the moment: (I deleted the ones that are not compatible now.)
Code:
default (white): \x01
darkred: \x02
purple: \x03
green: \x04
lightgreen: \x05
lime: \x06
red: \x07
grey: \x08
yellow: \x09
gold: \x10
Here you go my man. Hope I could help you.

Best Regards,

SpirT.
__________________
SpirT 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 19:35.


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