IF Conditional Sentence. -
DarkMaster1998 - 14.07.2017
Hey.. So i have this if and i can't write more conditions if i do then the compiler gives me an error message (2 Long input).. Should i use array ?? with for loop in the if cond.. or what i have tried but it didn't work.
PHP код:
if(IsPlayerInRangeOfPoint(playerid, 20.0, 2177.5725,-1973.2252,13.2218) || IsPlayerInRangeOfPoint(playerid, 20.0, -2048.5581,173.2598,28.4962) || IsPlayerInRangeOfPoint(playerid, 20.0, -353.9812,1540.1951,75.5625) || IsPlayerInRangeOfPoint(playerid, 20.0, 92.0248,-164.9822,2.5938) || IsPlayerInRangeOfPoint(playerid, 20.0, -1688.0195,1035.4976,45.2109) || IsPlayerInRangeOfPoint(playerid, 20.0, -1787.5283,1216.6865,25.1250) || IsPlayerInRangeOfPoint(playerid, 20.0, -2181.6172,712.8118,53.8906))
{
Re: IF Conditional Sentence. -
NaS - 14.07.2017
Technically you could split the conditions into multiple parts, but that would be ugly.
I'd recommend using an array here, it's much cleaner and easier to manage especially if you are adding more.
Alternatively you could use Streamer Areas (from Incognito's Streamer Plugin), however that doesn't always make sense (eg. for very rare use-cases it doesn't need to be checked constantly).
Re: IF Conditional Sentence. -
Paulice - 14.07.2017
You can extend the character limit per line to 4,095 with
Zeex's PAWN Compiler Patches. I do encourage the use of an array combined with a loop however.
Re: IF Conditional Sentence. -
DarkMaster1998 - 14.07.2017
Ya i quite agree with that.. but i can't do it with an array, something is going wrong can u do it for me.. not the whole array just a one example and how to put it in the if condition .. i would appreciate that.
Re: IF Conditional Sentence. -
NaS - 14.07.2017
Quote:
Originally Posted by DarkMaster1998
Ya i quite agree with that.. but i can't do it with an array, something is going wrong can u do it for me.. not the whole array just a one example and how to put it in the if condition .. i would appreciate that.
|
Something like:
Код:
new Float:Areas[][3] =
{
{2177.5725,-1973.2252,13.2218},
{-2048.5581,173.2598,28.4962},
{-353.9812,1540.1951,75.5625}
};
for(new i = 0; i < sizeof(Areas); i ++) if(IsPlayerInRangeOfPoint(playerid, 20.0, Areas[i][0], Areas[i][1], Areas[i][2]))
{
// Do something
break; // We found one area, so don't continue.
}
Re: IF Conditional Sentence. -
DarkMaster1998 - 14.07.2017
It works!
Thank you buddies
.
Re: IF Conditional Sentence. -
OneDay - 15.07.2017
Quote:
Originally Posted by DarkMaster1998
Hey.. So i have this if and i can't write more conditions if i do then the compiler gives me an error message (2 Long input).. Should i use array ?? with for loop in the if cond.. or what i have tried but it didn't work.
PHP код:
if(IsPlayerInRangeOfPoint(playerid, 20.0, 2177.5725,-1973.2252,13.2218) || IsPlayerInRangeOfPoint(playerid, 20.0, -2048.5581,173.2598,28.4962) || IsPlayerInRangeOfPoint(playerid, 20.0, -353.9812,1540.1951,75.5625) || IsPlayerInRangeOfPoint(playerid, 20.0, 92.0248,-164.9822,2.5938) || IsPlayerInRangeOfPoint(playerid, 20.0, -1688.0195,1035.4976,45.2109) || IsPlayerInRangeOfPoint(playerid, 20.0, -1787.5283,1216.6865,25.1250) || IsPlayerInRangeOfPoint(playerid, 20.0, -2181.6172,712.8118,53.8906))
{
|
Press enter.
PHP код:
if (
IsPlayerInRangeOfPoint(playerid, 20.0, 2177.5725,-1973.2252,13.2218) ||
IsPlayerInRangeOfPoint(playerid, 20.0, -2048.5581,173.2598,28.4962) ||
IsPlayerInRangeOfPoint(playerid, 20.0, -353.9812,1540.1951,75.5625) ||
IsPlayerInRangeOfPoint(playerid, 20.0, 92.0248,-164.9822,2.5938) ||
IsPlayerInRangeOfPoint(playerid, 20.0, -1688.0195,1035.4976,45.2109) ||
IsPlayerInRangeOfPoint(playerid, 20.0, -1787.5283,1216.6865,25.1250) ||
IsPlayerInRangeOfPoint(playerid, 20.0, -2181.6172,712.8118,53.8906))
{