SA-MP Forums Archive
forward OnPlayerWeaponShot( .... ); - 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: forward OnPlayerWeaponShot( .... ); (/showthread.php?tid=488072)



forward OnPlayerWeaponShot( .... ); - Kyance - 16.01.2014

Alright, so i saw this.

pawn Код:
#define BULLET_HIT_TYPE_OBJECT          3

forward OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
How do you use it with the "BULLET_HIT_TYPE_OBJECT"?

(I thought of making a small test script which makes objects fall( IF SHOT ) ;d)


Re: forward OnPlayerWeaponShot( .... ); - Vince - 16.01.2014

'hitid' will be the id of the object that you just shot. So you can use that as input for IsValidObject and the like.


Re: forward OnPlayerWeaponShot( .... ); - Kyance - 16.01.2014

Quote:
Originally Posted by Vince
Посмотреть сообщение
'hitid' will be the id of the object that you just shot. So you can use that as input for IsValidObject and the like.
Uh, could you give me an example please?D:


Re: forward OnPlayerWeaponShot( .... ); - IstuntmanI - 16.01.2014

pawn Код:
public OnPlayerWeaponShot( playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ )
{
    switch( hittype )
    {
        case BULLET_HIT_TYPE_OBJECT:
        {
            if( IsValidObject( hitid ) )
            {
                SendClientMessage( playerid, -1, "You shot an object and it was destroyed !" );

                DestroyObject( hitid );
            }
        }
    }
    return 1;
}



Re: forward OnPlayerWeaponShot( .... ); - Kyance - 16.01.2014

Quote:
Originally Posted by IstuntmanI
Посмотреть сообщение
pawn Код:
public OnPlayerWeaponShot( playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ )
{
    if( hittype == BULLET_HIT_TYPE_OBJECT )
    {
        if( IsValidObject( hitid ) )
        {
            SendClientMessage( playerid, -1, "You shot an object and it was destroyed !" );

            DestroyObject( hitid );
        }
    }
}
Thank you so much!
Also, can i use something like
pawn Код:
if(hitid == /*ObjectID Here*/)
?


Re: forward OnPlayerWeaponShot( .... ); - IstuntmanI - 16.01.2014

Quote:
Originally Posted by Kyance
Посмотреть сообщение
Thank you so much!
Also, can i use something like
pawn Код:
if(hitid == /*ObjectID Here*/)
?
Of course !

pawn Код:
public OnPlayerWeaponShot( playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ )
{
    if( hittype == BULLET_HIT_TYPE_OBJECT )
    {
        if( IsValidObject( hitid ) && hitid == OBJECT_ID )
        {
            SendClientMessage( playerid, -1, "You shot an object and it was destroyed !" );

            DestroyObject( hitid );
        }
    }
    return 1;
}
Anyway, you don't have to use IsValidObject if already checking for BULLET_HIT_TYPE_OBJECT, because it surely exists if it was reported as hitid.


Re: forward OnPlayerWeaponShot( .... ); - Kyance - 16.01.2014

Quote:
Originally Posted by IstuntmanI
Посмотреть сообщение
Of course !

pawn Код:
public OnPlayerWeaponShot( playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ )
{
    if( hittype == BULLET_HIT_TYPE_OBJECT )
    {
        if( IsValidObject( hitid ) && hitid == OBJECT_ID )
        {
            SendClientMessage( playerid, -1, "You shot an object and it was destroyed !" );

            DestroyObject( hitid );
        }
    }
    return 1;
}
Anyway, you don't have to use IsValidObject if already checking for BULLET_HIT_TYPE_OBJECT, because it surely exists if it was reported as hitid.
Alright, thanks again!


Re: forward OnPlayerWeaponShot( .... ); - MA_proking - 16.01.2014

pawn Код:
public OnPlayerWeaponShot( playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ )
{
    switch( hittype )
    {
        case BULLET_HIT_TYPE_VEHICLE:
        {
            SetVehicleHealth(hidit, 10);
        }
    }
    return 1;
}
Is this possible with vehicle like that?


Re: forward OnPlayerWeaponShot( .... ); - iZN - 16.01.2014

Quote:
Originally Posted by MA_proking
Посмотреть сообщение
pawn Код:
public OnPlayerWeaponShot( playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ )
{
    switch( hittype )
    {
        case BULLET_HIT_TYPE_VEHICLE:
        {
            SetVehicleHealth(hidit, 10);
        }
    }
    return 1;
}
Is this possible with vehicle like that?
I guess it should work, you can test it by yourself. Also it is hitid* not hidit


Re: forward OnPlayerWeaponShot( .... ); - Stepashka - 16.01.2014

Quote:
Originally Posted by MA_proking
Посмотреть сообщение
pawn Код:
public OnPlayerWeaponShot( playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ )
{
    switch( hittype )
    {
        case BULLET_HIT_TYPE_VEHICLE:
        {
            SetVehicleHealth(hidit, 10);
        }
    }
    return 1;
}
Is this possible with vehicle like that?
yes.