Jump to content

Need help with a script


SGTbayk47

Recommended Posts

Hi guys,

 

I've just finished writing a script for a jar of caps, which when activated will give the player a random amount of caps as well as a predetermined amount. The script also deletes the activator, and places a static empty jar afterwards. Now, I'm no scripting genius but I thought what I wrote would have worked. My guess is that you maybe can't use 'Placeatme' on static objects? (The static object in this case is 'JarEmpty')

 

Anyway, what I'm asking is does anybody know why this script won't let me save?

 

Thanks, BayK.

 

Script:

SCN JarCapsActivatorScript

Short DoOnce
Short Button
Short RandomCaps
Ref Self

Begin OnActivate Player

If DoOnce == 0
   ShowMessage JarCapsActivatorMessage
Endif

End

Begin MenuMode 1001

Set Button to GetButtonPressed
Set Self to GetSelf

If Button == 0
   Set Self to GetSelf
   Set RandomCaps to GetRandomPercent
   If GetRandomPercent >= 0 && GetRandomPercent < 25
      Player.Additem Caps001 (75 + RandomCaps) 1
   Elseif GetRandomPercent >= 25 && GetRandomPercent < 50
      Player.Additem Caps001 (100 + RandomCaps) 1
   Elseif GetRandomPercent >= 50 && GetRandomPercent < 75
      Player.Additem Caps001 (125 + RandomCaps) 1
   Else GetRandomPercent >= 75 && GetRandomPercent < 100
      Player.Additem Caps001 (150 + RandomCaps) 1
   Endif
   Set DoOnce to 1
   GetSelf.PlaceAtMe JarEmpty 1
   GetSelf.Disable
   GetSelf.MarkForDelete
Elseif Button == 1
   ;Do Nothing
Endif

End
Link to comment
Share on other sites

Player.Additem Caps001 (75 + RandomCaps) 1

You cannot normally pass arguments as parameters when calling a function, only explicit values or variable names. (75 + RandomCaps) is an argument, and is therefore invalid in this context.

GetSelf.PlaceAtMe JarEmpty 1
GetSelf.Disable
GetSelf.MarkForDelete

GetSelf is a function. You cannot use a function as the calling object of another function.

 

 

Try this fixed script:

scn	JarCapsActivatorScript

short	DoOnce
short	Button
short	RandomCaps

begin OnActivate

	if IsActionRef playerRef
		set DoOnce to 1
		ShowMessage JarCapsActivatorMessage
	endif

end

begin MenuMode 1001

	if DoOnce
		set Button to GetButtonPressed
		if Button == 0
			set DoOnce to 0
			set RandomCaps to GetRandomPercent
			if RandomCaps < 25
				set RandomCaps to 75 + RandomCaps
			elseif RandomCaps < 50
				set RandomCaps to 100 + RandomCaps
			elseif RandomCaps < 75
				set RandomCaps to 125 + RandomCaps
			else
				set RandomCaps to 150 + RandomCaps
			endif
			player.Additem Caps001 RandomCaps 1
			PlaceAtMe JarEmpty 1
			Disable
			MarkForDelete
		endif
	endif

end
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...