Page 1 of 1

0xBF Subcommand 4

Posted: Wed Jun 24, 2015 1:39 pm
by blckfire
I'm using POL96 so I don't have the CloseGump function.

I'm trying to build this packet to send it to the client so that it closes a gump before opening another one.

So, I am able to send the packet, but the client then stops after a few steps

Code: Select all

function CloseGump(mobile, pid, retval := 0)
	var packet := CreatePacket(0xBF, 13);
	packet.SetInt16(1, 0x4);
	packet.SetInt32(3, pid);
	packet.SetInt32(7, retval);
	packet.SendPacket(mobile);
	
	return 1;
endfunction
Do I need to do anything else? after I send this packet?

Re: 0xBF Subcommand 4

Posted: Wed Jun 24, 2015 2:11 pm
by blckfire
It is now solved. I was making some mistakes with the offsetts.

Code: Select all

use uo;
use os;
use polsys;

function CloseGump(mobile, pid, retval := 0)
	var packet := CreatePacket(0xBF, -1);
	packet.SetInt16(3, 0x4);
	packet.SetInt32(5, pid);
	packet.SetInt32(9, retval);
	
	var result := packet.SendPacket(mobile);
	if(!result)
		SendSysMessage(mobile, "Error: "+result);
	endif
	
	GetProcess(pid).kill();
	
	return 1;
endfunction
I post the code to do this in case someone wants to use this.

Re: 0xBF Subcommand 4

Posted: Wed Jun 24, 2015 2:51 pm
by Harley
Nice one! Are u using it like packethook?

Re: 0xBF Subcommand 4

Posted: Fri Jun 26, 2015 5:47 am
by blckfire
Nope. Just created a custom function to send the package out to the client and it works like a charm.

It basically allows you to emulate the CloseGump() function from later cores.

Eventually I'm going to upgrade the whole server to POL99 but for now I'll have to use this workaround.

As a side note:
Also, I decided to kill the script afterwards to make sure no crumbs are left behind.