forward OnPlayerWeaponShot( .... );
#1

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)
Reply
#2

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

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:
Reply
#4

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;
}
Reply
#5

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*/)
?
Reply
#6

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.
Reply
#7

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!
Reply
#8

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?
Reply
#9

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
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)