13.05.2015, 20:48
How to create vehicles with this useful function?
GetXYGridPos https://sampforum.blast.hk/showthread.php?tid=38965&page=446
GetXYGridPos https://sampforum.blast.hk/showthread.php?tid=38965&page=446
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
}
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);
}
undefined symbol "Resultx" & undefined symbol "Resulty" in: stock Calc_Point(Float:xs, Float:ys, &Float:x, &Float:y, Float:xOffset, Float:yOffset, Float:Angle, i, j) { //do further calculations with the params in last operation, find the next x and y values in the grid //x and yOffset is basically the space between the coordinates you calculate. Bigger value, bigger grid. x = xs +i * xOffset * floatcos(Angle,degrees) +j * yOffset * floatsin(Angle,degrees); y = ys + i * xOffset * floatsin(Angle,degrees) - j * yOffset * floatcos(Angle,degrees); //the two here is having + & + and + & - because of the coordinate system in samp. } Help?