tezz311 10 Posted August 20, 2013 I need help modifying my variables its a simple case of I want one script to hold all the variables for my mission. lets say I have a script that displays a hint with the total value of earned XP and I have another script tied to a feature where if you complete that specific task it adds XP to the HUD display how can I call the variable from another script to be modified? Share this post Link to post Share on other sites
bangabob 45 Posted August 20, 2013 Use get/set variable. Check this video tutorial if you don't know how to use it Share this post Link to post Share on other sites
cuel 25 Posted August 20, 2013 So you just want some normal global variables? http://community.bistudio.com/wiki/Variables#Global_Variables Any variable defined as e.g MyVariable = 0; can be accessed from anywhere and also be redefined. E: Oh hud.. Should still be the same? Just update the value Share this post Link to post Share on other sites
tezz311 10 Posted August 21, 2013 It for some reason keeps coming up with "error no defined variable" I'll paste my code in see if I did anything wrong ///// Master Variable Arrays V0.1A ///// experiance = 2500; skillpoints = 22500; infamy = 1200; //// Player Initialization //// if (isPlayer ranger1) then hint format["Skill Points: %1 \nInfamy: %2 \nexperiance %3",skill,infamy,experiance]; Share this post Link to post Share on other sites
cuel 25 Posted August 21, 2013 And you run the variables-script before player init? Hint should not have a problem since it is formatting the variables. If I run hint format ["%1",undefined_var]; The hint box will say "any" - it does not exist (undefined). It won't throw a script error. I'd say the undefined variable error is caused by something else. A good practice is also to use TAG_variables where TAG is (often) 3-letters, e.g yours could be TEZ_variable. This is done to avoid any conflicts with (bad :p) addons or existing scripting commands Edit: 1k posts! :) Share this post Link to post Share on other sites
Larrow 2828 Posted August 21, 2013 It for some reason keeps coming up with "error no defined variable" I'll paste my code in see if I did anything wrong ///// Master Variable Arrays V0.1A ///// experiance = 2500; [color="#FF0000"]skillpoints[/color] = 22500; infamy = 1200; //// Player Initialization //// if (isPlayer ranger1) then hint format["Skill Points: %1 \nInfamy: %2 \nexperiance %3",[color="#FF0000"]skill[/color],infamy,experiance]; if (isPlayer ranger1) then hint format["Skill Points: %1 \nInfamy: %2 \nexperiance %3",[color="#FF0000"]skillpoints[/color],infamy,experiance]; Share this post Link to post Share on other sites
tezz311 10 Posted August 26, 2013 Tried larrows suggestion still doesn't work? Share this post Link to post Share on other sites
Foxy 1 Posted August 26, 2013 (edited) And you run the variables-script before player init?My guess is this is the problem.You could try placing the player init code in an sqf and the call that from the player init box. Add a waitUntil {!isNil "infamy"}; at the top to be sure. eg: in player init box: nul0 = execVM "playerInit.sqf"; playerInit.sqf: waitUntil {!isNil "infamy"}; if (isPlayer ranger1) then {hint format["Skill Points: %1 \nInfamy: %2 \nexperiance %3",skillpoints,infamy,experiance]}; Edited August 26, 2013 by Foxy Share this post Link to post Share on other sites
kylania 568 Posted August 26, 2013 That's working for me tezz, what exactly is happening when you try it? Share this post Link to post Share on other sites
Larrow 2828 Posted August 27, 2013 Tried larrows suggestion still doesn't work?If its not that error that i pointed out in your script then you will need to supply the whole error code of where it is saying a variable is undefined for any of us to be able to help you. Else were just playing a guessing game. Share this post Link to post Share on other sites