Applying a force to player hit by weapon.

When a bullet hits an entity, and that entity is a player, what must one do to apply a force to the player’s body in a random direction?

I am doing this in the TTT add-on.
The force itself is not the issue I am having with this, but rather that I do not know how to get the player when the bullet hits it. A rather simple issues, but I am new to coding in GMod.

CTakeDamageInfo gives you everything you need

GM:EntityFireBullets takes a Bullet Structure table as one of it’s arguments. Use a callback in this table to get the victim.

Alternatively you could see how TTT does this: https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/terrortown/entities/weapons/weapon_ttt_push.lua#L112

EDIT: Or do the above, not sure what is better as it depends if you are editing core files or not.

Would I not have to already know what entity took the damage to be able to call the CTakeDamageInfo?

The first argument is the entity that is supposed to take damage, as the wiki says.