Help here please - 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)
+--- Thread: Help here please (
/showthread.php?tid=574130)
Help here please -
OliverK - 13.05.2015
How to create vehicles with this useful function?
GetXYGridPos
https://sampforum.blast.hk/showthread.php?tid=38965&page=446
Re: Help here please -
OliverK - 27.05.2015
?...
Re: Help here please -
shadowdog - 27.05.2015
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
}
You insert all the params. XY and R are centered. Index stands for the vehicle number you want to spawn. Columns stand for the amount of side-by-side lines. Offsets are individual distances between vehicles.
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);
}
Re: Help here please -
OliverK - 28.05.2015
thank you very much
Re: Help here please -
OliverK - 28.05.2015
Код:
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?
Re: Help here please -
OliverK - 28.05.2015
Help - me ?