Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

THE ERROR


Hayk94
 Share

Recommended Posts

here is the script

scn aaSackSCRIPT


float money

float addmoney

float removemoney

short button

short actdep

short actwith

short actshow

short firstuse


Begin OnActivate

If firstuse == 0

 messagebox "Choose Action", "Deposit money", "Withdraw money", "Show deposited money"

  set button to GetButtonPressed

  if button == 1

   set actdep to 1

   set firstuse to 1

  elseif button == 2

   set actwith to 1

   set firstuse to 1

  elseif button == 3

   set firstuse to 1

   set actshow to 1

    endif

  endif

end


Begin Gamemode

If actdep == 1

 messagebox "How much do you want to deposit?", "500", "1000", "10000"

  set button to GetButtonPressed

   if button == 1

    set money to money + 500

    player.removeitem Gold001 500

    set actdep to 0

   elseif button == 2

    set money to money + 1000

    player.removeitem Gold001 1000

    set actdep to 0

   elseif button == 3

    set money to money + 10000

    player.removeitem Gold001 10000

    set actdep to 0

   endif

endif

elseif actwith == 1 (this is line 47)

 messagebox "How much do you want to withdraw?", "500", "1000", "10000"

  set button to GetButtonPressed

   if button == 1

    set money to money - 500

    player.additem Gold001 500

    set actwith to 0 

   elseif button == 2

    set money to money - 1000

    player.additem Gold001 1000

    set actwith to 0 

   elseif button == 3

    set money to money - 10000

    player.additem Gold001 10000

    set actwith to 0

    endif

  endif

 endif

endif

elseif actshow == 1

 messagebox "You have deposited %"money" septims"

   endif

 endif

End

  

It says Invalid Begin\End structure on line 47... I marked line 47

Link to comment
Share on other sites

On line 47 your using elseif without it being preceeded by an If statement.

Also, with messagebox buttons they start with 0.

So the one for Deposit should be 0, Withdraw should be 1 and Show should be 2

Also, you need to keep that section of the script looping until the player DOES press a button.

I suggest reading this tutorial

http://cs.elderscrolls.com/constwiki/index.php/Scripting_Tutorial:_My_Second_Script

you will be particularly interested in the bits explaining what this snippet of code is for:


    Set button to GetButtonPressed

    If ( button == -1 )

      Return

Link to comment
Share on other sites

On line 47 your using elseif without it being preceeded by an If statement.

Well is this supposed to be correct

scn aaSackSCRIPT


float money

float addmoney

float removemoney

short button

short actdep

short actwith

short actshow

short firstuse


Begin OnActivate

If firstuse == 0

 messagebox "Choose Action", "Deposit money", "Withdraw money", "Show deposited money"

  set button to GetButtonPressed

  if button == 1

   set actdep to 1

   set firstuse to 1

  elseif button == 2

   set actwith to 1

   set firstuse to 1

  elseif button == 3

   set firstuse to 1

   set actshow to 1

    endif

  endif

end


Begin Gamemode

If actdep == 1

 messagebox "How much do you want to deposit?", "500", "1000", "10000"

  set button to GetButtonPressed

   if button == 1

    set money to money + 500

    player.removeitem Gold001 500

    set actdep to 0

   elseif button == 2

    set money to money + 1000

    player.removeitem Gold001 1000

    set actdep to 0

   elseif button == 3

    set money to money + 10000

    player.removeitem Gold001 10000

    set actdep to 0

   endif

endif

if actwith == 1

 messagebox "How much do you want to withdraw?", "500", "1000", "10000"

  set button to GetButtonPressed

   if button == 1

    set money to money - 500

    player.additem Gold001 500

    set actwith to 0 

   elseif button == 2

    set money to money - 1000

    player.additem Gold001 1000

    set actwith to 0 

   elseif button == 3

    set money to money - 10000

    player.additem Gold001 10000

    set actwith to 0

    endif

 endif

if actshow == 1

 messagebox "You have deposited %"money" septims"

   endif

End

  

Link to comment
Share on other sites

Its giving you that error because you started an if condition with an elseif. You must have an if before you can follow it with elseifs. Also, you have way too many endifs, you only need one endif per if condition. This is how it should be:


if actwith == 1 (this is line 47)

 messagebox "How much do you want to withdraw?", "500", "1000", "10000"

  set button to GetButtonPressed

   if button == 0

    set money to money - 500

    player.additem Gold001 500

    set actwith to 0 

   elseif button == 1

    set money to money - 1000

    player.additem Gold001 1000

    set actwith to 0 

   elseif button == 2

    set money to money - 10000

    player.additem Gold001 10000

    set actwith to 0

   endif

endif

if actshow == 1

 messagebox "You have deposited %"money" septims"

endif

End

  

Edit: yes that looks right. Except you need to start with if button == 0 not if button == 1

See Joben's post

Link to comment
Share on other sites

Its giving you that error because you started an if condition with an elseif. You must have an if before you can follow it with elseifs. Also, you have way too many endifs, you only need one endif per if condition. This is how it should be:


if actwith == 1 (this is line 47)

 messagebox "How much do you want to withdraw?", "500", "1000", "10000"

  set button to GetButtonPressed

   if button == 0

    set money to money - 500

    player.additem Gold001 500

    set actwith to 0 

   elseif button == 1

    set money to money - 1000

    player.additem Gold001 1000

    set actwith to 0 

   elseif button == 2

    set money to money - 10000

    player.additem Gold001 10000

    set actwith to 0

   endif

endif

if actshow == 1

 messagebox "You have deposited %"money" septims"

endif

End

  

Edit: yes that looks right. Except you need to start with if button == 0 not if button == 1

Shall I use 0 everywhere in my script or only in that part???

Link to comment
Share on other sites

Shall I use 0 everywhere in my script or only in that part???

Anywhere you use getButtonPressed. The first button in a message box is returned as button 0 with getButtonPressed. All the following buttons go up one (second button = 1, third button = 2, etc.), its like the index for arrays. The first is always 0. So use it all throughout your script.

Link to comment
Share on other sites

I can already see a design flaw :D

There is no checking if you have the given amount of money, so you can just "deposit" thousands then withdraw it all.

Or, even worse is theres nothing to stop the "money" value from going negative, so you could just withdraw off the bat.

Link to comment
Share on other sites

I looked at it more closely and fixed a few things. This should work right:

scn aaSackSCRIPT


float money

short button

short firstuse

short choosing


Begin OnActivate

 If firstuse == 0

  set choosing to -1

  set firstuse to 1

 endif

end


Begin Gamemode 

 if choosing == -1

  messagebox "Choose Action", "Deposit money", "Withdraw money", "Show deposited money"

  set choosing to 1

 elseif choosing == 1

  set button to GetButtonPressed

  if button == 0

   set choosing to -10

  elseif button == 1

   set choosing to -11

  elseif button == 2

   set choosing to -12

  endif

 elseif choosing == -10

  messagebox "How much do you want to deposit?", "500", "1000", "10000"

  set choosing to 10

 elseif choosing == 10

   set button to GetButtonPressed

   if button == 0

    if player.getGold >= 500

     set money to money + 500

     player.removeitem Gold001 500

    else

     message "You do not have enough money."

    endif

    set choosing to 0

   elseif button == 1

    if player.getGold >= 1000

     set money to money + 1000

     player.removeitem Gold001 1000

    else

     message "You do not have enough money."

    endif

    set choosing to 0

   elseif button == 2

    if player.getGold >= 10000

     set money to money + 10000

     player.removeitem Gold001 10000

    else

     message "You do not have enough money."

    endif

    set choosing to 0

   endif

 elseif choosing == -11

  messagebox "How much do you want to withdraw?", "500", "1000", "10000"

  set choosing to 11

 elseif choosing == 11

   set button to GetButtonPressed

   if button == 0

    if money >= 500

     set money to money - 500

     player.additem Gold001 500

    else

     message "Not enough money in account."

    endif

    set choosing to 0 

   elseif button == 1

    if money >= 1000

     set money to money - 1000

     player.additem Gold001 1000

    else

     message "Not enough money in account."

    endif

    set choosing to 0 

   elseif button == 2

    if money >= 10000

     set money to money - 10000

     player.additem Gold001 10000

    else

     message "Not enough money in account."

    endif

    set choosing to 0

    endif

 elseif choosing == -12

  messagebox "You have deposited %.0f septims" money

 endif

End

  

Note: You had the "firstuse" variable in your original script make it so the player can only access the messageboxes only once. I kept it working like that, but did you intend it to do that?

Link to comment
Share on other sites

Yes I did...THANX AGAIN...I was going to do all this...The script I posted first was just a skeleton for testing....BUT HOWEVER THANK YA VERY MUCH THERE WERE SOME PARTS THAT I WASN'T ABLE TO DO, YET...BUT NOW I UNDERSTOOD EVERYTHING THANK TO EVERYONE AND ESPECIALLY TO YOU CRITTERMAN!!!!!!!!!! But one thing still remains not understood... This part

messagebox "You have deposited %.0f septims" money

%.0f What does this mean? I just never used such a thing, before. Does It mean that here must be the variable I want to be shown which must also be certainly written in the line end??????? PLEASE EXPLAIN ME IT !!!!!!!!!!!!!!!!!!!!!!!!!!! PLEASEEE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Link to comment
Share on other sites

:D Smarty Says: The first rule of scripting is to USE THE WIKI.

MessageBox

You also should put your 'messageBox' in the activate code instead of the gamemode code. All code that only needs to be executed once can go in the OnActivate block.

For example:

Begin OnActivate
If firstuse == 0
set choosing to 1
set firstuse to 1
messagebox "Choose Action", "Deposit money", "Withdraw money", "Show deposited money"
endif
end

Begin Gamemode
if choosing == 1
set button to GetButtonPressed
if button == 0
set choosing to -10[/code]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...