Junior Member
|
07-28-2017
, 18:09
Re: What am I doing wrong?
|
#7
|
Quote:
Originally Posted by BraveFox
PHP Code:
#include <sourcemod>
#include <clientprefs>
#include <scp>
#include <colors_csgo>
#pragma semicolon 1/
#pragma dynamic 131072
#define PLUGIN_VERSION "1.0"
Handle gH_Cookie = INVALID_HANDLE;
Handle gH_Cookie2 = INVALID_HANDLE;
Handle gH_Cookie3 = INVALID_HANDLE;
Handle gH_Cookie4 = INVALID_HANDLE;
public Plugin:myinfo =
{
name = "hP Chat",
author = "Shavit + AntiTeal + Ice_",
description = "Custom tags, chat colors, & name colors.",
version = PLUGIN_VERSION,
url = "https://forums.alliedmods.net/, http://steamcommunity.com/profiles/76561198117802354"
}
public void OnPluginStart()
{
gH_Cookie = RegClientCookie("sm_chatcolors_cookie", "Contains the used chat color", CookieAccess_Protected);
gH_Cookie2 = RegClientCookie("sm_chattag_cookie", "Contains the used chat tag.", CookieAccess_Protected);
gH_Cookie3 = RegClientCookie("sm_suffix_cookie", "Contains the used chat suffix.", CookieAccess_Protected);
RegAdminCmd("sm_sufixo", Command_Suffix, ADMFLAG_GENERIC, "Allows the player to change their ChatTag.");
gH_Cookie4 = RegClientCookie("sm_namecolor_cookie", "Contains the used name color", CookieAccess_Protected);
CreateConVar("sm_chatextender_version", PLUGIN_VERSION, "Plugin version", FCVAR_DONTRECORD|FCVAR_NOTIFY);
RegAdminCmd("sm_cores", Command_Menus, ADMFLAG_ROOT);
}
public Action Command_Menus(int client, int args)
{
Handle g_hMenuCS = CreateMenu(MenuSelectHandler);
SetMenuTitle(g_hMenuCS, "Escolha o que quer colorir");
AddMenuItem(g_hMenuCS, "ChatColors", "Chat");
AddMenuItem(g_hMenuCS, "NameColors", "Nome");
SetMenuExitButton(g_hMenuCS, true);
DisplayMenu(g_hMenuCS, client, 20);
}
public MenuSelectHandler(Handle g_hMenuCS, MenuAction maAction, int client, int choice)
{
if (maAction == MenuAction_Select)
{
char sChoice[64];
GetMenuItem(g_hMenuCS, choice, sChoice, sizeof(sChoice));
if(StrEqual(sChoice, "ChatColors"))
{
Handle g_hMenuCC = CreateMenu(MenuHandler_Colors, MENU_ACTIONS_ALL);
SetMenuTitle(g_hMenuCC, "Selecione a cor do chat:");
AddMenuItem(g_hMenuCC, "none", "Padrão");
AddMenuItem(g_hMenuCC, "\x02", "Vermelho");
AddMenuItem(g_hMenuCC, "\x03", "Cor do Time");
AddMenuItem(g_hMenuCC, "\x04", "Verde");
AddMenuItem(g_hMenuCC, "\x05", "Verde Claro");
AddMenuItem(g_hMenuCC, "\x06", "Limão");
AddMenuItem(g_hMenuCC, "\x07", "Vermelho Claro");
AddMenuItem(g_hMenuCC, "\x08", "Cinza");
AddMenuItem(g_hMenuCC, "\x09", "Oliva");
AddMenuItem(g_hMenuCC, "\x0B", "Azul Claro");
AddMenuItem(g_hMenuCC, "\x0C", "Azul");
AddMenuItem(g_hMenuCC, "\x0C", "Roxo");
AddMenuItem(g_hMenuCC, "\x0E", "Rosa");
AddMenuItem(g_hMenuCC, "\x10", "Dourado");
AddMenuItem(g_hMenuCC, "\x0F", "Laranja");
SetMenuExitButton(g_hMenuCC, true);
DisplayMenu(g_hMenuCC, client, 20);
}
if(StrEqual(sChoice, "NameColors"))
{
Handle g_hMenuCN = CreateMenu(MenuHandler_NameColor, MENU_ACTIONS_ALL);
SetMenuTitle(g_hMenuCN, "Selecione a cor do nome:");
AddMenuItem(g_hMenuCN, "none", "Padrão");
AddMenuItem(g_hMenuCN, "\x02", "Vermelho");
AddMenuItem(g_hMenuCN, "\x03", "Cor do Time");
AddMenuItem(g_hMenuCN, "\x04", "Verde");
AddMenuItem(g_hMenuCN, "\x05", "Verde Claro");
AddMenuItem(g_hMenuCN, "\x06", "Limão");
AddMenuItem(g_hMenuCN, "\x07", "Vermelho Claro");
AddMenuItem(g_hMenuCN, "\x08", "Cinza");
AddMenuItem(g_hMenuCN, "\x09", "Oliva");
AddMenuItem(g_hMenuCN, "\x0B", "Azul Claro");
AddMenuItem(g_hMenuCN, "\x0C", "Azul");
AddMenuItem(g_hMenuCN, "\x0C", "Roxo");
AddMenuItem(g_hMenuCN, "\x0E", "Rosa");
AddMenuItem(g_hMenuCN, "\x10", "Dourado");
AddMenuItem(g_hMenuCN, "\x0F", "Laranja");
SetMenuExitButton(g_hMenuCN, true);
DisplayMenu(g_hMenuCN, client, 20);
}
else if(maAction == MenuAction_End)
{
CloseHandle(g_hMenuCS);
}
}
}
public int MenuHandler_Colors(Handle g_hMenuCC, MenuAction maAction, int client, int choice)
{
if(maAction == MenuAction_Select)
{
char sChoice[8];
GetMenuItem(g_hMenuCC, choice, sChoice, 8);
if(StrEqual(sChoice, "none"))
{
FormatEx(sChoice, 8, "\x01");
}
if(StrEqual(sChoice, "\x03"))
{
CPrintToChat(client, " \x0C[hP Chat]\x01 A cor do seu chat combinará com a cor da sua equipe.");
}
else
{
CPrintToChat(client, " \x0C[hP Chat]\x01 Você selecionou %sesta cor\x01.", sChoice);
}
SetClientCookie(client, gH_Cookie, sChoice);
}
else if(maAction == MenuAction_End)
{
CloseHandle(g_hMenuCC);
}
}
public int MenuHandler_NameColor(Handle g_hMenuCN, MenuAction maAction, int client, int choice)
{
if(maAction == MenuAction_Select)
{
char sChoice[8];
GetMenuItem(g_hMenuCN, choice, sChoice, 8);
SetClientCookie(client, gH_Cookie4, sChoice);
if(StrEqual(sChoice, "none"))
{
FormatEx(sChoice, 8, "\x01");
}
if(StrEqual(sChoice, "\x03"))
{
CPrintToChat(client, " \x0C[hP Chat]\x01 Sua cor do seu nome combinará com a cor da sua equipe.");
}
else
{
CPrintToChat(client, " \x0C[hP Chat]\x01 Você selecionou %sesta cor\x01.", sChoice);
}
}
else if(maAction == MenuAction_End)
{
CloseHandle(g_hMenuCN);
}
}
stock bool:IsValidClient(client) {
return (client > 0 && client <= MaxClients);
}
public Action Command_Tag(int client, int args)
{
if (IsValidClient(client))
{
if (args < 1)
{
ReplyToCommand(client, "\x0C[hP Chat]\x01 Uso: sm_tag <tag>.");
return Plugin_Handled;
}
char arg[32];
GetCmdArg(1, arg, sizeof(arg));
ReplaceString(arg, sizeof(arg), "{teamcolor}", "\x03", false);
SetClientCookie(client, gH_Cookie2, arg);
if(StrEqual(arg, "none", false))
{
CPrintToChat(client, " \x0B[hP Chat]\x01 Você removeu sua tag.");
return Plugin_Handled;
}
CPrintToChat(client, " \x0B[hP Chat]\x01 Você selecionou a tag: '%s\x01'.", arg);
return Plugin_Handled;
}
return Plugin_Handled;
}
public Action Command_Suffix(int client, int args)
{
if (IsValidClient(client))
{
if (args < 1)
{
ReplyToCommand(client, "\x0C[hP Chat]\x01 Uso: sm_sufixo <tag>.");
return Plugin_Handled;
}
char arg[32];
GetCmdArg(1, arg, sizeof(arg));
ReplaceString(arg, sizeof(arg), "{teamcolor}", "\x03", false);
SetClientCookie(client, gH_Cookie3, arg);
if(StrEqual(arg, "none", false))
{
CPrintToChat(client, " \x0B[hP Chat]\x01 Você removeu seu sufixo.");
return Plugin_Handled;
}
CPrintToChat(client, " \x0C[hP Chat]\x01 Você selecionou o sufixo: '%s\x01'.", arg);
return Plugin_Handled;
}
return Plugin_Handled;
}
public Action OnChatMessage(int &client, Handle hRecipients, char[] sName, char[] sMessage)
{
if(CheckCommandAccess(client, "sm_cores", ADMFLAG_GENERIC))
{
char sCookie[8];
GetClientCookie(client, gH_Cookie, sCookie, sizeof(sCookie));
char sCookie2[32];
GetClientCookie(client, gH_Cookie2, sCookie2, sizeof(sCookie2));
char sCookie3[32];
GetClientCookie(client, gH_Cookie3, sCookie3, sizeof(sCookie3));
char sCookie4[8];
GetClientCookie(client, gH_Cookie4, sCookie4, sizeof(sCookie4));
if(StrEqual(sCookie, "") || StrEqual(sCookie, "none"))
{
if(StrEqual(sCookie2, "") || StrEqual(sCookie2, "none"))
{
if(StrEqual(sCookie3, "") || StrEqual(sCookie3, "none"))
{
if(StrEqual(sCookie4, "") || StrEqual(sCookie4, "none"))
{
return Plugin_Continue;
}
}
}
}
if(StrEqual(sCookie2, "") || StrEqual(sCookie2, "none"))
{
strcopy(sCookie2, sizeof(sCookie2), "");
}
if(StrEqual(sCookie3, "") || StrEqual(sCookie3, "none"))
{
strcopy(sCookie3, sizeof(sCookie3), "");
}
if(StrEqual(sCookie4, "") || StrEqual(sCookie4, "none"))
{
strcopy(sCookie4, sizeof(sCookie3), "\x03");
}
Format(sMessage, MAXLENGTH_INPUT, "%s%s", sCookie, sMessage);
CFormat(sMessage, MAXLENGTH_INPUT);
Format(sName, MAXLENGTH_INPUT, "%s%s%s%s", sCookie2, sCookie4, sName, sCookie3);
CFormat(sName, MAXLENGTH_INPUT);
return Plugin_Changed;
}
return Plugin_Continue;
}
Should fix your problem.
Added:
PHP Code:
char sChoice[64];
GetMenuItem(g_hMenuCS, choice, sChoice, sizeof(sChoice));
|
Fixed
PHP Code:
#include <sourcemod>
#include <clientprefs>
#include <scp>
#include <colors_csgo>
#pragma semicolon 1
#pragma dynamic 131072
#define PLUGIN_VERSION "1.0"
Handle gH_Cookie = INVALID_HANDLE;
Handle gH_Cookie2 = INVALID_HANDLE;
Handle gH_Cookie3 = INVALID_HANDLE;
Handle gH_Cookie4 = INVALID_HANDLE;
public Plugin:myinfo =
{
name = "hP Chat",
author = "Shavit + AntiTeal + Ice_",
description = "Custom tags, chat colors, & name colors.",
version = PLUGIN_VERSION,
url = "https://forums.alliedmods.net/, http://steamcommunity.com/profiles/76561198117802354"
}
public void OnPluginStart()
{
gH_Cookie = RegClientCookie("sm_chatcolors_cookie", "Contains the used chat color", CookieAccess_Protected);
gH_Cookie2 = RegClientCookie("sm_chattag_cookie", "Contains the used chat tag.", CookieAccess_Protected);
RegAdminCmd("sm_prefixo", Command_Tag, ADMFLAG_GENERIC, "Allows the player to change their ChatTag.");
gH_Cookie3 = RegClientCookie("sm_suffix_cookie", "Contains the used chat suffix.", CookieAccess_Protected);
RegAdminCmd("sm_sufixo", Command_Suffix, ADMFLAG_GENERIC, "Allows the player to change their ChatTag.");
gH_Cookie4 = RegClientCookie("sm_namecolor_cookie", "Contains the used name color", CookieAccess_Protected);
CreateConVar("sm_chatextender_version", PLUGIN_VERSION, "Plugin version", FCVAR_DONTRECORD|FCVAR_NOTIFY);
RegAdminCmd("sm_cores", Command_Menus, ADMFLAG_GENERIC, "Open menu");
}
public Action Command_Menus(int client, int args)
{
Handle g_hMenuCS = CreateMenu(MenuSelectHandler);
SetMenuTitle(g_hMenuCS, "Escolha o que quer colorir");
AddMenuItem(g_hMenuCS, "ChatColors", "Chat");
AddMenuItem(g_hMenuCS, "NameColors", "Nome");
SetMenuExitButton(g_hMenuCS, true);
DisplayMenu(g_hMenuCS, client, 20);
}
public MenuSelectHandler(Handle g_hMenuCS, MenuAction maAction, int client, int choice)
{
if (maAction == MenuAction_Select)
{
char sChoice[64];
GetMenuItem(g_hMenuCS, choice, sChoice, sizeof(sChoice));
if(StrEqual(sChoice, "ChatColors"))
{
Handle g_hMenuCC = CreateMenu(MenuHandler_Colors, MENU_ACTIONS_ALL);
SetMenuTitle(g_hMenuCC, "Selecione a cor do chat:");
AddMenuItem(g_hMenuCC, "none", "Padrão");
AddMenuItem(g_hMenuCC, "\x02", "Vermelho");
AddMenuItem(g_hMenuCC, "\x03", "Cor do Time");
AddMenuItem(g_hMenuCC, "\x04", "Verde");
AddMenuItem(g_hMenuCC, "\x05", "Verde Claro");
AddMenuItem(g_hMenuCC, "\x06", "Limão");
AddMenuItem(g_hMenuCC, "\x07", "Vermelho Claro");
AddMenuItem(g_hMenuCC, "\x08", "Cinza");
AddMenuItem(g_hMenuCC, "\x09", "Oliva");
AddMenuItem(g_hMenuCC, "\x0B", "Azul Claro");
AddMenuItem(g_hMenuCC, "\x0C", "Azul");
AddMenuItem(g_hMenuCC, "\x0C", "Roxo");
AddMenuItem(g_hMenuCC, "\x0E", "Rosa");
AddMenuItem(g_hMenuCC, "\x10", "Dourado");
AddMenuItem(g_hMenuCC, "\x0F", "Laranja");
SetMenuExitButton(g_hMenuCC, true);
DisplayMenu(g_hMenuCC, client, 20);
}
if(StrEqual(sChoice, "NameColors"))
{
Handle g_hMenuCN = CreateMenu(MenuHandler_NameColor, MENU_ACTIONS_ALL);
SetMenuTitle(g_hMenuCN, "Selecione a cor do nome:");
AddMenuItem(g_hMenuCN, "none", "Padrão");
AddMenuItem(g_hMenuCN, "\x02", "Vermelho");
AddMenuItem(g_hMenuCN, "\x03", "Cor do Time");
AddMenuItem(g_hMenuCN, "\x04", "Verde");
AddMenuItem(g_hMenuCN, "\x05", "Verde Claro");
AddMenuItem(g_hMenuCN, "\x06", "Limão");
AddMenuItem(g_hMenuCN, "\x07", "Vermelho Claro");
AddMenuItem(g_hMenuCN, "\x08", "Cinza");
AddMenuItem(g_hMenuCN, "\x09", "Oliva");
AddMenuItem(g_hMenuCN, "\x0B", "Azul Claro");
AddMenuItem(g_hMenuCN, "\x0C", "Azul");
AddMenuItem(g_hMenuCN, "\x0C", "Roxo");
AddMenuItem(g_hMenuCN, "\x0E", "Rosa");
AddMenuItem(g_hMenuCN, "\x10", "Dourado");
AddMenuItem(g_hMenuCN, "\x0F", "Laranja");
SetMenuExitButton(g_hMenuCN, true);
DisplayMenu(g_hMenuCN, client, 20);
}
else if(maAction == MenuAction_End)
{
CloseHandle(g_hMenuCS);
}
}
}
public int MenuHandler_Colors(Handle g_hMenuCC, MenuAction maAction, int client, int choice)
{
if(maAction == MenuAction_Select)
{
char sChoice[8];
GetMenuItem(g_hMenuCC, choice, sChoice, 8);
if(StrEqual(sChoice, "none"))
{
FormatEx(sChoice, 8, "\x01");
}
if(StrEqual(sChoice, "\x03"))
{
CPrintToChat(client, " \x0C[hP Chat]\x01 A cor do seu chat combinará com a cor da sua equipe.");
}
else
{
CPrintToChat(client, " \x0C[hP Chat]\x01 Você selecionou %sesta cor\x01.", sChoice);
}
SetClientCookie(client, gH_Cookie, sChoice);
}
else if(maAction == MenuAction_End)
{
CloseHandle(g_hMenuCC);
}
}
public int MenuHandler_NameColor(Handle g_hMenuCN, MenuAction maAction, int client, int choice)
{
if(maAction == MenuAction_Select)
{
char sChoice[8];
GetMenuItem(g_hMenuCN, choice, sChoice, 8);
SetClientCookie(client, gH_Cookie4, sChoice);
if(StrEqual(sChoice, "none"))
{
FormatEx(sChoice, 8, "\x01");
}
if(StrEqual(sChoice, "\x03"))
{
CPrintToChat(client, " \x0C[hP Chat]\x01 Sua cor do seu nome combinará com a cor da sua equipe.");
}
else
{
CPrintToChat(client, " \x0C[hP Chat]\x01 Você selecionou %sesta cor\x01.", sChoice);
}
}
else if(maAction == MenuAction_End)
{
CloseHandle(g_hMenuCN);
}
}
stock bool:IsValidClient(client) {
return (client > 0 && client <= MaxClients);
}
public Action Command_Tag(int client, int args)
{
if (IsValidClient(client))
{
if (args < 1)
{
ReplyToCommand(client, "\x0C[hP Chat]\x01 Uso: sm_tag <tag>.");
return Plugin_Handled;
}
char arg[32];
GetCmdArg(1, arg, sizeof(arg));
ReplaceString(arg, sizeof(arg), "{teamcolor}", "\x03", false);
SetClientCookie(client, gH_Cookie2, arg);
if(StrEqual(arg, "none", false))
{
CPrintToChat(client, " \x0B[hP Chat]\x01 Você removeu sua tag.");
return Plugin_Handled;
}
CPrintToChat(client, " \x0B[hP Chat]\x01 Você selecionou a tag: '%s\x01'.", arg);
return Plugin_Handled;
}
return Plugin_Handled;
}
public Action Command_Suffix(int client, int args)
{
if (IsValidClient(client))
{
if (args < 1)
{
ReplyToCommand(client, "\x0C[hP Chat]\x01 Uso: sm_sufixo <tag>.");
return Plugin_Handled;
}
char arg[32];
GetCmdArg(1, arg, sizeof(arg));
ReplaceString(arg, sizeof(arg), "{teamcolor}", "\x03", false);
SetClientCookie(client, gH_Cookie3, arg);
if(StrEqual(arg, "none", false))
{
CPrintToChat(client, " \x0B[hP Chat]\x01 Você removeu seu sufixo.");
return Plugin_Handled;
}
CPrintToChat(client, " \x0C[hP Chat]\x01 Você selecionou o sufixo: '%s\x01'.", arg);
return Plugin_Handled;
}
return Plugin_Handled;
}
public Action OnChatMessage(int &client, Handle hRecipients, char[] sName, char[] sMessage)
{
if(CheckCommandAccess(client, "sm_cores", ADMFLAG_GENERIC))
{
char sCookie[8];
GetClientCookie(client, gH_Cookie, sCookie, sizeof(sCookie));
char sCookie2[32];
GetClientCookie(client, gH_Cookie2, sCookie2, sizeof(sCookie2));
char sCookie3[32];
GetClientCookie(client, gH_Cookie3, sCookie3, sizeof(sCookie3));
char sCookie4[8];
GetClientCookie(client, gH_Cookie4, sCookie4, sizeof(sCookie4));
if(StrEqual(sCookie, "") || StrEqual(sCookie, "none"))
{
if(StrEqual(sCookie2, "") || StrEqual(sCookie2, "none"))
{
if(StrEqual(sCookie3, "") || StrEqual(sCookie3, "none"))
{
if(StrEqual(sCookie4, "") || StrEqual(sCookie4, "none"))
{
return Plugin_Continue;
}
}
}
}
if(StrEqual(sCookie2, "") || StrEqual(sCookie2, "none"))
{
strcopy(sCookie2, sizeof(sCookie2), "");
}
if(StrEqual(sCookie3, "") || StrEqual(sCookie3, "none"))
{
strcopy(sCookie3, sizeof(sCookie3), "");
}
if(StrEqual(sCookie4, "") || StrEqual(sCookie4, "none"))
{
strcopy(sCookie4, sizeof(sCookie3), "\x03");
}
Format(sMessage, MAXLENGTH_INPUT, "%s%s", sCookie, sMessage);
CFormat(sMessage, MAXLENGTH_INPUT);
Format(sName, MAXLENGTH_INPUT, "%s%s%s%s", sCookie2, sCookie4, sName, sCookie3);
CFormat(sName, MAXLENGTH_INPUT);
return Plugin_Changed;
}
return Plugin_Continue;
}
Last edited by Ice_MMB; 07-28-2017 at 19:09.
|
|