Jump to content
Sign in to follow this  
-FW- Shaanguy

Variable Checking Problem (Help!!)

Recommended Posts

in my init.sqf

all i want is to make my own inventory made up from script, like Wasteland Inventory, the problem here is, my two steps are correct, but step three is incorrect, i dont know how to check the item!? :butbut: in my scripted INV, it has to be like this if (player getVariable "INV" == "BLA1") then {BLA BLA BLA};

_otherItems = ["BLA1","BLA2","BLA3"];
player setVariable ["INV", _otherItems];

and then i went back to the game, and used this code

Hint format ["%1", player getVariable "INV"];

well the hint works fine, it shows the inventory objects , so i putted a addaction to a unit,

this addaction ["Check BLA1","Checker.sqf"];

Checker.sqf

if (player getVariable "INV" == BLA1) then
{
Hint "you have BLA1!";
};

init.sqf // Worked!

Hint // Worked!

Checker.sqf: Checking if i have the item // Not working!

I dont know how to check the item O_o,

For Newbies: remember i am using my own inventory system made up from script, not game inventory xD

Share this post


Link to post
Share on other sites

player getVariable "INV"

returns

["BLA1","BLA2","BLA3"]

So

(player getVariable "INV") select 0

returns "BLA1".

Share this post


Link to post
Share on other sites

A better way to do this would be to use the in command:

if ("BLA1" in (player getVariable "INV")) then
{
Hint "you have BLA1!";
};

Share this post


Link to post
Share on other sites

Thank you for this informative info, I hope I can start to catch on soon.

Shaanguy;2878159']in my init.sqf

all i want is to make my own inventory made up from script' date=' like Wasteland Inventory, the problem here is, my two steps are correct, but step three is incorrect, i dont know how to check the item!? :butbut: in my scripted INV, it has to be like this if (player getVariable "INV" == "BLA1") then {BLA BLA BLA};

_otherItems = ["BLA1","BLA2","BLA3"];
player setVariable ["INV", _otherItems];

and then i went back to the game, and used this code

Hint format ["%1", player getVariable "INV"];

well the hint works fine, it shows the inventory objects , so i putted a addaction to a unit,

this addaction ["Check BLA1","Checker.sqf"];

Checker.sqf

if (player getVariable "INV" == BLA1) then
{
Hint "you have BLA1!";
};

init.sqf // Worked!

Hint // Worked!

Checker.sqf: Checking if i have the item // Not working!

I dont know how to check the item O_o,

For Newbies: remember i am using my own inventory system made up from script, not game inventory xD[/quote']

Share this post


Link to post
Share on other sites

Thanks

This works

if ("BLA1" in (player getVariable "INV")) then
{
   Hint "you have BLA1!";
};  

now to find a way how to remove a variable xD,

Share this post


Link to post
Share on other sites
Shaanguy;2878731']now to find a way how to remove a variable xD' date='[/quote']

player setVariable ["INV", (player getVariable "INV") - ["BLA1"]];

Share this post


Link to post
Share on other sites

Set the value of the variable to nil.

 player setVariable ["VarName",nil];

Nvm...

Share this post


Link to post
Share on other sites

thanks all for the variable informations, i am not good at pro scripting variables, but i know the basics :D, i am having a other problem also, is there anyway to set a variable to that Bla1 like [["BLA1", 53],["BLA2", 45]]

and remove like this >_> // 24- from BLA1, like that maybe,

player setVariable ["INV", (player getVariable "INV") - ["BLA1", 24]];

Share this post


Link to post
Share on other sites

If your variable had that info in it yes, that should work, i.e.:

player setVariable ["INV",[["BLAH",24],["BLAH,53"],["BLAH",45]]];

//later on
player setVariable ["INV",(player getVariable "INV") - ["BLAH",24]];//should set the variable to just [["BLAH,53"],["BLAH",45]]

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  

×