Jump to content
Sign in to follow this  
tezz311

Variables from a master script

Recommended Posts

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

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

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

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
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
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 by Foxy

Share this post


Link to post
Share on other sites

That's working for me tezz, what exactly is happening when you try it?

Share this post


Link to post
Share on other sites
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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×