Destroying a single type of item

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.

Moderator: POL Developer

Post Reply
gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

Destroying a single type of item

Post 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 :)
Tomi
POL Developer
Posts: 478
Joined: Tue Feb 21, 2006 5:08 pm

Re: Destroying a single type of item

Post by Tomi »

if ( targ.objtype == trashbarrel )
gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

Re: Destroying a single type of item

Post by gundamwing84 »

:D thanks tomi that works wonders, now i just gotta get the damn thing to delete the trash barrel :(((
gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

Re: Destroying a single type of item

Post by gundamwing84 »

nvm everything is working fine :) thanks for the help tomi, much appreciated
Yukiko
Distro Developer
Posts: 2825
Joined: Thu Feb 02, 2006 1:41 pm

Re: Destroying a single type of item

Post 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.
gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

Re: Destroying a single type of item

Post 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
Post Reply