Sandbird Posted February 25, 2014 Report Share Posted February 25, 2014 I need to set a global variable in a unit on the server. How can i check that variable after on the client side ? Its for a bot i want to have a 'dialog' with. I need to access the 'name' of the bot. On my server i got: _sideGroup = createGroup WEST; _unit_4 = objNull; if (true) then { _this = _sideGroup createUnit ["Graves_Light_DZ", [5101.4746, 2550.7922, 0.36117637], [], 0, "CAN_COLLIDE"]; _unit_4 = _this; _this setDir -29.416721; _this setVehicleVarName "botunit"; botunit= _this; _this setUnitAbility 0.60000002; if (true) then {_sideGroup selectLeader _this;}; _this addEventHandler ["HandleDamage", {false}]; _this allowDammage true; }; and on the client side i want to do this: if ((!isNull cursorTarget) && (player distance botunit<= 5)) then { ..... }; I've tried this but it doesnt recognize 'botunit'. Anyone knows ? Aslo....how will the 'bot' send side messages to the player ? Link to comment Share on other sites More sharing options...
0 Sandbird Posted February 25, 2014 Author Report Share Posted February 25, 2014 ok found the 1st problem (publicvariable). Now about the side message ? Its not possible is it ? Link to comment Share on other sites More sharing options...
0 TheVampire Posted February 25, 2014 Report Share Posted February 25, 2014 Possibly its not recognizing it as an object for distance, but it should as a position. Try (player distance (getPosASL botunit) <= 5) Link to comment Share on other sites More sharing options...
0 TheVampire Posted February 25, 2014 Report Share Posted February 25, 2014 Just re-read, i'm not sure you can do side. I think you can do dialog though with Say or rSay. Sandbird 1 Link to comment Share on other sites More sharing options...
0 Sandbird Posted February 25, 2014 Author Report Share Posted February 25, 2014 yeah, probably cant... still have a global variable issue though...Its not working on another level now. Its a client side problem. I got a script that loads on addaction. That script has some objects spawning like this: [] spawn {[botunit,3] call target_spawner}; The target_spawner is a function, compiled first of course, but inside it, it should take a global variable and add +1 to it...like this bots = bots + 1; alive = alive + 1 this global variable should be used now outside, in the script that called the function in a hint box like: hintsilent format["Bots: %1/%2 Score: %3", bots, alive, _score]; The hint is inside a while statement with a sleep 1 at the end.....but ......the global value is not updating.... I've set the variables to 0 in the variables.sqf, and i see 0 when the hint appears...but why isnt it updating ? In a nutshell player -> addaction ---> script.sqf script.sqf ---> call target_spawner target_spawner ---> update values bots, alive script.sqf ---> while{true}---> show values bots, alive Link to comment Share on other sites More sharing options...
0 TheVampire Posted February 25, 2014 Report Share Posted February 25, 2014 You probably have a scope problem then. Make sure your variables are being defined in a global scope. Link to comment Share on other sites More sharing options...
0 Sandbird Posted February 25, 2014 Author Report Share Posted February 25, 2014 You probably have a scope problem then. Make sure your variables are being defined in a global scope. Yup, in my variables.sqf: bots= 0;alive= 0; Link to comment Share on other sites More sharing options...
0 TheVampire Posted February 25, 2014 Report Share Posted February 25, 2014 I'm not really sure then. Link to comment Share on other sites More sharing options...
0 Sandbird Posted February 26, 2014 Author Report Share Posted February 26, 2014 Ok i kinda managed to make it work...only that i am stuck to a weird point. I've set some global variables to some objects on the server side, and they work fine (checked with diag_log) ( i publicvariabled them :P) But when it reaches the point the objects to run a script (file is on the client side)....that damn thing is not firing up. t11 is the global variable of the object _ran1 is a random value...(i've set it to 100 for testing purposes) tar_hit.sqf all it does is adds a counter (hit=hit+1) basically. if(_ran1 > 50)then{t11 addEventHandler ["hit", {[t11,5] execVM "custom\tar_hit.sqf"}];}; Does this look wrong ? I've added a diag_log format [ "OBJ:%1", t11]; before the last curly end and it did echo t11, so it is grabbing the object. But adding a test diag_log at the top of the file, in the tar_hit.sqf brings nothing oO Its not running tar_hit and i dont understand why edit: Ok i know why now.......stupid server objects vs client objects.... Link to comment Share on other sites More sharing options...
0 Guest Posted March 7, 2014 Report Share Posted March 7, 2014 Hey is there a way to set the scope on a variable? Or is it just the underscore? I have one that I can't seem to reference from anywhere. All client side (mission) Link to comment Share on other sites More sharing options...
0 Sandbird Posted March 7, 2014 Author Report Share Posted March 7, 2014 Hey is there a way to set the scope on a variable? Or is it just the underscore? I have one that I can't seem to reference from anywhere. All client side (mission) Link to comment Share on other sites More sharing options...
Question
Sandbird
I need to set a global variable in a unit on the server. How can i check that variable after on the client side ?
Its for a bot i want to have a 'dialog' with. I need to access the 'name' of the bot.
On my server i got:
and on the client side i want to do this:
I've tried this but it doesnt recognize 'botunit'.
Anyone knows ?
Aslo....how will the 'bot' send side messages to the player ?
Link to comment
Share on other sites
10 answers to this question
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now