Jump to content

Script not functioning correctly.


SmileyCat

Recommended Posts

I am creating a Enclave Commander for personal use because I want it my way :)

 

Now, when requesting more units through the hamradio, you can pick one unit, but when you press it, an loop of messages saying "Unit is sent now." until the 7 unit limit is reached, then it will loop "All Unit slots used."

 

Here is the code;

scn EnclaveSquadRadioScript

int Button
int countSoldiers

begin onActivate
showMessage EnclaveSquadCallTrooperMsg
end

begin GameMode
set Button to getButtonPressed
if button == 0
if countSoldiers < 7
Player.PlaceleveledActoratme enclavesquadenergyweaponsCANNON
showmessage enclavesquadsoldiercalled
set countSoldiers to (countSoldiers + 1)
else
showmessage enclavesquadsoldierenough
endif
elseif button == 1
if countSoldiers < 7
Player.PlaceleveledActoratme enclavesquadenergyweaponsHEAVY
showmessage enclavesquadsoldiercalled
set countSoldiers to (countSoldiers + 1)
else
showmessage enclavesquadsoldierenough
endif
elseif button == 2
if countSoldiers < 7
Player.PlaceleveledActoratme enclavesquadenergyweaponsSMALL
showmessage enclavesquadsoldiercalled
set countSoldiers to (countSoldiers + 1)
else
showmessage enclavesquadsoldierenough
endif
elseif button == 3
if countSoldiers < 7
Player.PlaceleveledActoratme enclavesquadenergyweaponsINCINERATOR
showmessage enclavesquadsoldiercalled
set countSoldiers to (countSoldiers + 1)
else
showmessage enclavesquadsoldierenough
endif
elseif button == 4
if countSoldiers < 7
Player.PlaceleveledActoratme enclavesquadenergyweaponsTeslaCANNON
showmessage enclavesquadsoldiercalled
set countSoldiers to (countSoldiers + 1)
else
showmessage enclavesquadsoldierenough
endif
elseif button == 5
if countSoldiers < 7
Player.PlaceleveledActoratme enclavesquadenergyweaponsTeslaHEAVY
showmessage enclavesquadsoldiercalled
set countSoldiers to (countSoldiers + 1)
else
showmessage enclavesquadsoldierenough
endif
elseif button == 6
if countSoldiers < 7
Player.PlaceleveledActoratme enclavesquadenergyweaponsTeslaSMALL
showmessage enclavesquadsoldiercalled
set countSoldiers to (countSoldiers + 1)
else
showmessage enclavesquadsoldierenough
endif
elseif button == 7
if countSoldiers < 7
Player.PlaceleveledActoratme enclavesquadenergyweaponsTeslaINCINERATOR
showmessage enclavesquadsoldiercalled
set countSoldiers to (countSoldiers + 1)
else
showmessage enclavesquadsoldierenough
endif
elseif button == 8
if countSoldiers < 7
Player.PlaceleveledActoratme enclavesquadspecializedstealthsniper
showmessage enclavesquadsoldiercalled
set countSoldiers to (countSoldiers + 1)
else
showmessage enclavesquadsoldierenough
endif
endif
end

 

I know, I dont do things so great with scripts.

 

Its probably something simple, anyway, HELP ME!

 

*EDIT* I removed the limit wich fixed the bug, but if you find a solution then you are MORE THAN WELCOME TO POST.

Link to comment
Share on other sites

It looks like you need a control variable of some kind to prevent the GameMode block from executing more than once.

 

Something like this:

scn EnclaveSquadRadioScript

int Button
int countSoldiers
int radioState

begin onActivate
showMessage EnclaveSquadCallTrooperMsg
set radioState to 1
end


BEGIN GameMode
If radioState != 1
 return
EndIf

...
(Put the rest of your stuff here)
...

 set radioState to 0
END

Link to comment
Share on other sites

  • Recently Browsing   0 members

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