buy window packet

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
Mouse
New User
Posts: 2
Joined: Fri Jan 15, 2010 9:40 am

buy window packet

Post by Mouse »

Hello!

I'm trying to modify the package sendbuywindow, prentem modify the values of prices and description of the name.

using the code below does not get any success yet, it seems that the package remains unchanged.

Code: Select all

use uo;
use os;
use storage;
use polsys;


const OFFSET_CMD := 0;
const OFFSET_BLOCK := 1;
const OFFSET_ID := 3;
const OFFSET_N_ITEMS := 7;
const OFFSET_ITEM := 8;


program openbuywindow()

	print( "INSTALLING: New Buy Window..." );
        return 1;

endprogram

exported function newbuywindow(who, byref packet)

	Broadcast(packet);

	var cmd := packet.GetInt8(OFFSET_CMD);
	var block := packet.GetInt16(OFFSET_BLOCK);
	var id := packet.GetInt32(OFFSET_ID);
	var num_items := packet.GetInt8(OFFSET_N_ITEMS);

	var backpack := SystemFindObjectBySerial(id);
	
	var length:=OFFSET_ITEM;
	var n_items:=0;
	var tamm;

	var name;

	var items_backpack:=EnumerateItemsInContainer(backpack);
	items_backpack.Reverse();

	foreach items in items_backpack;
			
			packet.SetInt32(length, items.VendorSellsFor + 100 );

			name:="new "+items.desc;

			packet.SetInt8(length+4, len(name));
			
			packet.SetString(length+4+1, name,1);
			
			length:=length+4+1+(len(name));

		sleepms(1);
	endforeach

	

	return 1;
	
endfunction
When I put packet.sendpacket (who) at the end to modify the package, place a loop of 200 times in the function.

Another question is about the values of BYTE [1] and cmd BYTE [2] blockSize what they mean? I tried to create the package from the beginning too, but I do not know what values I assign to cmd and blocksize.

What am I doing wrong?
Tomi
POL Developer
Posts: 478
Joined: Tue Feb 21, 2006 5:08 pm

Re: buy window packet

Post by Tomi »

"return 1" in the end of script stops this packet going from ( server -> client or client->server )

Try to change it to return 0; and the packet will be sent modified. Now the packet just stops at your packethook when you are using return 1;
Mouse
New User
Posts: 2
Joined: Fri Jan 15, 2010 9:40 am

Re: buy window packet

Post by Mouse »

With both return 1 return 0 as the end, the same thing happens.

With the code I posted, it changes the values of the items more settings, but I can not change the description.
Tomi
POL Developer
Posts: 478
Joined: Tue Feb 21, 2006 5:08 pm

Re: buy window packet

Post by Tomi »

Remove those blocksize stuff you have there

just after your foreach loop add this

Code: Select all

packet.SetInt16( OFFSET_BLOCK, packet.GetSize() );
then keep the return as 0
Post Reply