How to I make player unable to kill each other in HL SDK? Created 2 years ago2022-01-23 13:36:37 UTC by JacksBestGaming JacksBestGaming

Created 2 years ago2022-01-23 13:36:37 UTC by JacksBestGaming JacksBestGaming

Posted 2 years ago2022-01-23 13:36:37 UTC Post #346225
I am using Solokiller's HL Updated SDK, and I want to make a Co-op mod. How do I make it so players can't to kill each other?
Posted 2 years ago2022-01-23 15:54:22 UTC Post #346226
Go to multiplay_gamerules.cpp, around line 500, look for CHalfLifeMultiplay::FPlayerCanTakeDamage.
//=========================================================
//=========================================================
bool CHalfLifeMultiplay::FPlayerCanTakeDamage(CBasePlayer* pPlayer, CBaseEntity* pAttacker)
{
    return true;
}
Simply replace return true; with this:
return !pAttacker->IsPlayer();
This will affect the deathmatch gamemode.
Admer456 Admer456If it ain't broken, don't fox it!
Posted 2 years ago2022-01-23 16:10:37 UTC Post #346227
Thank you!
Posted 2 years ago2022-01-23 19:32:54 UTC Post #346228
Update CHalfLifeMultiplay::PlayerRelationship too. If you have it return GR_TEAMMATE you'll be able to see your friends' health and armour amounts, just like when you play HLDM in teams.

Also, move/copy CHalfLifeTeamplay's ShouldAutoAim implementation into CHalfLifeMultiplay if you don't want auto-aim to target your friends when you have the cvar sv_aim set to 1.
Oskar Potatis Oskar Potatis🦔
You must be logged in to post a response.