Closing gumps

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
phao
Grandmaster Poster
Posts: 129
Joined: Fri Aug 31, 2007 2:25 pm

Closing gumps

Post by phao »

Can anyone here tell me how can I close gumps in a server scripts using 0xBF packet?
User avatar
ncrsn
Grandmaster Poster
Posts: 255
Joined: Fri Feb 10, 2006 12:15 am

Post by ncrsn »

http://packets.polserver.com/index.php? ... acket=0xBF, the key is subcommand 4.

Example function exists in distro, gumps_ex.inc in gumps package.

Code: Select all

function GFCloseGump(mobile, pid, ret_val:=0)
	var packet := CreatePacket(0xBF, 13);
	packet.SetInt16(1, 13);
	packet.SetInt16(3, 4);
	packet.SetInt32(5, pid);
	packet.SetInt32(9, ret_val);

	return packet.SendPacket(mobile);
endfunction
In POL, dialogID is the pid of the script that sent the gump. See the command below.

textcmd .closegump

Code: Select all

use os;
use uo;

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

program command_closegump( who, param )
    if (param)
         var closegump := who.GetProp("#CloseGumpPID");

         if (closegump)
             GFCloseGump(who, closegump);
             who.EraseProp("#CloseGumpPID");
             return 1;
         endif
    endif
    
    who.SetProp("#CloseGumpPID", GetPid());
    
    YesNo(who, "This gump will close if you write .closegump 1");
    
    who.EraseProp("#CloseGumpPID");

    return 1;
endprogram
According the sourcefiles I have, this should compile and work. The idea anyway is correct.

--

Note though, it is possible that client does not reply if you close gump this way. Because of that, the script that sent the gump will turn into zombie, waiting for something to happen that will never occur. Only "workaround" I can think of is to kill the zombie process.

If you know how this could be avoided, I sure am willing to know.


--
edit: fixed a typo.
Last edited by ncrsn on Sun Mar 30, 2008 8:13 am, edited 1 time in total.
Post Reply