Esempio n. 1
0
int CLuaPlayerDefs::GetPlayerNametagColor(lua_State* luaVM)
{
    //  int, int, int getPlayerNametagColor ( player thePlayer )
    CClientPlayer* pPlayer;

    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pPlayer);

    if (!argStream.HasErrors())
    {
        // Grab his nametag color and return it
        unsigned char ucR, ucG, ucB;
        pPlayer->GetNametagColor(ucR, ucG, ucB);

        lua_pushnumber(luaVM, ucR);
        lua_pushnumber(luaVM, ucG);
        lua_pushnumber(luaVM, ucB);
        return 3;
    }
    else
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

    // Failed
    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 2
0
int CLuaMarkerDefs::SetMarkerColor(lua_State* luaVM)
{
    CElement* pElement;
    SColor    color;

    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pElement);
    argStream.ReadNumber(color.R);
    argStream.ReadNumber(color.G);
    argStream.ReadNumber(color.B);
    argStream.ReadNumber(color.A);

    if (!argStream.HasErrors())
    {
        if (CStaticFunctionDefinitions::SetMarkerColor(pElement, color))
        {
            lua_pushboolean(luaVM, true);
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 3
0
int ROC::LuaPhysicsDef::GetFloorEnabled(lua_State *f_vm)
{
    // bool physicsGetFloorEnabled()
    ArgReader argStream(f_vm);
    argStream.PushBoolean(Core::GetCore()->GetPhysicsManager()->GetFloorEnabled());
    return argStream.GetReturnValue();
}
Esempio n. 4
0
int CLuaRadarAreaDefs::SetRadarAreaColor(lua_State* luaVM)
{
    //  bool setRadarAreaColor ( radararea theRadarArea, int r, int g, int b, int a )
    CElement* pElement;
    float     dRed;
    float     dGreen;
    float     dBlue;
    float     dAlpha;

    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pElement);
    argStream.ReadNumber(dRed);
    argStream.ReadNumber(dGreen);
    argStream.ReadNumber(dBlue);
    argStream.ReadNumber(dAlpha, 255);

    if (!argStream.HasErrors())
    {
        SColorRGBA color(dRed, dGreen, dBlue, dAlpha);
        if (CStaticFunctionDefinitions::SetRadarAreaColor(pElement, color))
        {
            lua_pushboolean(luaVM, true);
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 5
0
int CLuaMarkerDefs::GetMarkerColor(lua_State* luaVM)
{
    CMarker* pMarker;

    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pMarker);

    if (!argStream.HasErrors())
    {
        SColor color;
        if (CStaticFunctionDefinitions::GetMarkerColor(pMarker, color))
        {
            lua_pushnumber(luaVM, static_cast<lua_Number>(color.R));
            lua_pushnumber(luaVM, static_cast<lua_Number>(color.G));
            lua_pushnumber(luaVM, static_cast<lua_Number>(color.B));
            lua_pushnumber(luaVM, static_cast<lua_Number>(color.A));
            return 4;
        }
    }
    else
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 6
0
int CLuaBlipDefs::SetBlipSize(lua_State* luaVM)
{
    CClientEntity*   pEntity = NULL;
    int              iSize = 0;
    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pEntity);
    argStream.ReadNumber(iSize);

    if (iSize < 0 || iSize > 25)
        argStream.SetCustomWarning(SString("Blip size beyond 25 is no longer supported (got %i). It will be clamped between 0 and 25.", iSize));

    if (!argStream.HasErrors())
    {
        unsigned char ucSize = Clamp(0, iSize, 25);

        if (CStaticFunctionDefinitions::SetBlipSize(*pEntity, ucSize))
        {
            lua_pushboolean(luaVM, true);
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 7
0
int CLuaRadarAreaDefs::GetRadarAreaColor(lua_State* luaVM)
{
    //  int, int, int, int getRadarAreaColor ( radararea theRadararea )
    CRadarArea* pRadarArea;

    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pRadarArea);

    if (!argStream.HasErrors())
    {
        SColor color;
        if (CStaticFunctionDefinitions::GetRadarAreaColor(pRadarArea, color))
        {
            lua_pushnumber(luaVM, static_cast<lua_Number>(color.R));
            lua_pushnumber(luaVM, static_cast<lua_Number>(color.G));
            lua_pushnumber(luaVM, static_cast<lua_Number>(color.B));
            lua_pushnumber(luaVM, static_cast<lua_Number>(color.A));
            return 4;
        }
    }
    else
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 8
0
static void
    configure(const void* tags, size_t tags_size, const void* args, size_t args_size, Methcla_SynthOptions* outOptions)
    {
        OSCPP::Server::ArgStream argStream(OSCPP::ReadStream(tags, tags_size), OSCPP::ReadStream(args, args_size));
        Options* options = (Options*)outOptions;
        options->fftSize = argStream.int32();       
    }
Esempio n. 9
0
int CLuaAccountDefs::GetAccountData(lua_State* luaVM)
{
    //  string getAccountData ( account theAccount, string key )
    CAccount* pAccount;
    SString   strKey;

    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pAccount);
    argStream.ReadString(strKey);

    if (!argStream.HasErrors())
    {
        auto pArgument = CStaticFunctionDefinitions::GetAccountData(pAccount, strKey);
        if (pArgument)
        {
            pArgument->Push(luaVM);
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 10
0
int CLuaVector3Defs::Dot(lua_State* luaVM)
{
    CLuaVector3D* pVector1 = NULL;
    CLuaVector3D* pVector2 = NULL;

    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pVector1);
    argStream.ReadUserData(pVector2);

    if (!argStream.HasErrors())
    {
        CVector vector(*pVector1);
        float   fProduct = vector.DotProduct(pVector2);

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

    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 11
0
int CLuaVector3Defs::Div(lua_State* luaVM)
{
    CLuaVector3D* pVector1 = NULL;
    CLuaVector3D* pVector2 = NULL;

    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pVector1);

    if (argStream.NextIsNumber())
    {
        float fValue = 0.0f;
        argStream.ReadNumber(fValue);

        lua_pushvector(luaVM, *pVector1 / fValue);
        return 1;
    }
    else
    {
        argStream.ReadUserData(pVector2);

        if (!argStream.HasErrors())
        {
            lua_pushvector(luaVM, *pVector1 / *pVector2);
            return 1;
        }
        else
        {
            m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
        }
    }

    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 12
0
int CLuaPlayerDefs::SetPlayerNametagShowing(lua_State* luaVM)
{
    //  bool setPlayerNametagShowing ( player thePlayer, bool showing )
    CClientEntity* pPlayer;
    bool           bShowing;

    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pPlayer);
    argStream.ReadBool(bShowing);

    if (!argStream.HasErrors())
    {
        // Set the new rotation
        if (CStaticFunctionDefinitions::SetPlayerNametagShowing(*pPlayer, bShowing))
        {
            lua_pushboolean(luaVM, true);
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

    // Failed
    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 13
0
int CLuaPlayerDefs::ShowPlayerHudComponent(lua_State* luaVM)
{
    //  bool showPlayerHudComponent ( string component, bool show )
    eHudComponent component;
    bool          bShow;

    CScriptArgReader argStream(luaVM);
    argStream.ReadEnumString(component);
    argStream.ReadBool(bShow);

    if (!argStream.HasErrors())
    {
        if (CStaticFunctionDefinitions::ShowPlayerHudComponent(component, bShow))
        {
            lua_pushboolean(luaVM, true);
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

    // Failed
    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 14
0
int CLuaPlayerDefs::GetPlayerTeam(lua_State* luaVM)
{
    //  team getPlayerTeam ( player thePlayer )
    CClientPlayer* pPlayer;

    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pPlayer);

    if (!argStream.HasErrors())
    {
        // Grab his team and return it
        CClientTeam* pTeam = pPlayer->GetTeam();
        if (pTeam)
        {
            lua_pushelement(luaVM, pTeam);
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

    // Failed
    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 15
0
int CLuaAccountDefs::LogIn(lua_State* luaVM)
{
    //  bool logIn ( player thePlayer, account theAccount, string thePassword )
    CPlayer*  pPlayer;
    CAccount* pAccount;
    SString   strPassword;

    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pPlayer);
    argStream.ReadUserData(pAccount);
    argStream.ReadString(strPassword);

    if (!argStream.HasErrors())
    {
        // Log him in
        if (CStaticFunctionDefinitions::LogIn(pPlayer, pAccount, strPassword))
        {
            // Success
            lua_pushboolean(luaVM, true);
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

    // Failed
    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 16
0
int CLuaAccountDefs::GetAccount(lua_State* luaVM)
{
    //  account getAccount ( string username, [ string password ] )
    SString strName;
    SString strPassword;
    bool    bUsePassword = false;

    CScriptArgReader argStream(luaVM);
    argStream.ReadString(strName);

    if (!argStream.NextIsNil() && !argStream.NextIsNone())
    {
        argStream.ReadString(strPassword);
        bUsePassword = true;
    }

    if (!argStream.HasErrors())
    {
        CAccount* pAccount = CStaticFunctionDefinitions::GetAccount(strName, bUsePassword ? strPassword.c_str() : NULL);
        if (pAccount)
        {
            lua_pushaccount(luaVM, pAccount);
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 17
0
int CLuaAccountDefs::LogOut(lua_State* luaVM)
{
    //  bool logOut ( player thePlayer )
    CPlayer* pPlayer;

    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pPlayer);

    if (!argStream.HasErrors())
    {
        // Log out
        if (CStaticFunctionDefinitions::LogOut(pPlayer))
        {
            // Success
            lua_pushboolean(luaVM, true);
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

    // Failed
    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 18
0
int CLuaAccountDefs::GetAccountsByIP(lua_State* luaVM)
{
    // table getAccountsByIP ( string ip )
    SString strIP;

    CScriptArgReader argStream(luaVM);
    argStream.ReadString(strIP);

    if (!argStream.HasErrors())
    {
        lua_newtable(luaVM);
        std::vector<CAccount*> accounts;

        CStaticFunctionDefinitions::GetAccountsByIP(strIP, accounts);
        for (unsigned int i = 0; i < accounts.size(); ++i)
        {
            lua_pushnumber(luaVM, i + 1);
            lua_pushaccount(luaVM, accounts[i]);
            lua_settable(luaVM, -3);
        }
        return 1;
    }
    else
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 19
0
int CLuaBlipDefs::SetBlipColor(lua_State* luaVM)
{
    CClientEntity*   pEntity = NULL;
    SColor           color;
    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pEntity);
    argStream.ReadNumber(color.R);
    argStream.ReadNumber(color.G);
    argStream.ReadNumber(color.B);
    argStream.ReadNumber(color.A);

    if (!argStream.HasErrors())
    {
        if (CStaticFunctionDefinitions::SetBlipColor(*pEntity, color))
        {
            lua_pushboolean(luaVM, true);
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 20
0
int CLuaAccountDefs::AddAccount(lua_State* luaVM)
{
    //  account addAccount ( string name, string pass[, bool allowCaseVariations = false ] )
    SString strName;
    SString strPassword;
    bool    bAllowCaseVariations;

    CScriptArgReader argStream(luaVM);
    argStream.ReadString(strName);
    argStream.ReadString(strPassword);
    argStream.ReadBool(bAllowCaseVariations, false);

    SString strError;
    if (!argStream.HasErrors())
    {
        CAccount* pAccount;
        if ((pAccount = CStaticFunctionDefinitions::AddAccount(strName, strPassword, bAllowCaseVariations, strError)))
        {
            lua_pushaccount(luaVM, pAccount);
            return 1;
        }
    }

    if (argStream.HasErrors())
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

    lua_pushboolean(luaVM, false);
    lua_pushstring(luaVM, strError);
    return 2;
}
Esempio n. 21
0
int CLuaRadarAreaDefs::IsInsideRadarArea(lua_State* luaVM)
{
    //  bool isInsideRadarArea ( radararea theArea, float posX, float posY )
    CRadarArea* pRadarArea;
    CVector2D   vecPosition;

    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pRadarArea);
    argStream.ReadVector2D(vecPosition);

    if (!argStream.HasErrors())
    {
        bool bInside = false;
        if (CStaticFunctionDefinitions::IsInsideRadarArea(pRadarArea, vecPosition, bInside))
        {
            lua_pushboolean(luaVM, bInside);
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 22
0
int CLuaAccountDefs::RemoveAccount(lua_State* luaVM)
{
    //  bool removeAccount ( account theAccount )
    CAccount* pAccount;

    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pAccount);

    if (!argStream.HasErrors())
    {
        if (CStaticFunctionDefinitions::RemoveAccount(pAccount))
        {
            lua_pushboolean(luaVM, true);
            return 1;
        }

        CClient* pClient = pAccount->GetClient();
        if (pClient)
            argStream.SetCustomError("Unable to remove account as unable to log out client. (Maybe onPlayerLogout is cancelled)");
    }
    if (argStream.HasErrors())
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 23
0
int CLuaMatrixDefs::SetRotation(lua_State* luaVM)
{
    CLuaMatrix* pMatrix = NULL;
    CVector     vecRotation;

    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pMatrix);
    argStream.ReadVector3D(vecRotation);

    if (!argStream.HasErrors())
    {
        ConvertRadiansToDegreesNoWrap(vecRotation);
        pMatrix->SetRotation(vecRotation);

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

    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 24
0
int CLuaAccountDefs::SetAccountName(lua_State* luaVM)
{
    // bool setAccountPassword ( account theAccount, string name[, bool allowCaseVariations = false ] )
    CAccount* pAccount;
    SString   strNewName;
    bool      bAllowCaseVariations;

    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pAccount);
    argStream.ReadString(strNewName);
    argStream.ReadBool(bAllowCaseVariations, false);

    SString strError;
    if (!argStream.HasErrors())
    {
        if (CStaticFunctionDefinitions::SetAccountName(pAccount, strNewName, bAllowCaseVariations, strError))
        {
            lua_pushboolean(luaVM, true);
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 25
0
int CLuaMarkerDefs::OOP_GetMarkerTarget(lua_State* luaVM)
{
    CMarker* pMarker = NULL;

    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pMarker);

    if (!argStream.HasErrors())
    {
        CVector vecPosition;
        if (CStaticFunctionDefinitions::GetMarkerTarget(pMarker, vecPosition))
        {
            lua_pushvector(luaVM, vecPosition);
        }
        else
            lua_pushboolean(luaVM, false);

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

    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 26
0
int CLuaAccountDefs::SetAccountPassword(lua_State* luaVM)
{
    //  bool setAccountPassword ( account theAccount, string password )
    CAccount*                              pAccount;
    SString                                strPassword;
    CAccountPassword::EAccountPasswordType ePasswordType;

    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pAccount);
    argStream.ReadString(strPassword);
    argStream.ReadEnumString(ePasswordType, CAccountPassword::PLAINTEXT);

    if (!argStream.HasErrors())
    {
        if (CStaticFunctionDefinitions::SetAccountPassword(pAccount, strPassword, ePasswordType))
        {
            lua_pushboolean(luaVM, true);
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 27
0
int CLuaMarkerDefs::SetMarkerTarget(lua_State* luaVM)
{
    CElement* pElement;
    CVector   vecTarget;
    CVector*  pvecTarget = NULL;

    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pElement);

    if (argStream.NextIsVector3D())
    {
        argStream.ReadVector3D(vecTarget);
        pvecTarget = &vecTarget;
    }

    if (!argStream.HasErrors())
    {
        if (CStaticFunctionDefinitions::SetMarkerTarget(pElement, pvecTarget))
        {
            lua_pushboolean(luaVM, true);
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 28
0
int CLuaAccountDefs::SetAccountData(lua_State* luaVM)
{
    //  bool setAccountData ( account theAccount, string key, string value )
    CAccount*    pAccount;
    SString      strKey;
    CLuaArgument Variable;

    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pAccount);
    argStream.ReadString(strKey);
    argStream.ReadLuaArgument(Variable);

    if (!argStream.HasErrors())
    {
        if (CStaticFunctionDefinitions::SetAccountData(pAccount, strKey, &Variable))
        {
            lua_pushboolean(luaVM, true);
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

    lua_pushboolean(luaVM, false);
    return 1;
}
Esempio n. 29
0
int ROC::LuaPhysicsDef::RayCast(lua_State *f_vm)
{
    // float float float float float float element physicsRayCast(float startX, float startY, float startZ, float endX, float endY, float endZ)
    glm::vec3 l_start, l_end;
    ArgReader argStream(f_vm);
    for(int i = 0; i < 3; i++) argStream.ReadNumber(l_start[i]);
    for(int i = 0; i < 3; i++) argStream.ReadNumber(l_end[i]);
    if(!argStream.HasErrors())
    {
        glm::vec3 l_hitNormal;
        Element *l_hitElement = nullptr;
        if(Core::GetCore()->GetPhysicsManager()->RayCast(l_start, l_end, l_hitNormal, l_hitElement))
        {
            argStream.PushNumber(l_end.x);
            argStream.PushNumber(l_end.y);
            argStream.PushNumber(l_end.z);
            argStream.PushNumber(l_hitNormal.x);
            argStream.PushNumber(l_hitNormal.y);
            argStream.PushNumber(l_hitNormal.z);
            l_hitElement ? argStream.PushElement(l_hitElement) : argStream.PushBoolean(false);
        }
        else argStream.PushBoolean(false);
    }
    else argStream.PushBoolean(false);
    return argStream.GetReturnValue();
}
Esempio n. 30
0
int CLuaPlayerDefs::GetPlayerNametagText(lua_State* luaVM)
{
    //  string getPlayerNametagText ( player thePlayer )
    CClientPlayer* pPlayer;

    CScriptArgReader argStream(luaVM);
    argStream.ReadUserData(pPlayer);

    if (!argStream.HasErrors())
    {
        // Grab his nametag text and return it
        const char* szName = pPlayer->GetNametagText();
        if (szName)
        {
            lua_pushstring(luaVM, szName);
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

    // Failed
    lua_pushboolean(luaVM, false);
    return 1;
}