Closed prineside closed 7 years ago
I can create this, but I don't understand why you cannot use code like this:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
if (FCNPC_IsValid(playerid) && hittype == BULLET_HIT_TYPE_PLAYER) {
if (IsShotHaveObstacles(playerid, hitid)) { // cast a ray
// cheater
return 0; // disable bullet
}
}
return 1;
}
I think this should work.
No, this callback is not called when NPC shoots. I'm running Windows version of plugin, didn't test it on Linux yet.
First of all, thanks for maintaining this project! I'm glad to see NPCs are shooting again.
I was trying to create enemies with firearms and realized that I can't create sufficient protection against cheaters - simple GodMode cheat disables FCNPC_OnGiveDamage callback. NPCs are not completely accurate in shooting so I can't be sure that the lack of callback calls means cheating.
It would be nice if you add natives for bullet creation method to PAWN. I know I can use YSF for that but installation of one more plugin for just one function would be quite an overkill. Also, disabling default bullet creation would also be nice, so we can leave only shooting sounds and create bullets manually.
It may also be useful to invoke something like OnPlayerWeaponShot right when NPC shoots, even without bullet origin and hit positions, just to know when players will hear shot sound and see bullet particles.
How we can use these things against cheaters: First of all, disable default NPC bullers and ignore FCNPC_OnGiveDamage as it is not safe to rely on it. Then in NPC version of OnPlayerWeaponShoot we use ColAndreas to cast a ray between NPC and its target. If there are no obstacles, we spawn a bullet which hits the target (we can also add some kind of accuracy here) and change target's health. As a result, no cheat will save player from being hit by NPC.
Thanks!