SA-MP Forums Archive
Need some advice - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need some advice (/showthread.php?tid=521929)



Need some advice - babecka - 25.06.2014

Hello! I'm making a new script and I'd like to keep the code short and clean, however, I need some advice. I have many variables in my code, and my question is:

I have a variable
Код:
new bool:Variable[10];
And I want to make the variable false, so I do this
Код:
Variable[1] = false;
Variable[2] = false;
Variable[3] = false;
...
Variable[10] = false;
My question is, what is the code to make it shorter, so I don't need to type it like that. I know it is possible, but I don't know how and I couldn't find the code.

Also, would it be also possible in a similliar way to do this:
Код:
new bool:Variable[10];

if(Variable[1] == true) 
{
    Do this
    and that
}
else if(Variable[2] == true) 
{
    Do this
    and that
}

else if(Variable[3] == true) 
{
    Do this
    and that
}
I hope you get it; I want to check 10 boolean - I check if they are true - and if Variable[1] == true I want to e.g. set the Player's pos to 0.0, however if Variable[2] == true I want to set the pos to 1.0.

I can provide more explantation if you do not know what I mean, but I hope you can help me!