SA-MP Forums Archive
getting bullet coordinates - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: getting bullet coordinates (/showthread.php?tid=625580)



getting bullet coordinates - FFAKO - 03.01.2017

how to get x,y,z of a bullet that penetrated to shotted player and make it a variable like new = BulletCoordinates;
BulletCoordinates = x,y,z of penetrated bullet and also my code gives error why?
it says invalid declarition or function

new myobject;
myobject = CreateObject(19836, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{ AttachObjectToPlayer(myobject, playerid, 1.5, 0.5, 0.0, 0.0, 1.5, 2);
return 1;
}


Re: getting bullet coordinates - iamjems - 03.01.2017

I suggest using player variables in order to control the objects and bullet information.
I also suggest using CreatePlayerObject and AttachPlayerObjectToPlayer.

You must create the object in another function or callback or whatever:

PHP код:
new myobject[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
    
myobject[playerid] = CreatePlayerObject(playerid198360.00.00.00.00.00.0);
    return 
1;
}
public 
OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart)
{
    
AttachPlayerObjectToPlayer(playeridmyobject[playerid], playerid1.50.50.00.01.52);
    return 
1;

This is to store the bullet's X, Y and Z:

PHP код:
new Float:BulletCoordinates[3][MAX_PLAYERS];
public 
OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
    if(
hittype == BULLET_HIT_TYPE_PLAYER)
    {
        
BulletCoordinates[0][playerid] = fX;
        
BulletCoordinates[1][playerid] = fY;
        
BulletCoordinates[2][playerid] = fZ;
        
BulletCoordinates[0][hitid] = fX;
        
BulletCoordinates[1][hitid] = fY;
        
BulletCoordinates[2][hitid] = fZ;
    }
    return 
1;

Be sure to create the new variables at the top of your script.


Re: getting bullet coordinates - FFAKO - 04.01.2017

thank you very much i was looking this for 2 weeks