Deleted11438360User Posted May 20, 2016 Share Posted May 20, 2016 (edited) ElseIf (aiButton == 4) aiButton = AR_MsgMenu.Show() If (aiButton == 0) ;Cancel ElseIf (aiButton == 1 || aiButton == 2 If (!noPermission) AR_MsgNoPerms.Show() Else int iActors = Actors.Length ReferenceAlias rActors = None If (iActors <= 0) ARMsgNoActors.Show() Else While (iActors > 0) iActors -= 1 rActors = Actors[iActors] If (aiButton == 1) rActors.GetActorRef().Resurrect() Else rActors.GetActorRef().Kill() EndIf EndWhile AR_MsItIsDone.Show() EndIf Endif EndIfNow I want to say if the player presses a button they have already pressed, show a message that they have already pressed it. Now I could add a bool under the buttons and then say (aiButton == 1 && myBool || aiButton = 2 && !myBool) but that is rather messy and lengthy. I also don't want to put the messages in the While for performance reasons, which is why my AR_MsItIsDone is outside the While. So is there any simpler and less messy way to do this? I honestly can't think straight at the moment. Thank you awesome people. P.S If you are reading this Contrathetix, I didn't want to bug you AGAIN! You have studies! Edited May 20, 2016 by Guest Link to comment Share on other sites More sharing options...
NorthHare Posted May 20, 2016 Share Posted May 20, 2016 I can't really see what you're trying to do from that snippet (and I haven't slept), so apologies if this is no help. Could you use a bool array to check whether a button has been pressed? e.g. PressedArray[0] is button 0, etc. If PressedArray[aiButton] ; The returned button has already been pressed. EndIf Link to comment Share on other sites More sharing options...
Deleted11438360User Posted May 20, 2016 Author Share Posted May 20, 2016 (edited) I'm not sure because I'm pretty new at this. Well, I have that button inside another button, so when that button is pressed, it shows AR_MsgMenu as you can probably see. Then if the player has permission, it goes through the array of buttons which is linked to ReferenceAlias actors; it then kills or resurrects them based on choice. I can't uses IsDead or anything outside of the array. Edit: If anyone reads this and can give examples of how to properly implement this, that would be fantastic. So in a perfect world, I'd want to get if a button has already been pressed in the array, then a would message to display (out of the array) in a non-cluttered manner. That is all I'm saying. So: If the player has pressed button 1 again after pressing button 1, it would say they have already done that. Then if they press button 2 after pressing button 1, things happen. If they pressed button 2 after pressing button 2, it would say they already did it ect. Edited May 20, 2016 by Guest Link to comment Share on other sites More sharing options...
IsharaMeradin Posted May 20, 2016 Share Posted May 20, 2016 Here is a possibility. Setup an int var that you will pass the currently pressed button into. Then compare that with the next button pressed. If the same then prevent the processing. Here is an example with the snippet you posted... no idea how it would work in the grander scheme since you are using the same var name for the message buttons across different menus. Int LastButton = 0 ElseIf (aiButton == 4) aiButton = AR_MsgMenu.Show() If (aiButton == 0) ;Cancel ElseIf (LastButton == aiButton) ;already did this option ElseIf (aiButton == 1 || aiButton == 2) If (!noPermission) AR_MsgNoPerms.Show() Else int iActors = Actors.Length ReferenceAlias rActors = None If (iActors <= 0) ARMsgNoActors.Show() Else While (iActors > 0) iActors -= 1 rActors = Actors[iActors] If (aiButton == 1) rActors.GetActorRef().Resurrect() Else rActors.GetActorRef().Kill() EndIf EndWhile AR_MsItIsDone.Show() EndIf Endif EndIf LastButton = aiButton EndIf Link to comment Share on other sites More sharing options...
Deleted11438360User Posted May 20, 2016 Author Share Posted May 20, 2016 (edited) Thank you. I tried it but it says: mismatched input 'ElseIf' expecting ENDFUNCTIONEdit: Solved that, there were too many EndIfs there. I'll check it out! Edit 2: Actually should have noticed this wouldn't work, because you exit the menu after each button press, so it resets the aiButton. Any way around this? Edited May 20, 2016 by Guest Link to comment Share on other sites More sharing options...
IsharaMeradin Posted May 20, 2016 Share Posted May 20, 2016 Since you didn't post the entire script.... no idea of knowing. But if you put the declaration of the LastButton variable in the empty state with the properties it should remain set with the value of the last button used despite aiButton being reset with each menu use. Otherwise, use the bool method you mentioned. Not sure how that would be considered any more lengthy or messy than any other method. Link to comment Share on other sites More sharing options...
Deleted11438360User Posted May 20, 2016 Author Share Posted May 20, 2016 (edited) It's exactly as you told me, bar the extra Endif and the Int dropped down a level. If I didn't do the latter it errors. Edit: Silly me. Your EndIf out of nowhere right at the bottom threw me off. I have had the day off today due to feeling a bit exhausted, so my apologies for me not grasping basic things. I understand perfectly now, thank you. Edited May 20, 2016 by Guest Link to comment Share on other sites More sharing options...
NexusComa Posted May 21, 2016 Share Posted May 21, 2016 man you keep beating me to theses IsharaMeradinnice script Link to comment Share on other sites More sharing options...
Recommended Posts