27.05.2015, 09:09
PHP код:
stock GetXYGridPos(Float:xs, Float:ys, &Float:x, &Float:y, Float:Angle, Index , Columns, Float:xOffset, Float:yOffset)
{
//the values saved in x and y are the values saved into the variable you use in the function call param 3 and 4.
//the "Index" is defining which of the positions in the grid you want to calculate and get returned.
//if we had two columns this would mean: 0 = front left, 1 = front right, 2 = row two left, 3 = row two right.. and so on.
new i = Index%Columns; //modulus
new j = floatround(Index, floatround_floor) / Columns; //normal division, rounding to nearest even number below the value.
Calc_Point(xs, ys, Resultx, Resulty, xOffset, yOffset, Angle , i, j);
x = Resultx; //x Position
y = Resulty;//Y position
}
Let's say you want to make a boat race.
PHP код:
new pos[2];
for(new i;i<10;i++) //spawns 9 boats
{
GetXYGridPos(2000.0,2000.0, pos[0], pos[1], i, 0, 5.0, 10.0);
CreateVehicle(490,pos[0], pos[1],1.0,0.0,0,0,1000);
}