Senior Member
|
01-17-2019
, 14:34
Need help with hud messages
|
#1
|
Hello
How can i make this plugin to show a message to everyone via the hudmessage include
Code:
SendHudMessage(client, 3, -1.0, -0.6, 0xFF00FF00, 0xFF00FF00, 1, 0.1, 0.5, 1.5, 5.0, "Text");
Code:
#pragma semicolon 1
#include <sourcemod>
#define PLUGIN_VERSION "0.08"
#define YELLOW 0x01
#define NAME_TEAMCOLOR 0x02
#define TEAMCOLOR 0x03
#define GREEN 0x04
public Plugin:myinfo =
{
name = "Most destructive",
author = "X@IDER",
description = "Show most dsestructive player at end of round",
version = PLUGIN_VERSION,
url = "http://www.sourcemod.net/"
};
// Arrays
new GDamage[65],GPlayers[65],GHits[65];
// Cvars
new Handle:sm_most_damage_mode = INVALID_HANDLE;
new Handle:sm_most_damage_lines = INVALID_HANDLE;
new String:DmgParam[16] = "dmg_health"; // cstrike, l4d, insurgency
public OnPluginStart()
{
LoadTranslations("plugin.mdest");
sm_most_damage_mode = CreateConVar("sm_md_mode", "0", "0 - display in chat, 1 - in hint", 0);
sm_most_damage_lines = CreateConVar("sm_md_lines", "3", "0 - none, 1 - most damage, 2 - most kills, 3 - both", 0);
HookEvent("round_start", Round_Start, EventHookMode_PostNoCopy);
HookEvent("round_end", Round_End, EventHookMode_PostNoCopy);
HookEvent("player_hurt", Damage, EventHookMode_Post);
HookEvent("player_death", Death, EventHookMode_Post);
new String:GameDir[32];
GetGameFolderName(GameDir,32);
if (!strcmp(GameDir,"dod")) DmgParam = "damage";
}
public SayText2(to, from, const String:format[], any:...)
{
decl String:message[256];
VFormat(message,sizeof(message),format,4);
new Handle:hBf = StartMessageOne("SayText2", to);
BfWriteByte(hBf, from);
BfWriteByte(hBf, true);
BfWriteString(hBf, message);
EndMessage();
}
public Death(Handle:event, const String:name[], bool:dontBroadcast)
{
new t = GetClientOfUserId(GetEventInt(event,"attacker"));
if (t) GPlayers[t]++;
}
public Damage(Handle:event, const String:name[], bool:dontBroadcast)
{
new t = GetClientOfUserId(GetEventInt(event,"attacker"));
if (t)
{
GDamage[t] += GetEventInt(event,DmgParam);
GHits[t]++;
}
}
public Round_Start(Handle:event, const String:name[], bool:dontBroadcast)
{
for (new i = 1; i <= MaxClients; i++)
GDamage[i] = GPlayers[i] = GHits[i] = 0;
}
public Round_End(Handle:event, const String:name[], bool:dontBroadcast)
{
new maxGD = 0,maxGP = 0;
GDamage[0] = GPlayers[0] = GHits[0] = 0;
new String:nameGD[32],String:nameGP[32];
for (new i = 1; i <= MaxClients; i++)
if (IsClientInGame(i))
{
if (GDamage[i] > GDamage[maxGD]) maxGD = i;
else if ((GDamage[i] == GDamage[maxGD]) && (GPlayers[i] > GPlayers[maxGD])) maxGD = i;
if (GPlayers[i] > GPlayers[maxGP]) maxGP = i;
else if ((GDamage[i] > GDamage[maxGP]) && (GPlayers[i] == GPlayers[maxGP])) maxGP = i;
}
GetClientName(maxGD,nameGD,31);
GetClientName(maxGP,nameGP,31);
new lines = GetConVarInt(sm_most_damage_lines);
if (GetConVarBool(sm_most_damage_mode))
{
decl String:buff[512],String:line[512];
buff[0] = 0;
if (maxGD && (lines & 1))
{
Format(line,512,"%t","Max damage",nameGD,GDamage[maxGD],GPlayers[maxGD],GHits[maxGD]);
StrCat(buff,512,line);
}
if (maxGD && maxGP && (lines == 3)) StrCat(buff,512,"\n");
if (maxGP && (lines & 2))
{
Format(line,512,"%t","Max kills",nameGP,GDamage[maxGP],GPlayers[maxGP],GHits[maxGP]);
StrCat(buff,512,line);
}
if (buff[0]) PrintHintTextToAll(buff);
} else
{
for (new i = 1; i <= MaxClients; i++)
if (IsClientInGame(i) && !IsFakeClient(i))
{
if (maxGD && (lines & 1)) SayText2(i,maxGD,"%t","Maximum damage",YELLOW,TEAMCOLOR,nameGD,YELLOW,GREEN,GDamage[maxGD],YELLOW,GREEN,GPlayers[maxGD],YELLOW,GREEN,GHits[maxGD],YELLOW);
if (maxGP && (lines & 2)) SayText2(i,maxGP,"%t","Maximum kills",YELLOW,TEAMCOLOR,nameGP,YELLOW,GREEN,GDamage[maxGP],YELLOW,GREEN,GPlayers[maxGP],YELLOW,GREEN,GHits[maxGP],YELLOW);
}
}
}
Include hudmessages
Code:
/**
** Created by horr0rjkee
** Thanks for Alex(tracker) for ColorHexToRGB function! Wiki link: https://wiki.alliedmods.net/User_messages
** Date: 18 July 2014
*/
#if defined easy_hud_message
#endinput
#endif
#define easy_hud_message
/**
* Return colors from HEX to RGB format.
*
* @param color HEX color with transparent (Example: 0xFF00FFFF - Fully red color). Get any color from colorpicker.com.
* @param outr Red color.
* @param outg Green color.
* @param outb Blue color.
* @param outalpha Transparent.
* @return 1 or 0.
*/
stock bool:ColorHexToRGB(color, &outr, &outg, &outb, &outalpha) { //by Alex (Tracker)
outr=(color & 0xFF000000)>>>24;
outg=(color & 0x00FF0000)>>16;
outb=(color & 0x0000FF00)>>8;
outalpha=color & 0x000000FF;
return true;
}
/**
* Prints hud message to player
*
* @param client Client index.
* @param channel Channel index (Only 1 channel can write message).
* @param posx Position x on monitor (-1.0 = center).
* @param posy Position y on monitor (-1.0 = center).
* @param color1 First color in HEX.
* @param color2 Second color in HEX.
* @param effect Effect index (0 is fade in/fade out; 1 is flickery credits; 2 is write out).
* @param fadetime FadeIn time.
* @param fadeouttime FadeOut time.
* @param holdtime Hold time.
* @param fxtime Effect time (Effect type 2 used)
* @param message Message
* @param ... Variable number of format parameters.
* @return 1 or 0.
*/
stock bool:SendHudMessage(client,channel=3,Float:posx=-1.0, Float:posy=-1.0,color1,color2,effect=0,Float:fadetime=1.0,Float:fadeouttime=1.0,Float:holdtime=1.5,Float:fxtime=5.0,const String:message[],any:...)
{
if(client == 0 || !IsClientConnected(client) || effect < 0 || fadetime < 0.0 || fadeouttime < 0.0 || holdtime < 0.0 || fxtime < 0.0) return false;
new String:buffer[256];
SetGlobalTransTarget(client);
VFormat(buffer, sizeof(buffer), message, 13);
new Handle:hBf = StartMessageOne("HudMsg", client), rgb[4];
BfWriteByte(hBf, channel); //channel
BfWriteFloat(hBf, posx); // x ( -1 = center )
BfWriteFloat(hBf, posy); // y ( -1 = center )
// second color
ColorHexToRGB(color1, rgb[0], rgb[1], rgb[2], rgb[3]);
BfWriteByte(hBf, rgb[0]); //r1
BfWriteByte(hBf, rgb[1]); //g1
BfWriteByte(hBf, rgb[2]); //b1
BfWriteByte(hBf, rgb[3]); //a1 // transparent?
// init color
ColorHexToRGB(color2, rgb[0], rgb[1], rgb[2], rgb[3]);
BfWriteByte(hBf, rgb[0]); //r2
BfWriteByte(hBf, rgb[1]); //g2
BfWriteByte(hBf, rgb[2]); //b2
BfWriteByte(hBf, rgb[3]); //a2
BfWriteByte(hBf, effect); //effect (0 is fade in/fade out; 1 is flickery credits; 2 is write out)
BfWriteFloat(hBf, fadetime); //fadeinTime (message fade in time - per character in effect 2)
BfWriteFloat(hBf, fadeouttime); //fadeoutTime
BfWriteFloat(hBf, holdtime); //holdtime
BfWriteFloat(hBf, fxtime); //fxtime (effect type(2) used)
BfWriteString(hBf, buffer); //Message
EndMessage();
return true;
}
Last edited by farawayf; 01-18-2019 at 11:44.
|
|