It is currently Fri Nov 21, 2008 2:24 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Closing gumps
PostPosted: Sat Mar 29, 2008 11:47 pm 
Offline

Joined: Fri Aug 31, 2007 2:25 pm
Posts: 77
Can anyone here tell me how can I close gumps in a server scripts using 0xBF packet?

_________________
Hello from Brazil :)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 30, 2008 4:40 am 
Offline
User avatar

Joined: Fri Feb 10, 2006 12:15 am
Posts: 225
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 8:13 am, edited 1 time in total.

Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl