Senior Member
Join Date: Feb 2016
Location: Pluto
|
11-21-2021
, 09:11
How to transfrom HUD messages to Dhud messages?
|
#1
|
Hello. I want to make this HUD message to be Dhud.
The following code is the code that is responsible for the ZP's HUD message that shows health, class, ammo, armor, etc...
Code:
// Spectating someone else?
if (id != ID_SHOWHUD)
{
// Show name, health, class, and ammo packs and armor
set_hudmessage(0, 0, 128, HUD_SPECT_X, HUD_SPECT_Y, 1, 6.0, 1.1, 0.0, 0.0, -1)
ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync2, "%L %s^nHP: %d - %L %s - %L %d - %L %d", ID_SHOWHUD, "SPECTATING", g_playername[id],
pev(id, pev_health), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[id], ID_SHOWHUD, "ARMOR", pev(id, pev_armorvalue))
}
else
{
// Show health, class and ammo packs and armor
set_hudmessage(red, green, blue, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync2, "%L: %d - %L %s - %L %d - %L %d", id, "ZOMBIE_ATTRIB1", pev(ID_SHOWHUD, pev_health), ID_SHOWHUD, "CLASS_CLASS",
class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[ID_SHOWHUD], ID_SHOWHUD, "ARMOR", pev(ID_SHOWHUD, pev_armorvalue))
}
}
I replaced:
with this:
and this:
with this:
When i tried to compile the plugin, i got the following warning and errors:
// C:\Mod\cstrike\addons\amxmodx\scripting\zombi e_plague_advance_v1-6-1.sma(10509) : warning 213: tag mismatch
// C:\Mod\cstrike\addons\amxmodx\scripting\zombi e_plague_advance_v1-6-1.sma(10510) : error 035: argument type mismatch (argument 2)
// C:\Mod\cstrike\addons\amxmodx\scripting\zombi e_plague_advance_v1-6-1.sma(10516) : warning 213: tag mismatch
// C:\Mod\cstrike\addons\amxmodx\scripting\zombi e_plague_advance_v1-6-1.sma(10517) : error 035: argument type mismatch (argument 2)
// C:\Mod\cstrike\addons\amxmodx\scripting\zombi e_plague_advance_v1-6-1.sma(13479) : warning 204: symbol is assigned a value that is never used: "g_MsgSync2"
Then, i opened the main code again, and used Ctrl+F to find all lines that contain "g_MsgSync2", so i can delete "g_MsgSync2".
Then i edited the following codes by removing (deleting) what is marked in red:
In the "// Game vars" section:
Code:
new g_MsgSync, g_MsgSync2 , g_MsgSync3// message sync objects
Then i edited this:
Code:
// Create the HUD Sync Objects
g_MsgSync = CreateHudSyncObj()
g_MsgSync2 = CreateHudSyncObj()
g_MsgSync3 = CreateHudSyncObj()
This is the main HUD code. In red is marked what I deleted:
Code:
// Spectating someone else?
if (id != ID_SHOWHUD)
{
// Show name, health, class, and ammo packs and armor
set_dhudmessage(0, 0, 128, HUD_SPECT_X, HUD_SPECT_Y, 1, 6.0, 1.1, 0.0, 0.0, -1)
show_dhudmessage(ID_SHOWHUD, g_MsgSync2, "%L %s^nHP: %d - %L %s - %L %d - %L %d", ID_SHOWHUD, "SPECTATING", g_playername[id],
pev(id, pev_health), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[id], ID_SHOWHUD, "ARMOR", pev(id, pev_armorvalue))
}
else
{
// Show health, class and ammo packs and armor
set_dhudmessage(red, green, blue, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
show_dhudmessage(ID_SHOWHUD, g_MsgSync2, "%L: %d - %L %s - %L %d - %L %d", id, "ZOMBIE_ATTRIB1", pev(ID_SHOWHUD, pev_health), ID_SHOWHUD, "CLASS_CLASS",
class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[ID_SHOWHUD], ID_SHOWHUD, "ARMOR", pev(ID_SHOWHUD, pev_armorvalue))
}
}
So, the 2 errors are now fixed. However, the 2 warnings are still here:
// C:\Mod\cstrike\addons\amxmodx\scripting\zombi e_plague_advance_v1-6-1.sma(1050 : warning 213: tag mismatch
// C:\Mod\cstrike\addons\amxmodx\scripting\zombi e_plague_advance_v1-6-1.sma(10515) : warning 213: tag mismatch
This is line 10508:
Code:
set_dhudmessage(0, 0, 128, HUD_SPECT_X, HUD_SPECT_Y, 1, 6.0, 1.1, 0.0, 0.0, -1)
This is line 10515:
Code:
set_dhudmessage(red, green, blue, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
This is the whole code where the two error-causing lines are contained:
Code:
// Spectating someone else?
if (id != ID_SHOWHUD)
{
// Show name, health, class, and ammo packs and armor
set_dhudmessage(0, 0, 128, HUD_SPECT_X, HUD_SPECT_Y, 1, 6.0, 1.1, 0.0, 0.0, -1)
show_dhudmessage(ID_SHOWHUD, "%L %s^nHP: %d - %L %s - %L %d - %L %d", ID_SHOWHUD, "SPECTATING", g_playername[id],
pev(id, pev_health), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[id], ID_SHOWHUD, "ARMOR", pev(id, pev_armorvalue))
}
else
{
// Show health, class and ammo packs and armor
set_dhudmessage(red, green, blue, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
show_dhudmessage(ID_SHOWHUD, "%L: %d - %L %s - %L %d - %L %d", id, "ZOMBIE_ATTRIB1", pev(ID_SHOWHUD, pev_health), ID_SHOWHUD, "CLASS_CLASS",
class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[ID_SHOWHUD], ID_SHOWHUD, "ARMOR", pev(ID_SHOWHUD, pev_armorvalue))
}
}
So, what exactly is mismatched? Would you explain me how the code should be like in order to be understood by the compiler?
Also, will the deletion of "g_MsgSync2" cause any problems with the main code of ZPA, or was "g_MsgSync2" intended only for helping the work of the specific HUD message i want to turn into DHUD, meaning the deletion of "g_MsgSync2" won't affect any of the functions of the main ZPA plugin?
There is one more plugin i have problems with when i try to turn its HUD message into DHUD.
This is the warning i get:
Code:
// C:\Mod\cstrike\addons\amxmodx\scripting\health_reminder_nem.sma(59) : warning 213: tag mismatch
This is line 59:
Code:
set_dhudmessage(0, 255, 0, HUD_MODE_X, HUD_MODE_Y, 0, 6.0, HOLD_TIME, 0.0, 0.0, -1)
The only change i introduced to line 59, was to add "d" before "hudmessage".
Then i changed line 60 from this:
Code:
ShowSyncHudMsg(0, g_SyncHud, "Nemesis still has %d health points!", get_user_health(id))
To this:
Code:
show_dhudmessage(0, "Nemesis still has %d health points!", get_user_health(id))
I replaced "ShowSyncHudMsg" with "show_dhudmessage", and then i deleted "g_SyncHud,", and "new g_SyncHud" which was added at the top of the code.
In both plugins, the health reminder plugin and the main ZPA code, i added "#include <dhudmessage>" at the top of the code, where the names of includes are added. However, i still get warnings and errors.
Can someone explain to me what I'm doing wrong? I would like someone to explain to me how to turn HUD messages into DHUD.
Here is the original code of the health reminder plugin, in case you need to see the original code before explaining whether or not the changes i introduced are correct:
Code:
#include <amxmodx>
#include <hamsandwich>
#include <zombieplague>
#define PLUGIN_NAME "[ZP] Nemesis Health Reminder"
#define PLUGIN_VERS "1.0"
#define PLUGIN_AUTH "zmd94"
#define TASK_HEALTH 95000
#define HOLD_TIME 2.0
const Float:HUD_MODE_X = -1.0
const Float:HUD_MODE_Y = 0.20
const Float:START_TIME = 6.0
new g_SyncHud
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERS, PLUGIN_AUTH)
// Fwd's
RegisterHam(Ham_Spawn, "player", "Fwd_PlayerSpawn_Post", 1)
RegisterHam(Ham_Killed, "player", "Fwd_PlayerKilled_Pre", 0)
g_SyncHud = CreateHudSyncObj()
}
public Fwd_PlayerSpawn_Post(id)
{
if (task_exists(id+TASK_HEALTH))
remove_task(id+TASK_HEALTH)
}
public Fwd_PlayerKilled_Pre(victim, attacker, shouldgib)
{
if (task_exists(victim+TASK_HEALTH))
remove_task(victim+TASK_HEALTH)
}
public zp_round_started(mode, id)
{
if (mode != MODE_NEMESIS)
return
if (!zp_get_user_nemesis(id))
return
set_task(START_TIME, "Task_ShowHealth", id+TASK_HEALTH, _, _, "b")
}
public Task_ShowHealth(id)
{
id -= TASK_HEALTH
if (!zp_get_user_nemesis(id))
remove_task(id+TASK_HEALTH)
set_hudmessage(0, 255, 0, HUD_MODE_X, HUD_MODE_Y, 0, 6.0, HOLD_TIME, 0.0, 0.0, -1)
ShowSyncHudMsg(0, g_SyncHud, "Nemesis still has %d health points!", get_user_health(id))
}
I use AMXX 1.8.2
Thanks.
Last edited by GlobalPlague; 11-22-2021 at 02:57.
|
|