Posts: 775
Threads: 78
Joined: Dec 2014
Posts: 578
Threads: 40
Joined: Dec 2016
Try debugging a bit further:
PHP код:
#if !defined PRESSED
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
#endif
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (PRESSED(KEY_FIRE) && !IsPlayerInAnyVehicle(playerid) && GetPlayerWeapon(playerid) != 0)
{
SendClientMessage(playerid, -1, "[Debug] Should have shot a bullet.");
SetTimerEx("DebugBulletInfo", 500, false, "i", playerid);
}
return 1;
}
forward DebugBulletInfo(playerid);
public DebugBulletInfo(playerid) {
new lsString[128],
Float:fOriginX, Float:fOriginY, Float:fOriginZ,
Float:fHitPosX, Float:fHitPosY, Float:fHitPosZ;
GetPlayerLastShotVectors(playerid, fOriginX, fOriginY, fOriginZ, fHitPosX, fHitPosY, fHitPosZ);
format(lsString, 128, "Bullet info. launch pos: %f, %f, %f - hit pos: %f, %f, %f", fOriginX, fOriginY, fOriginZ, fHitPosX, fHitPosY, fHitPosZ);
SendClientMessage(playerid, -1, lsString);
}
OBS: written straight from browser, might have some warnings.
Posts: 1,801
Threads: 21
Joined: Mar 2008
Reputation:
0
If no bullet is actually shot (which is the case when you shoot the sky or a target that is too far for the collision to be loaded), the callback won't be called. Simple as that.
The cause is a lack of a bullet.
Note: this is for the Sniper (since Sniper works a bit different from other guns). Take other weapons and it works (although the hit point retrieved by GetPlayerLastShotVector will be wrong - 23.040445, 0.0, 0.0 mostly - this depends where you are).