CloseGump()

Moderator: POL Developer

Locked
User avatar
*Edwards
Forum Regular
Posts: 303
Joined: Fri Dec 28, 2007 11:19 pm
Location: Montreal, Canada

CloseGump()

Post by *Edwards »

I can't find a way to close any gump with the CloseGump function since 098. Even my old packets aren't working. Might be something missing.

Code: Select all

use uo;

include ":gumps:gumps";
include ":gumps:gumps_ex";

program test( mobile )

        SetObjProperty( mobile, "#CloseGumpPID", GetPid() );

        //Initialize the gump
        var gump := GFCreateGump();

        GFResizePic( gump, 275, 230, GFGetCfgConst( "BackGrounds", "GOLDTRIM" ), 250, 100 );

        var close_gump := GetObjProperty( mobile, "#CloseGumpPID" );
        var result := CloseGump( mobile, close_gump, 0x10 );
        broadcast( result );

        //And now we need to know the answer...
        var input := GFSendGump( mobile, gump );
        if( input[0x10] )
                  return 0;
        endif

        return 1;
endprogram
it returns "Couldn't find any scripts".

POL098 RC2
User avatar
*Edwards
Forum Regular
Posts: 303
Joined: Fri Dec 28, 2007 11:19 pm
Location: Montreal, Canada

Re: CloseGump()

Post by *Edwards »

I tested differently with the help of Tomi and it works.

I created a script that shall call the gump script. So script :test:gumpTest will display what I want to mobile. 2 seconds later CloseGump of the gump pid is called to return 0x10...

Code: Select all

use uo;

program test( mobile )

        var process := start_script( ":test:gumpTest", mobile );
        var gumpid := process.pid;
        
        Sleep(2);
        
        var result := CloseGump( mobile, gumpid, 0x10 );
        Broadcast( gumpid );

        return 1;
endprogram

Problem: if you call CloseGump directly from the gump' script it doesn't work and return Couldn't find script. I believe it should work at the moment you have the pid...
User avatar
ncrsn
Grandmaster Poster
Posts: 255
Joined: Fri Feb 10, 2006 12:15 am

Re: CloseGump()

Post by ncrsn »

Well, think about it.

If you write 1. CloseGump() 2. SendDialogLayout(), there is no gump to close because you haven't send it yet. If you try 1. SendDialogLayout() 2. CloseGump(), on the other hand, send function holds script until player replies, and because of that, once you try to close the gump, it no longer exists.

Until a new method is created, you cannot close a gump from the very same process that sends it, so I don't consider this as a bug.
Locked