Jump to content

Script Help


stealthtank91

Recommended Posts

begin gamemode
       if aaaSTCell4fRlSwch1Ref.aaaSTBunkerCityCell4fRelayShrt1 && aaaSTCell4fRlSwch2Ref.aaaSTBunkerCityCell4fRelayShrt2 && aaaSTCell4fRlSwch3Ref.aaaSTBunkerCityCell4fRelayShrt3 && aaaSTCell4fRlSwch4Ref.aaaSTBunkerCityCell4fRelayShrt4 && aaaSTCell4fRlSwch5Ref.aaaSTBunkerCityCell4fRelayShrt5
               PlaySound3D OBJBuzzerBell ; see the note at the bottom about this line
       endif
end

 

well the buzzer ringing the whole time would make sense since, the gamemode block runs continuosly, unless like you said - you made an extra line of code

 

im still confused about the script portion above^

 

i dont understand the logic - what does ref.variable do in this condition? does it get a value from somewhere and return it because its like

 

if ref.variable

playsound (sound)

endif

 

but what does this mean logically? i want to know what im writing and understand it, so i can use it in future, rather than blindly copy pasting someones code without knowing whats what.

Link to comment
Share on other sites

your script didnt fire because as i stated you are calling variables in a local script and you need to be calling variables as per reference.

 

i did this for you.

 

the sound issue..

use enable and disable if you want control over how long the buzzer goes, and as suggested a timer if you want it to play for a certain amount of time.

so if you want the player to control when its on and off through whether or not all switches are on this is really simple:

 

use this instead after adding the sound AS A REFERENCE IN THE WORLD where you want it to play from (will automatically play 3d from wherever you put it)

 

if aaaSTCell4fRlSwch1Ref.aaaSTBunkerCityCell4fRelayShrt1 &&  aaSTCell4fRlSwch2Ref.aaaSTBunkerCityCell4fRelayShrt2 && aaaSTCell4fRlSwch3Ref.aaaSTBunkerCityCell4fRelayShrt3 && aaaSTCell4fRlSwch4Ref.aaaSTBunkerCityCell4fRelayShrt4 && aaaSTCell4fRlSwch5Ref.aaaSTBunkerCityCell4fRelayShrt5
OBJBuzzerBellREF.enable
else
OBJBuzzerBellREF.disable
endif

 

btw see the reference name in front of the variables??? thats why your isnt working. you have to call the variable from the reference your pointing to because separate scripts have separate variables!!!!

Edited by angelwraith
Link to comment
Share on other sites

begin gamemode
       if aaaSTCell4fRlSwch1Ref.aaaSTBunkerCityCell4fRelayShrt1 && aaaSTCell4fRlSwch2Ref.aaaSTBunkerCityCell4fRelayShrt2 && aaaSTCell4fRlSwch3Ref.aaaSTBunkerCityCell4fRelayShrt3 && aaaSTCell4fRlSwch4Ref.aaaSTBunkerCityCell4fRelayShrt4 && aaaSTCell4fRlSwch5Ref.aaaSTBunkerCityCell4fRelayShrt5
               PlaySound3D OBJBuzzerBell ; see the note at the bottom about this line
       endif
end

 

well the buzzer ringing the whole time would make sense since, the gamemode block runs continuosly, unless like you said - you made an extra line of code

 

im still confused about the script portion above^

 

i dont understand the logic - what does ref.variable do in this condition? does it get a value from somewhere and return it because its like

 

if ref.variable

playsound (sound)

endif

 

but what does this mean logically? i want to know what im writing and understand it, so i can use it in future, rather than blindly copy pasting someones code without knowing whats what.

 

 

 

ref.variable:

 

this is what ive been trying to describe to you!!

 

you MUST have the ref before the variable otherwise it will access the variable from THAT REFERENCE rather than the variable in the script attached to the reference being activated. if it were all run from 1 script this wouldnt be an issue but because were using 5 scripts this is the way its gotta be done.

 

its like someone asking you what my favorite color is ... wouldnt know would you? now if they asked the question to me, the person it pertains to i would probabbly be able to answer the question.

 

now heres the fun part..you should def know this. by having this script attached to all 5 references and each RUNNUNG ITS SCRIPT INDEPENDANTLY that means that when the condition is satisified the functions are actually running 5 times because each script will fire independently.

 

now if your using enable and disable as i suggested.. this doesnt matter because you cant enable something thats already enabled or disable something thats diabled..

 

however if you start to add new functions to the gamemode block keep in mind that it will run 5 times.

 

 

there is a better way to do all this.. but im trying not to confuse you any more...

when you get this working and understand what is going on ill help you fix it all the way if you like so that you dont have to worry about referencing the variables in external scripts or have to worry about things running 5 times.. and youll need just one script to do it all. (the switches involved wouldnt actually need ANY SCRIPT AT ALL.

 

 

 

ALSO lose the setopenstate stuff if you want to hear the switch, and like i showed you add the 'ACTIVATE' at the end of the onactivate block. this will make it do everything its supposed to do normally.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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