Hello,
I'm trying to make script that shows messagebox with two options. If first is selected, it should open the container. I attach the script below. Problem is that when I go to the barrel in game and select I want to open it, the barrel opens for very short moment and closes again. I tried to remove the activate command, but then nothing happens at all. I also tried to add Messagebox right before the activate command to see if the code is executed really only once and it is. I would appreciate any help
Begin ariisiss_barrel
float timer
float swingTime
float swingSpeed
float startAngle
short button
short status
;float script part
set startAngle to GetStartingAngle, x
if ( MenuMode == 0 )
set swingTime to 1
;set swingSpeed to 30
set timer to ( timer + GetSecondsPassed )
;rotate up
if ( timer < swingTime )
Rotate x,2
;rotate down
elseif ( timer < (swingTime * 3) )
Rotate x, -2
;up again
elseif (timer < (swingTime * 4 ) )
Rotate x, 2
;reset timer to zero
else
set timer to 0
SetAngle X startAngle
endif
endif
;end of float script part
;barrel disabling and open script
if ( OnActivate == 1 )
if ( MenuMode == 1 )
return
endif
MessageBox "Do you want to open the barrel, or remove it?" , "Open", "Remove"
set status to 1
endif
If ( status == 1 ) ; button was pressed
set button to GetButtonPressed
if ( button == -1 ) ; if button not pressed do nothing
return
elseif ( button == 0 ) ; open the barrel
set status to 0
activate
elseif ( button == 1 ) ; remove the barrel
set status to 0
disable
setdelete 1
endif
endif
;end of barrel disabling and open script
End