Home   Help Search Login Register  

Author Topic: Limit Length of Times in Between Calling a Script.  (Read 1575 times)

0 Members and 1 Guest are viewing this topic.

Offline benxcore

  • Members
  • *
Limit Length of Times in Between Calling a Script.
« on: 23 Jun 2007, 04:13:33 »
Hey.
I've been reading, and no luck on this topic.
Is there a way I can make it so I can check the last time a script was called by a unit, and if it was say <20 Minutes ago, the script would return a "Negative." sound over sideradio, but if it was >20 Minutes it would allow the script to execute. Then. After that, you'd have to wait another 20 Minutes before succesfully calling in script, else you'd get the "Negative."


Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: Limit Length of Times in Between Calling a Script.
« Reply #1 on: 23 Jun 2007, 08:38:48 »
u cud use a simple variables stuff (deres brobably better way but still dis 1 will work :D)

when u execute da script make ur variable true (varname = true)... add time delay(~time) nd den set it back to false( varname = false)...

now make a simple condition if da variable is true (? varName : sidechat "negative") nd anoder condition (? ! varName : [] exec "scriptname.sqs")

dat shud do da workd  ;) :D

LCD OUT

"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline benxcore

  • Members
  • *
Re: Limit Length of Times in Between Calling a Script.
« Reply #2 on: 23 Jun 2007, 20:49:47 »
@LCD

So what your saying, in the part where I add "Add Action" to the unit to request a Task, i have the Variable set as true, the I would put a time delay, since I want 20 minutes, I'd put ~1200 in the same addaction.sqf then after that, I'd put the Variable set as "False" in the same script, or another script after it finishes the entire scripting process.

Does that sound correct?

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: Limit Length of Times in Between Calling a Script.
« Reply #3 on: 23 Jun 2007, 21:20:41 »
ur usin addaction ?

kk here is how it goes...

1) in da init.sqs set da variable 2 false
2) @ da start of da addaction script (script dats called by addaction) check if da vari is true... if it is say negative and exit
3) after da check set da variable 2 true (now if da player tries da action again it will refuse)
4) put ur delay (~1200)
5) set da variable 2 false and exit (now da player can use action again :D)

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline benxcore

  • Members
  • *
Re: Limit Length of Times in Between Calling a Script.
« Reply #4 on: 24 Jun 2007, 01:32:14 »
@LCD
Ok, I think I'm real close.
I must be making a stupid mistake, as soon as I set up, and launch for it to tell me no I get. However, It does tell me no.

Code: [Select]
if (fireagain=true)then
{
a1 sideradio "RadioMsg4";
exit
};

fireagain=true
~1200
Thats what I have right at the begging.
This is the error I recieve.

' |#|; '
Error Missing {

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Limit Length of Times in Between Calling a Script.
« Reply #5 on: 24 Jun 2007, 01:38:53 »
Code: [Select]
if (isNil lastcalltime) then
{
   lastcall = 0;
};

_currenttime = dayTime * 3600;
if ((_currenttime - lastcalltime) < (20*60)) exitWith {hint "NO WAY"};
lastcalltime = _currentime;

// REST OF YOUR CODE


Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Limit Length of Times in Between Calling a Script.
« Reply #6 on: 24 Jun 2007, 01:40:48 »
hmmm....Also .......maybe should be:

if (fireagain==true)then


Planck
I know a little about a lot, and a lot about a little.

Offline benxcore

  • Members
  • *
Re: Limit Length of Times in Between Calling a Script.
« Reply #7 on: 24 Jun 2007, 02:21:58 »
@Planck and Mandoble, I'm still recieving a similar error.
'exitWith |#| {a1 sideradio "RadioMsg4"};'
Error Missing ;


So, it must be something wrong with the rest of my code. Here it is with Mandoble's version (it looked pretty clean).

Code: [Select]
if (isNil lastcalltime) then
{
   lastcall = 0;
};

_currenttime = dayTime * 3600;
if ((_currenttime - lastcalltime) < (20*60))
exitWith {a1 sideradio "RadioMsg4"};

lastcalltime = _currentime;

a1 sideradio "RadioMsg2"
a1 sideradio "RadioMsg3"
setfire=true
~12
titletext ["Click on the map to set your firedirection","plain down"]
onMapSingleClick "ATarget setpos _pos;setfire=false"

@!setfire
[] exec "westari\ari.sqs"
"Firepoint" setmarkerpos getpos ATarget
fire=true
publicvariable "fire"
publicvariable "ATarget"
onMapSingleClick ""
titletext ["","plain down"]

exit

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Limit Length of Times in Between Calling a Script.
« Reply #8 on: 24 Jun 2007, 02:30:44 »
Yep, my code was SQF, I see yours is SQS

This should work
Code: [Select]
? isNil lastcalltime: lastcall = 0
_currenttime = dayTime * 3600
? ((_currenttime - lastcalltime) < (20*60)): a1 sideradio "RadioMsg4";exit
lastcalltime = _currentime

a1 sideradio "RadioMsg2"
a1 sideradio "RadioMsg3"
setfire=true
~12
titletext ["Click on the map to set your firedirection","plain down"]
onMapSingleClick "ATarget setpos _pos;setfire=false"

@!setfire
[] exec "westari\ari.sqs"
"Firepoint" setmarkerpos getpos ATarget
fire=true
publicvariable "fire"
publicvariable "ATarget"
onMapSingleClick ""
titletext ["","plain down"]

exit