Exemplo n.º 1
0
int CLuaTeamDefs::GetPlayersInTeam ( lua_State* luaVM )
{
    CClientTeam* pTeam = NULL;
    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pTeam );

    if ( !argStream.HasErrors () )
    {
        lua_newtable ( luaVM );

        unsigned int uiIndex = 0;

        list < CClientPlayer* > ::const_iterator iter = pTeam->IterBegin ();
        for ( ; iter != pTeam->IterEnd (); iter++ )
        {
            CClientPlayer* pPlayer = *iter;
            if ( !pPlayer->IsBeingDeleted () )
            {
                lua_pushnumber ( luaVM, ++uiIndex );
                lua_pushelement ( luaVM, pPlayer );
                lua_settable ( luaVM, -3 );
            }
        }

        return 1;
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

    lua_pushboolean ( luaVM, false );
    return 1;
}
Exemplo n.º 2
0
void CElementRPCs::SetElementDimension ( NetBitStreamInterface& bitStream )
{
    ElementID ID;
    unsigned short usDimension;
    if ( bitStream.Read ( ID ) && bitStream.Read ( usDimension ) )
    {
        CClientEntity* pEntity = CElementIDs::GetElement ( ID );
        if ( pEntity )
        {
            if ( pEntity->GetType () == CCLIENTTEAM )
            {
                CClientTeam* pTeam = static_cast < CClientTeam* > ( pEntity );
                list < CClientPlayer* > ::const_iterator iter = pTeam->IterBegin ();
                for ( ; iter != pTeam->IterEnd () ; iter++ )
                {
                    CClientPlayer* pPlayer = *iter;
                    if ( pPlayer->IsLocalPlayer () )
                    {
                        // Update all of our streamers/managers to the local player's dimension
                        m_pClientGame->SetAllDimensions ( usDimension );
                    }

                    pPlayer->SetDimension ( usDimension );
                }
            }
            else
            {
                if ( pEntity->GetType () == CCLIENTPLAYER )
                {
                    CClientPlayer* pPlayer = static_cast < CClientPlayer* > ( pEntity );
                    if ( pPlayer->IsLocalPlayer () )
                    {
                        // Update all of our streamers/managers to the local player's dimension
                        m_pClientGame->SetAllDimensions ( usDimension );
                    }         
                }
                
                pEntity->SetDimension ( usDimension );
            }
        }
    }
}