A List
#1

Is it possible to make something like this in one list?

pawn Код:
if(PlayerToPoint(2.5,playerid,1277.9015,-1604.4323,-8.9047),
PlayerToPoint(2.5,playerid,1282.3475,-1603.8329,-8.9047),
PlayerToPoint(2.5,playerid,1246.1376,-1723.2724,-8.9135))
It takes too much time if I will write in one line like this:

pawn Код:
if(PlayerToPoint(2.5,playerid,1277.9015,-1604.4323,-8.9047) || PlayerToPoint(2.5,playerid,1282.3475,-1603.8329,-8.9047))
Reply
#2

Not like you have done it but u can like this using || not comma's.
pawn Код:
if(PlayerToPoint(2.5,playerid,1277.9015,-1604.4323,-8.9047)||
PlayerToPoint(2.5,playerid,1282.3475,-1603.8329,-8.9047)||
PlayerToPoint(2.5,playerid,1246.1376,-1723.2724,-8.9135))
Will take the same amount of time though lol
Reply
#3

Quote:
Originally Posted by iggy1
Посмотреть сообщение
Not like you have done it but u can like this using || not comma's.
pawn Код:
if(PlayerToPoint(2.5,playerid,1277.9015,-1604.4323,-8.9047)||
PlayerToPoint(2.5,playerid,1282.3475,-1603.8329,-8.9047)||
PlayerToPoint(2.5,playerid,1246.1376,-1723.2724,-8.9135))
Will take the same amount of time though lol
No, it will be more faster to edit this
Reply
#4

Use

Somewhere near the top

pawn Код:
new Float:Yourname[3][3] = { //Where first 3 is how many coords you have
{1277.9015,-1604.4323,-8.9047},
{1282.3475,-1603.8329,-8.9047},
{1246.1376,-1723.2724,-8.913}
};
than in place where you need these coords
pawn Код:
for(new i = 0; i <sizeof(Yourname); i++)
{
    if(IsPlayerInRangeOfPoint(playerid,2.5,Yourame[i][0],Yourame[i][1],Yourame[i][2]))
    {
    //Do something here
    }
}
btw, PlayerToPoint is like Win95
Reply
#5

I know this has already been answered, but why not use an array and a loop for how many "PlayerToPoint" coords there are?

eg,

pawn Код:
enum PTPInfo {Float:Distance, Float:x, Float:y, Float:z}
new PTP[][PTPInfo] = {
{2.5,1277.9015,-1604.4323,-8.9047},
{2.5,1282.3475,-1603.8329,-8.9047},
{2.51246.1376,-1723.2724,-8.9135}
};
//The above could go anywhere in the script, maybe at the top for easy access to add more?
for(new i; i < sizeof(PTP); i++)
{
     if(PlayerToPoint(PTP[i][Distance], playerid, PTP[i][x], PTP[i][y], PTP[i][z])
     {
           //Do you're thing here :)
     }
}
I havent tested it, but i use something like that on my server for checking whether a player is near a certain door, (eg, theres three doors, but everytime a player types /enter it runs something like the above code to check where they are, and what door there at)

Edit: Sorry Voldermort, we posted at the same time xD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)