first read the first tutorial, as the half of this is the same as the other but over SelAmmo data, is very recomendable to implement it
Start using the "find" function and look for "SelAmmo" in the Entire Solution
in player.cpp we need to edit the info inside the function LinkUserMessages
we need to change that 3 to a -1
then the message information inside CBasePlayer::RemoveAllItems
we change that bye by a short
and at last the message information inside CBasePlayer::Killed
and again
next in the list you should have weapon.cpp
we need to go inside the function CBasePlayerWeapon::UpdateClientData and find
we change that again for a short
and at last we open ammo.cpp
and inside CHudAmmo::MsgFunc_CurWeapon
we find
we change the read_byte to read_short
we that we can have 999 of ammo in the clip of the gun
now lets add more digits to the HUD
first lets opend hud.h and at the top find that constant definition
then we add our new one for the new 4digits HUD
now open hud_redraw.cpp and go to the very bottom of the file and find
inside the CHud::GetNumWidth and we add this if statment
in the same function go down find this
and edit it to look like this
now open hud_redraw.cpp and find the function CHud :: DrawHudNumber
this function is the one that arrange the numbers in positions in the hud
we need to change this line, this line trys to take the third digit of the number and put the correct HUD number, but as we are going to
add a 4th digit for the numbers we need to change this line
now this will make the third digit to not have a problem when we add the 4th digit
now we add the fourth digit on top
inside the same function in the bottom we find this chunk of code for the spacing of the digits
we need to ADD another one for our 4th digit(WE DO NOT REMOVE ANYTHING HERE)
done with hud_redraw.cpp now we can use 4th digits on hud(for health,armor, ammo, and weapona ammo)
at this point I recommend you again to have implemented the first tutorial for increasing the AMMO type capacity
so we open ammo.cpp, find the function int CHudAmmo::Draw(float flTime)
inside of it we need to find all the x = gHUD.DrawHudNumber() and change one of the variable inside of this
we need to change the old DHN_3DIGITS to out new DHN_4DIGITS
we do the same with this 2 more inside the function (look for the valve comment "GL Seems to need this" if you are confuse)
we change those to this
and one more inside if ((pw->iAmmo2Type != 0) && (gWR.CountAmmo(pw->iAmmo2Type) > 0)) {
now with that change you can have up to 9999 of ammo in the weapon magazine and be displayed on HUD + all the HUD stuff that use numbers
(armor,health) can be modified to use 4digits
one more thing if you did the first tutorial and now this you should change from player.cpp a line from the first tutorial
inside CBasePlayer::SendAmmoUpdate
the line WRITE_SHORT ( max( min( m_rgAmmo[i], 999 ), 0 ) );
should be even extended to have 9999 as max number of ammo sent to the client
then you can go to weapon.h and modify the capacity of ammo and magazine
and if everything goes well you can have this
I dont think we need that much ammo to end half-life1
Beautiful tutorial, very well written and nicely illustrated. I'm sure that a lot of people find it very useful, thank you for your work!
well thanks!, I felt that the other tutorial was kind of incomplete without the hud
Very nice
waht this program to open this file
visual studio 2008
You can also use Notepad++
When im compiling client dll it gives me error : Could not load library */valve/client.dll Help plz
first of all you shouldnt have in your proyect the load of .dll because thats what you are trying to compile, so it could be that the directory of the sdk is wrong for some reason, be sure that your sdk is compatible with your compiling program, before following any tutorial you should try to compile a clean SDK without modifications
Error: User Msg AmmoX 4 bytes written, expected 2
and when im changing ammox event from 2 to -1 still no work (then ammo is 0 but u can reload)
did you implement the first tutorial? Moddb.com
Look in the code for "ammox"
in player.cpp you need to change the reg_user_msg("ammox",2) to a (ammox,-1)
then in function SendAmmoUpdate, you need to change
WRITE_BYTE( i );
WRITE_BYTE( max( min( m_rgAmmo[i], 254 ), 0 ) );
to
WRITE_SHORT ( i );
WRITE_SHORT ( max( min( m_rgAmmo[i], 9999 ), 0 ) );
and then in the client side, on ammo.cpp fin this function
int CHudAmmo::MsgFunc_AmmoX(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ( pbuf, iSize );
int iIndex = READ_BYTE();
int iCount = READ_BYTE();
gWR.SetAmmo( iIndex, abs(iCount) );
return 1;
}
and change
int iIndex = READ_SHORT();
int iCount = READ_SHORT();
It should work I build it up on a clean SDK
hi sir do you know where can i change the weapon firing speed i know it's possible i found a mod that had the mp5 and some other weapons fire stupidly fast
weapons use diferent methods but the majority as the mp5 uses
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1;
where +0.1 is the time between shots, a smaller number a faster shoot a bigger number a slower
This comment is currently awaiting admin approval, join now to view.
Is There Difference about setting MESSAGE Size To Exact one or -1 ?
Will It Affect Performance ?
REG_USER_MSG( szMessage , Size )
as far I understand -1 means that the size is variable, it would be better to know how much data you want to send to know the right size, in the case of the message "curweapon" we changed the size from 3 to -1, but if we use size of 4 it should work too!
as the message sends 3 data package
write_byte=size 1
write_byte=size 1
write_short= size 2
I dont test it, but it should work
these message would definitly had some impact on online games as this are data between client and servers, how much will affect performance I dont know
Nice tutorial.
One more thing that needs to be fixed:
player.cpp, under void CBasePlayer::SendAmmoUpdate(void)
ASSERT( m_rgAmmo[i] < 255 ); ---> should be changed to 999 if you have followed the first tutorial, or should be changed to 9999 if you have followed the first and the second tutorial.
E.G.:
ASSERT( m_rgAmmo[i] < 999 ); // we have 3 digits, more than 254
or
ASSERT( m_rgAmmo[i] < 9999 ); // we have 4 digits, up to 9999
Other than that, everything works really good.
hello i followed you're first tutorial and now this and for some reason the hl.dll file size is 3,222 KB and when i put the dll file in the dlls folder then ingame well i dont even see my hud or use the HEV Suit anymore.