[HELP] A lot of values
#1

Hey there peeps, o have got a little problem, i got a 100 locations (yes exactly a 100) but i dont want to make a fuction like:
pawn Code:
if(location 1)
    {
        function
    }
if(location 2)
    {
        function
    }
if(location 3)
    {
        function
    }
if(location 4)
    {
        function
    }
................
because that will get way TOO long, so heres the question:
How do i shorten this? so i can make a lot of functions with these locations, and i dont need to make something like that ^ in every function??

Something like a 'new' or something i have seen it before like:
pawn Code:
new
    locations[100????][????????????????] =
    {
     {location1}
{location2}
{location3}
{location4}
.......
    };
Reply
#2

EDIT: I was very wrong
Reply
#3

They are called multidimensional arrays :P. Here is a little example:

pawn Code:
//Change the 5 to the total amount of locations (100)
new Float:Locations[5][4] = {
//X | Y   | Z | Angle
{0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0}
};
Reply
#4

Quote:
Originally Posted by PotH3Ad
View Post
They are called multidimensional arrays :P. Here is a little example:

pawn Code:
//Change the 5 to the total amount of locations (100)
new Float:Locations[5][4] = {
//X | Y   | Z | Angle
{0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0}
};
But can you explain me how to use them if i for EX wanted to do if(playertopoint ANY OF THE 100 POINTS)
Reply
#5

pawn Code:
for(new i = 0; i < sizeof(Locations); i++)
{
    if(IsPlayerInRangeOfPoint(playerid, 100, Locations[i][0],Locations[i][1],Locations[i][2])
    {
        //Something here?
    }
}
Reply
#6

now i have this
pawn Code:
for(new i = 0; i < sizeof(Locations); i++)
            {
                if(!IsPlayerInRangeOfPoint(playerid, 7.0, Locations[i][0],Locations[i][1],Locations[i][2]))
                {
                SendClientMessage(playerid, COLOR_GREY, "   You are not at the Bank !");
                return 1;
                }
            }
And everywhere i use the cmd it says You are not at the bank !
Reply
#7

bump....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)