OnSniperRifleFired
Description:
This function is called when a player fires a sniper rifle. This function is not called if the npc itself is firing the sniper rifle using FireSniperRifle. If more than one npc is there, this function gets called when other npcs fire sniper rifle using FireSniperRifle.
Parameters:
( playerid, weaponid, x, y, z, dx, dy, dz )
playerId : The ID of the player who fired
weaponid: The ID of the weapon fired. ( Usually 28 or 29 )
x : The source x co-ordinate of the firing.
y : The source y co-ordinate of the firing.
z : The source z co-ordinate of the firing
dx : The x component of the normalized direction vector multiplied by 16.0
dy : The y component of the normalized direction vector multiplied by 16.0
dz : The z component of the normalized direction vector multiplied by 16.0
Example
function OnSniperRifleFired( playerid, weaponid, x, y, z, dx, dy, dz ) { dx= dx/16.0; dy = dy/16.0; dz = dz/16.0; local start = Vector( x, y, z ); local start += Vector( dx, dy, dz ); local end = start + Vector( 90.0 * dx, 90.0 * dy, 90.0 * dz ); //90.0 is the range of Ruger //Now RayTrace function with the above values viz. start, end and flag as 2 will give hit position. //RayTrace is clientside function. So all the values can be passed to playerid via server local command= format("PLOS %d %.4f %.4f %.4f %.4f %.4f %.4f %d %d", playerid, x, y, z, dx, dy, dz, 2, weaponid ); SendCommand(command); //This will call the onPlayerCommand with cmd = "PLOS" and rest as text. }