Mining
#1

Is there any short way to shorten the lines.

pawn Код:
CMD:mine(playerid)
{
    if(IsPlayerInRangeOfPoint(playerid, range, x, y,z) || IsPlayerInRangeOfPoint(playerid, range, x,y,z))
    return 1;
}
Something like that, but I don't want to create more "IsPlayerInRageOfPoint" and more. As it makes lines longer.
Since that there's lots of objects to mine.

Any short ways ?
Reply
#2

You can use dynamic areas instead.
Reply
#3

Use loop.
Reply
#4

Well... you would essentially have to keep expanding

pawn Код:
if(IsPlayerInRangeOfPoint(playerid, range, x, y,z) || IsPlayerInRangeOfPoint(playerid, range, x,y,z) || IsPlayerInRangeOfPoint(playerid, range, x,y,z) || IsPlayerInRangeOfPoint(playerid, range, x,y,z) || IsPlayerInRangeOfPoint(playerid, range, x,y,z) || IsPlayerInRangeOfPoint(playerid, range, x,y,z))
or as Pottus said, dynamic points.
Reply
#5

pawn Код:
//top of your script
new Float:mines[][] =
{
    {1649.7455, -2147.9253, 6.9209}, // Mine1 (format x, y, z).
    {1549.7715, -2677.9262, 15.9550}, // Mine2
    //.....
    {844.5756, -1667.2555, 2.7684} // Last mine
};

CMD:mine(playerid)
{
    for(new i; i < sizeof(mines); i++)
    {
        if(!IsPlayerInRangeOfPoint(playerid, range, mines[i][0], mines[i][1], mines[i][2])) continue;
        //The player is in range of a mine.
    }
    return 1;
}
.
Reply
#6

You can create an array:
Код:
enum eMine {
	Float:range,
	Float:x,
	Float:y,
	Float:z
}

new Mining[][eMine] =
{
	{10.0,2480.86,-1959.27,12.9609},
	{10.0,1634.11,-2237.53,12.8906}
};
And then:
Код:
for(new x; x != sizeof(Mining); x++)
{
	if(IsPlayerInRangeOfPoint(playerid, Mining[x][range], Mining[x][x],Mining[x][y],Mining[x][z])
	{
		//do smthing
	}
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)