[HELP] A lot of values - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] A lot of values (
/showthread.php?tid=163058)
[HELP] A lot of values -
WThieves - 25.07.2010
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}
.......
};
Re: [HELP] A lot of values -
iggy1 - 25.07.2010
EDIT: I was very wrong
Re: [HELP] A lot of values -
PotH3Ad - 26.07.2010
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}
};
Re: [HELP] A lot of values -
WThieves - 26.07.2010
Quote:
Originally Posted by PotH3Ad
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)
Re: [HELP] A lot of values -
Shadow™ - 26.07.2010
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?
}
}
Re: [HELP] A lot of values -
WThieves - 26.07.2010
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 !
Re: [HELP] A lot of values -
WThieves - 27.07.2010
bump....