Jump to content

Need help working with Message Boxes


Shadyfan4500

Recommended Posts

I'm attempting to add a message box that pops up at the start and asks the player a yes or no question, and getting their response from that. The message pops up fine, but the vanilla function I'm using is always returning -1

int showOnce = 0 ;Used to show message only once

int playerIsSniper ;1 = yes (Sniper spawns in Chet's vendor inventory)

Begin GameMode
if showOnce == 0
    showmessage MSGSilentSniper
    set playerIsSniper to GetButtonPressed    

    ;Sniper is initially disabled, this turns it on
    if playerIsSniper == -1
        SilentSniperRef.enable
        SilentSniperModRef.enable
        SilentSniperMod2Ref.enable
        SilentSniperNoteRef.enable
        showmessage BigSalDead ;debugging line
    endif

    set showOnce to 1
endif
End

 

It's supposed to check if playerIsSniper == 1, but GetButtonPressed only returns -1, which according to the wiki means that something's going wrong with the indices of the Message I guess.. No is index 0, and yes is index 1, and there are no conditions preventing them from showing up.

 

I also tried JIP NVSE's MessageBoxExAlt function, but I can't get the GECK Compiler to Compile the example script's block "Begin Function { iButton }". That's not the way I want to go if I don't have to anyways.

 

Any help would be appreciated

Link to comment
Share on other sites

I guessing and have not tested it but I think the problem is that "set ShowOnce to 1" is outside of the "if PlayerIsSniper" block and so the script only runs once. PlayerIsSniper will equal -1 unless the player presses the button very quickly. Put "set ShowOnce to 1" where the debug line is should fix. I think you should also make ShowOnce its own thing so the message doesnt keep on displaying. How do you the code layout in forums?

 

int ShowOnce

 

int PlayerIsSniper

 

int MessageMenu

 

Begin GameMode

 

if ShowOnce == 0

ShowMessage MSGSilentSniper

Set MessageMenu to 1

Set ShowOnce to 1

endif

 

if MessageMenu == 1

Set playerIsSniper to GetButtonPressed

if PlayerIsSniper == 0

Set MessageMenu to 0

 

elseif PlayerIsSniper == 1

SilentSniperRef.enable
SilentSniperModRef.enable
SilentSniperMod2Ref.enable
SilentSniperNoteRef.enable

Set MessageMenu to 0

endif

endif

 

END

Edited by lc1000
Link to comment
Share on other sites

  • Recently Browsing   0 members

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