void CClientPickup::Create ( void )
{
    if ( !m_pPickup )
    {
        // Create the pickup
        m_pPickup = g_pGame->GetPickups ()->CreatePickup ( &m_vecPosition, m_usModel, PICKUP_ONCE );
        m_pObject = NULL;
        if ( m_pPickup )
        {
            // Grab the attributes from the MTA interface for this pickup
            unsigned char ucAreaCode = GetInterior ();
            unsigned short usDimension = GetDimension ();

            // Make sure we have an object
            if ( !m_pPickup->GetObject () ) m_pPickup->GiveUsAPickUpObject ();

            // Store our pickup's object
            m_pObject = m_pPickup->GetObject ();

            // Create our collision
            m_pCollision = new CClientColSphere ( g_pClientGame->GetManager(), NULL, m_vecPosition, 1.0f );
            m_pCollision->m_pOwningPickup = this;
            m_pCollision->SetHitCallback ( this );

            // Increment pickup counter
            ++m_pPickupManager->m_uiPickupCount;

            // Restore the attributes
            SetInterior ( ucAreaCode );
            SetDimension ( usDimension );
        }
    }
}
Exemple #2
0
void CPickup::Callback_OnLeave ( CColShape& Shape, CElement& Element )
{
    if ( IS_PLAYER ( &Element ) )
    {
        CPlayer& Player = static_cast < CPlayer& > ( Element );

        // Matching interior
        if ( GetInterior () == Element.GetInterior () )
        {
            // Matching dimension
            if ( GetDimension () == Element.GetDimension () )
            {
                // Is he alive?
                if ( !Player.IsDead () )
                {
                    // Call the onPickupHit event
                    CLuaArguments Arguments;
                    Arguments.PushElement ( &Player );
                    CallEvent ( "onPickupLeave", Arguments );

                    CLuaArguments Arguments2;
                    Arguments2.PushElement ( this );       // pickup
                    Element.CallEvent ( "onPlayerPickupLeave", Arguments2 );            
                }
            }
        }
    }
}
Exemple #3
0
void CPickup::Callback_OnCollision ( CColShape& Shape, CElement& Element )
{
    if ( IS_PLAYER ( &Element ) )
    {
        CPlayer& Player = static_cast < CPlayer& > ( Element );

        // Is he alive?
        if ( !Player.IsDead () )
        {
            // Matching interior
            if ( GetInterior () == Element.GetInterior () )
            {
                // Matching dimension
                if ( GetDimension () == Element.GetDimension () )
                {
                    // Call the onPickupHit event
                    CLuaArguments Arguments;
                    Arguments.PushElement ( &Player );
                    bool bContinue1 = CallEvent ( "onPickupHit", Arguments );

                    CLuaArguments Arguments2;
                    Arguments2.PushElement ( this );       // pickup
                    bool bContinue2 = Element.CallEvent ( "onPlayerPickupHit", Arguments2 );

                    if ( bContinue1 && bContinue2 )
                    {
                        // Does it still exist?
                        if ( !IsBeingDeleted () )
                        {
                            // Can we USE the pickup?
                            if ( CanUse ( Player ) )
                            {
                                // USE the pickup
                                Use ( Player );
                            }
                        }
                    }
                }
            }
        }
    }
}
Exemple #4
0
void CMarker::Callback_OnLeave ( CColShape& Shape, CElement& Element )
{
    // Matching interior?
    if ( GetInterior () == Element.GetInterior () )
    {
        // Call the marker hit event
        CLuaArguments Arguments;
        Arguments.PushElement ( &Element ); // Hit element
        Arguments.PushBoolean ( GetDimension () == Element.GetDimension () );        // Matching dimension?
        CallEvent ( "onMarkerLeave", Arguments );

        if ( IS_PLAYER ( &Element ) )
        {
            CLuaArguments Arguments2;
            Arguments2.PushElement ( this );        // marker
            Arguments2.PushBoolean ( GetDimension () == Element.GetDimension () );        // Matching dimension?
            Element.CallEvent ( "onPlayerMarkerLeave", Arguments2 );
        }
    }
}