Author Topic: Parenting problem  (Read 629 times)

I have a mod that uses
Code: [Select]
function useBricks()
{
    //code and parent
}
I want to be able to disable the parent and call a command to server when the client joins the server with it enabled.
But once the client joins another server the parent works and he should be able to use the brick menu like normal

How do I do this?

I have a mod that uses
Code: [Select]
function useBricks()
{
    //code and parent
}
I want to be able to disable the parent and call a command to server when the client joins the server with it enabled.
But once the client joins another server the parent works and he should be able to use the brick menu like normal

How do I do this?

CLIENT
Code: [Select]
function clientCmdBrickOverride_Ack()
{
    if(isEventPending($BrickOverride_Timeout);
        cancel($BrickOverride_Timeout);

    useBricks(2);
}

package UseBricksOverride
{
function useBricks(%whichCmd)
{
    if(%whichCmd == 1)
        parent::useBricks();
    else if(%whichCmd == 2)
    {
        //do your override thing here
    }
    else
    {
        $BrickOverride_Timeout = schedule(1000,0,"useBricks",1);
        commandToServer('BrickOverride_RequestAck');
    }
}
};

activatepackage("UseBricksOverride");

SERVER
Code: [Select]
function serverCmdBrickOverride_RequestAck(%client)
{
    commandToClient(%client,'BrickOverride_Ack');
}
This is sort of your basis, but you should test it.
« Last Edit: September 12, 2012, 06:54:44 PM by Axolotl2 »


Why in the world do you need schedules and global variables for a simple conditional overwrite?

Code: [Select]
package your_package_name_goes_here
{
    function useBricks( %slot )
    {
        if ( serverConnection.enableYourUseBricksOverwrite )
        {
            ...
        }
        else
        {
            parent::useBricks( %slot );
        }
    }
};

activatePackage( "your_package_name_goes_here" );

function clientCmdServerHasYourAddOn()
{
    serverConnection.enableYourUseBricksOverwrite = true;
}