Page 1 of 1

Destroying a single type of item

Posted: Mon May 28, 2012 10:30 pm
by gundamwing84
Hey guys, sorry for being a bother so soon :P

right now im doing some custom scripting for my housing system in game, and ive got a function that recognizes "i wish to place a trash barrel" and locks it down, and i want a function that recognizes the speech "i wish to destroy a trash barrel".

i created the script a couple days ago, and its compiles fine and what not. the problem is destroying the actual item, here is the script:

Code: Select all

function DestroyTrashBarrel(parms)
	var sign := parms[1];
	var owner := parms[2];
	var trashbarrel := 0x17057;


	var homeinfo := GetObjProperty (sign, "homeinfo");
	if (!homeinfo)
		return;
	endif
	
	
	if (IsInsidetheHouse(owner, sign));
		var targ := Target(owner);
		if (targ)
			if (targ.item == trashbarrel)
				SendSysMessage(owner, "passed the second if.", font := _DEFAULT_TEXT_FONT, color := MESSAGE_COLOR_MESSAGE);
				DestroyItem(item);
			else
				SendSysMessage(owner, "You can only destroy trash barrels...", font := _DEFAULT_TEXT_FONT, color := MESSAGE_COLOR_MESSAGE);
			endif
		elseif (!targ)
			SendSysMessage(owner, "Canceled.", font := _DEFAULT_TEXT_FONT, color := MESSAGE_COLOR_MESSAGE);
			return;
		endif
	elseif (!IsInsidetheHouse(owner, sign));
		SendSysMessage(owner, "You must be inside your home to use this command!", font := _DEFAULT_TEXT_FONT, color := MESSAGE_COLOR_MESSAGE);
		return;
	endif
endfunction
it needs to only be able to destroy a trash barrel (so they cant go on a rampage and destroy other items or destroy other items accidently) but the script will continue from "if (targ.item == trashbarrel)" even if i target the house sign. the second problem is it wont actually destroy the trash barrel :( other then that its working fine, does anyone have an idea as to why these errors are happening?

thanks in advance, mat :)

Re: Destroying a single type of item

Posted: Mon May 28, 2012 11:58 pm
by Tomi
if ( targ.objtype == trashbarrel )

Re: Destroying a single type of item

Posted: Tue May 29, 2012 1:30 am
by gundamwing84
:D thanks tomi that works wonders, now i just gotta get the damn thing to delete the trash barrel :(((

Re: Destroying a single type of item

Posted: Tue May 29, 2012 1:44 am
by gundamwing84
nvm everything is working fine :) thanks for the help tomi, much appreciated

Re: Destroying a single type of item

Posted: Tue May 29, 2012 4:44 am
by Yukiko
You could also have the "I wish to release this" command release it which would allow the player to move it or let it decay. That would simplify things a bit because you wouldn't need a separate command just for trash barrels.

Re: Destroying a single type of item

Posted: Tue May 29, 2012 10:23 pm
by gundamwing84
yeah they already have all the standard commands (i wish to lock this down/release, secure, etc), im using Agata's 99 WOD script package she released as a base for my shard :)

thanks though yukiko