Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
infection

If false comparison array

Recommended Posts

Hello I've ran into some trouble in an if statement and I'm not quite sure what the best way is to resolve it!

I currently have the variable ReturnedDatabaseLoadOuts being sent from the server, returns false if player dosn't have a profile. However if they do it returns an array of items he/she had.

So

No profile means-

ReturnedDatabaseLoadOuts = false;

Having a profile means

ReturnedDatabaseLoadOuts = ["thingy",thingy2,thingy3,thingy4];

however here's the problem I'm having

if (!(ReturnedDatabaseLoadOuts)) exitwith {bla bla bla};

Works great as long as ReturnedDatabaseLoadOuts is a boolean variable (I.E false in this case) however if it's the array incase you have a profile I get this.

if (!(ReturnedDatabaseLoadOuts)) exitwith
{
>
 Error position: <!(ReturnedDatabaseLoadOuts)) exitwith
{
>
 Error !: Type Array, expected Bool

So, as I said I don't know what the easiest solution to this would be.

Thanks for your help!

Share this post


Link to post
Share on other sites

Maybe counting the array would be better

if ( count (ReturnedDatabaseLoadOuts) == 0 ) exitwith {bla bla bla};

Actually I don't think it will work unless instead of ReturnedDatabaseLoadOuts = false you can make it ReturnedDatabaseLoadOuts=[];

Edited by F2k Sel

Share this post


Link to post
Share on other sites

couldn't you just do

if (ReturnedDatabaseLoadOuts) then {code stuff } else {bla bla bla};

????

Share this post


Link to post
Share on other sites

@Nimrod that returned the same error because it tries to check if it's true or false but it's an array.

@F2k sel Works great thanks!

Share this post


Link to post
Share on other sites

I just sent a request to the server for a Player uid - if it the return value was not the same as the player requesting uid - create all the necessary bits.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×