Sphereserver / Source-X

Ultima Online server emulator
Apache License 2.0
57 stars 45 forks source link

[Feature Request] f_onaccount_block and f_onaccount_unblock #1156

Closed canerksk closed 1 month ago

canerksk commented 11 months ago

Shouldn't there be another function that works when blocked, like all other functions that work in most changes made to the account?

eg;


        case AV_BLOCK:
            if (!s.HasArgs() || s.GetArgVal())
            {

                if (!g_Serv.IsLoading())
                {
                    CScriptTriggerArgs Args;
                    Args.Init(GetName());
                    TRIGRET_TYPE tRet = TRIGRET_RET_FALSE;
                    g_Serv.r_Call("f_onaccount_block", &g_Serv, &Args, nullptr, &tRet);
                    if (tRet == TRIGRET_RET_TRUE)
                    {
                        return false;
                    }
                }

                SetPrivFlags(PRIV_BLOCKED);
            }   
            else
            {

                if (!g_Serv.IsLoading())
                {
                    CScriptTriggerArgs Args;
                    Args.Init(GetName());
                    TRIGRET_TYPE tRet = TRIGRET_RET_FALSE;
                    g_Serv.r_Call("f_onaccount_unblock", &g_Serv, &Args, nullptr, &tRet);
                    if (tRet == TRIGRET_RET_TRUE)
                    {
                        return false;
                    }
                }

                ClearPrivFlags(PRIV_BLOCKED);
            }

            return true;

case AC_BLOCK:
    if ( ! s.HasArgs() || s.GetArgVal())
    {
        if (!g_Serv.IsLoading())
        {
            CScriptTriggerArgs Args;
            Args.Init(GetName());
            TRIGRET_TYPE tRet = TRIGRET_RET_FALSE;
            g_Serv.r_Call("f_onaccount_block", &g_Serv, &Args, nullptr, &tRet);
            if (tRet == TRIGRET_RET_TRUE)
            {
                return false;
            }
        }
        SetPrivFlags( PRIV_BLOCKED );
    }
    else
    {
        if (!g_Serv.IsLoading())
        {
            CScriptTriggerArgs Args;
            Args.Init(GetName());
            TRIGRET_TYPE tRet = TRIGRET_RET_FALSE;
            g_Serv.r_Call("f_onaccount_unblock", &g_Serv, &Args, nullptr, &tRet);
            if (tRet == TRIGRET_RET_TRUE)
            {
                return false;
            }
        }
        ClearPrivFlags( PRIV_BLOCKED );
    }
    break;

block


    if ( fBlock )
    {
        SetPrivFlags( PRIV_BLOCKED );

        if (!g_Serv.IsLoading())
        {
            CScriptTriggerArgs Args;
            Args.Init(GetName());
            TRIGRET_TYPE tRet = TRIGRET_RET_FALSE;
            g_Serv.r_Call("f_onaccount_block", &g_Serv, &Args, nullptr, &tRet);
            if (tRet == TRIGRET_RET_TRUE)
            {
                return false;
            }
        }

        pSrc->SysMessagef( g_Cfg.GetDefaultMsg(DEFMSG_MSG_ACC_BLOCK), GetName() );
    }

The codes here are purely examples. Although many have been tested, some may need to be rewritten.