Quote:
Originally Posted by xTURBOx
PHP код:
if(checkpointid == CP[1] || CP[2] || CP[3] || CP[4])
So this is the "efficient" way to do this?
|
Well, that's not the right syntax for an if statement with multiple "or" operators. Here are your options:
Код:
if(checkpointid == CP[1] || checkpointid == CP[2] || checkpointid == CP[3] || checkpointid == CP[4])
or
Код:
for(new i=0; i <= 4; i++)
{
if(checkpointid == CP[i])
{
// do code for entering CP
break; // break out of the loop
}
}
Honestly, at your level of experience, I wouldn't worry too much about efficiency. There are many ways you could optimize your code in these situations but it probably wouldn't be much use to you. Rather, just learn how to get stuff functioning.