Jump to content
  • 0

forcespeed {variable} question


Just_R

Question

If I define a variable:  Speed = 150; PublicVariable Speed; (in one script)

then in another script define:

forcespeed Speed;  

 

What is the valid format (if it can be done) and how would everyone that logins in would get this set value of "Speed".  I.E. you have a static plane flying at variable speeds. I am just using "Speed" defined at the value of "150" only for this discussion for simplicity. I know if the value changes on "Speed" I would have to re-define the PublicVariable again so it's republish (floating about) with the new value? Lastly would infiSTAR have an issue with a custom PublicVariable?

 

Any help would be greatly appreciated.  Thanks.

Edited by Just_R
my dog at the first digital version
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

why would you want to use public variable?
speed is a command, thus can't be used as var, but it is used to detect speed of an object, which can be used. You could limit speed using logic classes in config hierarchy.

//limit speed on all airplanes or helis
_speedLimit = 50;
if (vehicle player isKindOf "AIR") then {
    vehicle player forceSpeed _speedLimit;
};

Personally I'd make a small monitor inside a while loop that slowly detects what vehicle is used and adjust speed accordingly. Something along lines of:
 

_typeTemp = "";
while {true} do {
    
    sleep 5;
    _veh = vehicle player;
    _type = typeOf _veh;
    
    if (_type != _typeTemp) then {
        _speedLimit = if (_veh isKindOf "AIR") then {150} else {-1};
        _veh forcespeed _speedLimit;
        _typeTemp = _type;
    };
};

 

Link to comment
Share on other sites

  • 0

Raymix,  Thank you for the fast reply. I am not specifically using "Speed" I just used it as an example (without knowing it was already a predefined variable). 

this is the part I was more interested in

forceSpeed _speedLimit;

I wanted to be sure you could assign a variable after "forceSpeed".  using your example, could I set change _speedLimit to speedLimit and have it a publicVariable that could be picked up from another SQF or FSM being called? therefore taking speedLimit (public variable) passing it to SQF or FSM where in has "forceSpeed speedlimit;" defined.  

Example:

having a "check server time" if..then in a test.sqf called from the init.sqf, once the set time of day on the server is reached then the variable speedlimit=150; would be applied. I would  call to a FSM file that has this specific line of code " _veh forcespeed speedLimit;".  The FSM would reside in dayz_code under \system\ (if it can) OR do I need to have the FSM being called from the root mission directory in a custom\compile folder for the FSM call?

I do have a:

while {true} do {

running in the test.sqf that is called from the init.sqf.   so it runs until reboot while checking current server time and when a specific time is reached.... do this... and then at another specific time.... do this.....  this is why I asked if a make it a publicVariable can it be passed from one SQF or FSM to another.

спасибо.
Edited by Just_R
Link to comment
Share on other sites

  • 0

the proper term would be global variable (most common), but people call them in many names.

_localVariable = 0; //local vars has underscore in front 
globalVariable = 1; //global vars has no underscore

publicVariable "globalVariable"; //public variable is used to send global variable on network

This is very simplified tho, just to answer your question. Local variables used in script only, global variables everywhere and public variables on network, yadda yadda yadda... yes.
In reality local vars can be used externally and there are different namespaces where global variables reside as well as different types of public vars, but yeh... don't worry about that, answer to your question is still yes.

If you want to use FSM, i'd strongly suggest learning SQF first, otherwise you'll have a hard time getting around it, SQF is actually easier to work with, especially with something like this.... unless you are going condition heavy on the logic... like AI. 
Anyway, I have an FSM tutorial on youtube if you still insist on using it, just search for it, it's the only arma FSM tutorial out there for some reason, lol.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Discord

×
×
  • Create New...