Jump to content

Destroying a Static with Melee via Script


KDStudios

Recommended Posts

@TheTalkieToaster: You're right. Thank you. :)

 

New script. Counts up. Also MIGHT have fixed the reset time.

 

Change the 2 in "if ( iHealth == 2 )" to one number lower then what you actually want. 2 = 3 hits, 3 = 4 hits...

 

scn 0MCWoodHarvestScript

int iHealth
int iStage

float fTimer

Begin OnHitWith 0WeapAxeIron

if ( iHealth == 2 )
	Player.AddItem mcblockwood 1
	Disable
	MarkForDelete
else
	Set fTimer to 2
	Set iStage to 1
	Set iHealth to iHealth + 1
endif

End

Begin GameMode

if ( fTimer > 0 )
	Set fTimer to fTimer - GetSecondsPassed
elseif ( iStage == 1 )
	Set iStage to 0
	Set fTimer to 0
	Set iHealth to 0
endif

End

Link to comment
Share on other sites

  • Replies 49
  • Created
  • Last Reply

Top Posters In This Topic

Works like a charm!

The timer resets after it's left for a few seconds.

Decided to leave it at 3 hits per block.

 

Now I can start to add this to all the blocks, adjusting accordingly for different tools and blocks :)

 

You're the best! :)

Link to comment
Share on other sites

Well I was having trouble with my crafting bench

The schematic system was giving me grief.

So I've decided to scrap it all together :D (Well for the most part)

 

Can someone tell me why button 2 doesn't work. It just will not do anything even though 1, 3, 4 and 5 work fine.

Here's the script:

 

 


scn 0MCSCraftingBenchScript

short HasItems
short Button

short item1
short item2
short item3
short item4

float weaponCondition
int iHealth
int iStage

float fTimer

short button

Begin OnHit

       if ( iHealth == 2 )
               Player.AddItem 0MCBlockCraftingBench 1
               Disable
               MarkForDelete
       else
               Set fTimer to 2
               Set iStage to 1
               Set iHealth to iHealth + 1
       endif

End

Begin GameMode

       if ( fTimer > 0 )
               Set fTimer to fTimer - GetSecondsPassed
       elseif ( iStage == 1 )
               Set iStage to 0
               Set fTimer to 0
               Set iHealth to 0
       endif

End

Begin OnActivate
if IsActionRef player == 1
	set HasItems to 0

	if GetHasNote 0SchTNTMineNote == 1 			
		set HasItems to 1
	endif

	if HasItems == 1
		ShowMessage 0SchCraftingbenchMsg
	else
		ShowMessage 0SchCraftingbenchNoneMsg
	endif
endif

End

Begin GameMode

set Button to GetButtonPressed

if ( Button >0 )
	set weaponcondition to (player.getav Repair)/100

	if button == 1
		if ( player.GetItemCount LunchBox > 0 ) && ( player.GetItemCount CherryBomb > 0 ) && ( player.GetItemCount Caps001 >= 20 )
			ShowMessage 0SchCraftingbenchSuccessTNTBlockMsg
			player.RemoveItem LunchBox 1 1
			player.RemoveItem CherryBomb 1 1
			player.RemoveItem Caps001 20 1
			player.AddItemHealthPercent 0WeapMineTNTBlock 1 100
			PlaySound UIRepairWeapon
			endif

		endif
	elseif button == 2
		if ( player.GetItemCount 0MCStick > 1 ) && ( player.GetItemCount 0MCBarIron > 2 )
			ShowMessage 0SchCraftingbenchSuccessPickaxeMsg
			player.RemoveItem 0MCStick 2 1
			player.RemoveItem 0MCBarIron 3 1
			player.additemhealthpercent 0WeapPickaxeIron 1 100
			PlaySound UIRepairWeapon
			endif

		endif
	elseif button == 3
		if ( player.GetItemCount 0MCStick > 0 ) && ( player.GetItemCount 0MCBarIron > 1 )
			ShowMessage 0SchCraftingbenchSuccessAxeMsg
			player.RemoveItem 0MCStick 1 1
			player.RemoveItem 0MCBarIron 2 1
			player.additemhealthpercent 0weapAxeIron 1 100
			PlaySound UIRepairWeapon
			endif

		endif
	elseif button == 4
		if ( player.GetItemCount 0MCBlockWood > 0 )
			player.removeitem 0mcblockwood 1 1
			player.additem 0MCStick 4 1
			Playsound UIRepairWeapon
			endif

		endif
	elseif button == 5
		if ( player.GetItemCount 0MCStick > 0 ) && ( player.GetItemCount 0MCBarIron > 1 )
			ShowMessage 0SchCraftingbenchSuccessSwordMsg
			player.RemoveItem 0MCStick 1 1
			player.RemoveItem 0MCBarIron 2 1
			player.additemhealthpercent 0WeapSwordIron 1 100
			PlaySound UIRepairWeapon
			endif
		endif
	endif
endif
End

 

 

Link to comment
Share on other sites

Maybe this fixes it. You had declared Button twice, so I removed the second one. Also, you had too many "endif" inside each Button if statements.

 

 

scn 0MCSCraftingBenchScript

short HasItems
short Button

short item1
short item2
short item3
short item4

float weaponCondition
int iHealth
int iStage

float fTimer

Begin OnHit

if ( iHealth == 2 )
	Player.AddItem 0MCBlockCraftingBench 1
	Disable
	MarkForDelete
else
	Set fTimer to 2
	Set iStage to 1
	Set iHealth to iHealth + 1
endif

End

Begin GameMode

if ( fTimer > 0 )
	Set fTimer to fTimer - GetSecondsPassed
elseif ( iStage == 1 )
	Set iStage to 0
	Set fTimer to 0
	Set iHealth to 0
endif

End

Begin OnActivate
if IsActionRef player == 1
	set HasItems to 0

	if GetHasNote 0SchTNTMineNote == 1
		set HasItems to 1
	endif

	if HasItems == 1
		ShowMessage 0SchCraftingbenchMsg
	else
		ShowMessage 0SchCraftingbenchNoneMsg
	endif
endif

End

Begin GameMode

set Button to GetButtonPressed

if ( Button >0 )
	set weaponcondition to (player.getav Repair)/100

	if button == 1
		if ( player.GetItemCount LunchBox > 0 ) && ( player.GetItemCount CherryBomb > 0 ) && ( player.GetItemCount Caps001 >= 20 )
			ShowMessage 0SchCraftingbenchSuccessTNTBlockMsg
			player.RemoveItem LunchBox 1 1
			player.RemoveItem CherryBomb 1 1
			player.RemoveItem Caps001 20 1
			player.AddItemHealthPercent 0WeapMineTNTBlock 1 100
			PlaySound UIRepairWeapon
		endif
	elseif button == 2
		if ( player.GetItemCount 0MCStick > 1 ) && ( player.GetItemCount 0MCBarIron > 2 )
			ShowMessage 0SchCraftingbenchSuccessPickaxeMsg
			player.RemoveItem 0MCStick 2 1
			player.RemoveItem 0MCBarIron 3 1
			player.additemhealthpercent 0WeapPickaxeIron 1 100
			PlaySound UIRepairWeapon
		endif
	elseif button == 3
		if ( player.GetItemCount 0MCStick > 0 ) && ( player.GetItemCount 0MCBarIron > 1 )
			ShowMessage 0SchCraftingbenchSuccessAxeMsg
			player.RemoveItem 0MCStick 1 1
			player.RemoveItem 0MCBarIron 2 1
			player.additemhealthpercent 0weapAxeIron 1 100
			PlaySound UIRepairWeapon
		endif
	elseif button == 4
		if ( player.GetItemCount 0MCBlockWood > 0 )
			player.removeitem 0mcblockwood 1 1
			player.additem 0MCStick 4 1
			Playsound UIRepairWeapon
		endif
	elseif button == 5
		if ( player.GetItemCount 0MCStick > 0 ) && ( player.GetItemCount 0MCBarIron > 1 )
			ShowMessage 0SchCraftingbenchSuccessSwordMsg
			player.RemoveItem 0MCStick 1 1
			player.RemoveItem 0MCBarIron 2 1
			player.additemhealthpercent 0WeapSwordIron 1 100
			PlaySound UIRepairWeapon
		endif
	endif
endif
End

 

Edited by Alexx378
Link to comment
Share on other sites

I just tried it out and...

 

Well aint you turning out to be the best thing to come across my sorry scripting :P

It works like a charm!

 

It must have been my endless spam of "endif's" haha. http://www.thenexusforums.com/public/style_emoticons/dark/wallbash.gif

I think I'm getting there slowly with scripting though :)

 

Thankyou so damn much o_O! http://www.thenexusforums.com/public/style_emoticons/dark/woot.gif

Link to comment
Share on other sites

  • 2 weeks later...

Hey I kinda have a new problem.

 

I hit a brick wall when adding more buttons to the Crafting Bench menu.

Turns out the maximum amount of buttons we can have is 9.

So I figured I'd make button number 9 a "More" Button.

Problem is I don't know how to turn it into a "More".

 

So what I've done so far is turn Button 9 into a button called "More"

Then in the crafting script I added this simple line

 

 

elseif button == 9

ShowMessage 0SchCraftingbenchMsg2

 

Now the button works perfectly and shows the new menu to the crafting bench.

Then I figured out that obviously it won't run the script that the menu is based on and assumes that menu is for the script I am using for the first message.

What do I have to write to make it independent?

 

Would I need to make a new activator and instead of having it as ShowMessage 0SchCraftingbenchMsg2 and have it something like Activate CraftingbenchMC2 (Completely wrong I know but that's the 2nd idea I have to do it)

 

So yeah. Suggestions/advice if possible anyone?

 

Thanks again.

Link to comment
Share on other sites

Actually I took a look at that just then and that might work!

Kudos to you for the reply and I'll be sure to get back with the outcome, but by the looks of it. It's simple enough to implement and you may have saved my backside :D

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...