mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 06:15:37 +03:00
Added functionality for the auto-channeler
This commit is contained in:
parent
694d7c118c
commit
62e7e22a93
@ -83,6 +83,19 @@ void CPlayer::PutInServer()
|
||||
ingame = true;
|
||||
}
|
||||
|
||||
int CPlayer::NextHUDChannel()
|
||||
{
|
||||
int ilow = 1;
|
||||
|
||||
for (int i=ilow+1; i<=4; i++)
|
||||
{
|
||||
if (channels[i] < channels[ilow])
|
||||
ilow = i;
|
||||
}
|
||||
|
||||
return ilow;
|
||||
}
|
||||
|
||||
bool CPlayer::Connect(const char* connectname, const char* ipaddress)
|
||||
{
|
||||
name.assign(connectname);
|
||||
@ -98,6 +111,9 @@ bool CPlayer::Connect(const char* connectname, const char* ipaddress)
|
||||
initialized = true;
|
||||
authorized = false;
|
||||
|
||||
for (int i=0; i<=4; i++)
|
||||
channels[i] = 0.0f;
|
||||
|
||||
const char* authid = GETPLAYERAUTHID(pEdict);
|
||||
|
||||
if ((authid == 0) || (*authid == 0) || (strcmp(authid, "STEAM_ID_PENDING") == 0))
|
||||
|
@ -115,6 +115,8 @@ public:
|
||||
int newmenu;
|
||||
int page;
|
||||
|
||||
float channels[5];
|
||||
|
||||
Vector lastTrace;
|
||||
Vector thisTrace;
|
||||
Vector lastHit;
|
||||
@ -139,6 +141,8 @@ public:
|
||||
|
||||
inline void Authorize() { authorized = true; }
|
||||
|
||||
int NextHUDChannel();
|
||||
|
||||
};
|
||||
|
||||
// *****************************************************
|
||||
|
@ -309,6 +309,25 @@ static cell AMX_NATIVE_CALL show_motd(AMX *amx, cell *params) /* 3 param */
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL next_hudchannel(AMX *amx, cell *params)
|
||||
{
|
||||
int index = params[1];
|
||||
if (index < 1 || index > gpGlobals->maxClients)
|
||||
{
|
||||
LogError(amx, AMX_ERR_NATIVE, "Invalid player %d");
|
||||
return 0;
|
||||
}
|
||||
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
if (!pPlayer->ingame)
|
||||
{
|
||||
LogError(amx, AMX_ERR_NATIVE, "Player %d not in game", index);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return pPlayer->NextHUDChannel();
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL set_hudmessage(AMX *amx, cell *params) /* 11 param */
|
||||
{
|
||||
g_hudset.a1 = 0;
|
||||
@ -337,6 +356,7 @@ static cell AMX_NATIVE_CALL show_hudmessage(AMX *amx, cell *params) /* 2 param *
|
||||
g_langMngr.SetDefLang(params[1]);
|
||||
char* message = NULL;
|
||||
|
||||
bool aut = (g_hudset.channel == -1) ? true : false;
|
||||
if (params[1] == 0)
|
||||
{
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
@ -347,6 +367,11 @@ static cell AMX_NATIVE_CALL show_hudmessage(AMX *amx, cell *params) /* 2 param *
|
||||
{
|
||||
g_langMngr.SetDefLang(i);
|
||||
message = UTIL_SplitHudMessage(format_amxstring(amx, params, 2, len));
|
||||
if (aut)
|
||||
{
|
||||
g_hudset.channel = pPlayer->NextHUDChannel();
|
||||
pPlayer->channels[g_hudset.channel] = gpGlobals->time;
|
||||
}
|
||||
UTIL_HudMessage(pPlayer->pEdict, g_hudset, message);
|
||||
}
|
||||
}
|
||||
@ -363,8 +388,15 @@ static cell AMX_NATIVE_CALL show_hudmessage(AMX *amx, cell *params) /* 2 param *
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
|
||||
if (pPlayer->ingame)
|
||||
{
|
||||
if (aut)
|
||||
{
|
||||
g_hudset.channel = pPlayer->NextHUDChannel();
|
||||
pPlayer->channels[g_hudset.channel] = gpGlobals->time;
|
||||
}
|
||||
UTIL_HudMessage(pPlayer->pEdict, g_hudset, message);
|
||||
}
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
@ -3736,6 +3768,7 @@ AMX_NATIVE_INFO amxmodx_Natives[] =
|
||||
{"message_end", message_end},
|
||||
{"module_exists", module_exists},
|
||||
{"mkdir", amx_mkdir},
|
||||
{"next_hudchannel", next_hudchannel},
|
||||
{"num_to_word", num_to_word},
|
||||
{"parse_loguser", parse_loguser},
|
||||
{"parse_time", parse_time},
|
||||
|
@ -100,7 +100,7 @@ public cmdSayChat(id)
|
||||
|
||||
new Float:verpos = g_Pos[i][1] + float(g_msgChannel) / 35.0
|
||||
|
||||
set_hudmessage(g_Values[a][0], g_Values[a][1], g_Values[a][2], g_Pos[i][0], verpos, 0, 6.0, 6.0, 0.5, 0.15, g_msgChannel)
|
||||
set_hudmessage(g_Values[a][0], g_Values[a][1], g_Values[a][2], g_Pos[i][0], verpos, 0, 6.0, 6.0, 0.5, 0.15, -1)
|
||||
|
||||
if (get_cvar_num("amx_show_activity") == 2)
|
||||
{
|
||||
@ -292,7 +292,7 @@ public cmdTsay(id, level, cid)
|
||||
get_user_authid(id, authid, 31)
|
||||
get_user_name(id, name, 31)
|
||||
userid = get_user_userid(id)
|
||||
set_hudmessage(g_Values[a][0], g_Values[a][1], g_Values[a][2], tsay ? 0.05 : -1.0, verpos, 0, 6.0, 6.0, 0.5, 0.15, g_msgChannel)
|
||||
set_hudmessage(g_Values[a][0], g_Values[a][1], g_Values[a][2], tsay ? 0.05 : -1.0, verpos, 0, 6.0, 6.0, 0.5, 0.15, -1)
|
||||
|
||||
if (get_cvar_num("amx_show_activity") == 2)
|
||||
{
|
||||
|
@ -264,20 +264,20 @@ public plugin_cfg()
|
||||
|
||||
// Set hudmessage format.
|
||||
set_hudtype_killer(Float:fDuration)
|
||||
set_hudmessage(220, 80, 0, 0.05, 0.15, 0, 6.0, fDuration, (fDuration >= g_fHUDDuration) ? 1.0 : 0.0, 1.0, 2)
|
||||
set_hudmessage(220, 80, 0, 0.05, 0.15, 0, 6.0, fDuration, (fDuration >= g_fHUDDuration) ? 1.0 : 0.0, 1.0, -1)
|
||||
|
||||
set_hudtype_endround(Float:fDuration)
|
||||
set_hudmessage(100, 200, 0, 0.05, 0.55, 0, 0.02, fDuration, (fDuration >= g_fHUDDuration) ? 1.0 : 0.0, 1.0, 1)
|
||||
set_hudmessage(100, 200, 0, 0.05, 0.55, 0, 0.02, fDuration, (fDuration >= g_fHUDDuration) ? 1.0 : 0.0, 1.0, -1)
|
||||
|
||||
set_hudtype_attacker(Float:fDuration)
|
||||
set_hudmessage(220, 80, 0, 0.55, 0.35, 0, 6.0, fDuration, (fDuration >= g_fHUDDuration) ? 1.0 : 0.0, 1.0, 3)
|
||||
set_hudmessage(220, 80, 0, 0.55, 0.35, 0, 6.0, fDuration, (fDuration >= g_fHUDDuration) ? 1.0 : 0.0, 1.0, -1)
|
||||
|
||||
set_hudtype_victim(Float:fDuration)
|
||||
set_hudmessage(0, 80, 220, 0.55, 0.60, 0, 6.0, fDuration, (fDuration >= g_fHUDDuration) ? 1.0 : 0.0, 1.0, 4)
|
||||
set_hudmessage(0, 80, 220, 0.55, 0.60, 0, 6.0, fDuration, (fDuration >= g_fHUDDuration) ? 1.0 : 0.0, 1.0, -1)
|
||||
|
||||
set_hudtype_specmode()
|
||||
{
|
||||
set_hudmessage(255, 255, 255, 0.02, 0.87, 2, 0.05, 0.1, 0.01, 3.0, 1)
|
||||
set_hudmessage(255, 255, 255, 0.02, 0.87, 2, 0.05, 0.1, 0.01, 3.0, -1)
|
||||
}
|
||||
|
||||
#if defined STATSX_DEBUG
|
||||
|
@ -64,7 +64,7 @@ public infoMessage()
|
||||
if (g_Current >= g_MessagesNum)
|
||||
g_Current = 0
|
||||
|
||||
set_hudmessage(g_Values[g_Current][0], g_Values[g_Current][1], g_Values[g_Current][2], X_POS, Y_POS, 0, 0.5, HOLD_TIME, 2.0, 2.0, 1)
|
||||
set_hudmessage(g_Values[g_Current][0], g_Values[g_Current][1], g_Values[g_Current][2], X_POS, Y_POS, 0, 0.5, HOLD_TIME, 2.0, 2.0, -1)
|
||||
show_hudmessage(0, g_Messages[g_Current])
|
||||
client_print(0, print_console, g_Messages[g_Current])
|
||||
++g_Current
|
||||
|
@ -11,9 +11,9 @@
|
||||
#endif
|
||||
#define _amxconst_included
|
||||
|
||||
#define AMXX_VERSION 1.60
|
||||
#define AMXX_VERSION_NUM 160
|
||||
stock const AMXX_VERSION_STR[]="1.60"
|
||||
#define AMXX_VERSION 1.61
|
||||
#define AMXX_VERSION_NUM 161
|
||||
stock const AMXX_VERSION_STR[]="1.61"
|
||||
|
||||
#define ADMIN_ALL 0 /* everyone */
|
||||
#define ADMIN_IMMUNITY (1<<0) /* flag "a" */
|
||||
|
@ -127,7 +127,11 @@ native register_event(const event[],const function[],const flags[],cond[]="", ..
|
||||
*/
|
||||
native register_logevent(const function[], argsnum, ... );
|
||||
|
||||
/* Sets format for hudmessage. */
|
||||
/**
|
||||
* Sets format for hudmessage.
|
||||
* Note - as of AMX Mod X 1.61, setting the channel to -1
|
||||
* will automatically choose the next available HUD channel for a player.
|
||||
*/
|
||||
native set_hudmessage(red=200, green=100, blue=0, Float:x=-1.0, Float:y=0.35, effects=0, Float:fxtime=6.0, Float:holdtime=12.0, Float:fadeintime=0.1, Float:fadeouttime=0.2,channel=4);
|
||||
|
||||
/* Displays HUD message to given player. */
|
||||
@ -895,3 +899,8 @@ native abort(error, const fmt[]="", {Float,_}:...);
|
||||
* module_exists("dbi")
|
||||
*/
|
||||
native module_exists(const logtag[]);
|
||||
|
||||
/**
|
||||
* Returns the next valid hudchannel for a user, from 1-4.
|
||||
*/
|
||||
native next_hudchannel(player);
|
||||
|
@ -73,7 +73,7 @@ public showMsg()
|
||||
g_xPos = 0.35
|
||||
}
|
||||
|
||||
set_hudmessage(200, 100, 0, g_xPos, 0.90, 0, SPEED, SPEED, 0.05, 0.05, 2)
|
||||
set_hudmessage(200, 100, 0, g_xPos, 0.90, 0, SPEED, SPEED, 0.05, 0.05, -1)
|
||||
show_hudmessage(0, g_displayMsg)
|
||||
}
|
||||
|
||||
|
@ -256,9 +256,9 @@ public timeRemain(param[])
|
||||
setTimeText(arg, 127, tmlf, players[i])
|
||||
|
||||
if (flags & 16)
|
||||
set_hudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 1.1, 0.1, 0.5, 1)
|
||||
set_hudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 1.1, 0.1, 0.5, -1)
|
||||
else
|
||||
set_hudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 3.0, 0.0, 0.5, 1)
|
||||
set_hudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 3.0, 0.0, 0.5, -1)
|
||||
|
||||
show_hudmessage(players[i], arg)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user