PenUltima Online Forum Index Official Core: 096.7
Official Core: 097 2008-02-26
Donate towards the POL web hosting bill!
 POL Home   FAQ   Search    Memberlist   Usergroups    Register    Profile   Log in to check your private messages   Log in
Closing gumps

 
Post new topic   Reply to topic    PenUltima Online Forum Index -> Scripting Help
Display posts from previous:   

Author Message
phao



Joined: 31 Aug 2007
Posts: 34

PostPosted: Sun Mar 30, 2008 3:47 am    Post subject: Closing gumps Reply with quote

Can anyone here tell me how can I close gumps in a server scripts using 0xBF packet?

Author Message
ncrsn



Joined: 10 Feb 2006
Posts: 183

PostPosted: Sun Mar 30, 2008 8:40 am    Post subject: Reply with quote

http://packets.polserver.com/index.php?op=showpacket&packet=0xBF, the key is subcommand 4.

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

Code:

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:

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 12:13 pm; edited 1 time in total

Post new topic   Reply to topic    PenUltima Online Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 




Powered by phpBB © 2001, 2005 phpBB Group :: Theme & Graphics by GHS & Scott E. Royalty