new Float:CentreCircle[3];
CentreCircle[0] = 0;
CentreCircle[1] = 0;
CentreCircle[2] = 0;
new randX = random(/*Max*/ - /*Min*/)+/*Min*/,
randY = random(/*Max*/ - /*Min*/)+/*Min*/;
printf("Random Position: X: %f, Y: %f, Z: %f", CentreCircle[0]+randX, CentreCircle[1]+randY, CentreCircle[2]);
//A function to get a point on the edge of a circle, given a radius and an angle GetPointOnEdgeOfCircle(&Float:x, &Float:y, Float:r, Float:a, bool:isGTAAngle = false) { if(isGTAAngle) { //In case the angle was retrieved with GetPlayerFacingAngle, GetVehicleZAngle, ... a += 90.0; } x += r * floatcos(a, degrees); y += r * floatsin(a, degrees); } //Get the player's position new Float:x, Float:y, Float:z; GetPlayerPos(playerid, x, y, z); //Example with radius = 50.0 GetPointOnEdgeOfCircle(x, y, 50.0, frandom(360.0)); //See this post for frandom
No, that's incorrect, follow some math courses ...
This is correct: Код:
//A function to get a point on the edge of a circle, given a radius and an angle GetPointOnEdgeOfCircle(&Float:x, &Float:y, Float:r, Float:a, bool:isGTAAngle = false) { if(isGTAAngle) { //In case the angle was retrieved with GetPlayerFacingAngle, GetVehicleZAngle, ... a += 90.0; } x += r * floatcos(a, degrees); y += r * floatsin(a, degrees); } //Get the player's position new Float:x, Float:y, Float:z; GetPlayerPos(playerid, x, y, z); //Example with radius = 50.0 GetPointOnEdgeOfCircle(x, y, 50.0, frandom(360.0)); //See this post for frandom |
No, that's incorrect, follow some math courses ...
This is correct: Код:
//A function to get a point on the edge of a circle, given a radius and an angle GetPointOnEdgeOfCircle(&Float:x, &Float:y, Float:r, Float:a, bool:isGTAAngle = false) { if(isGTAAngle) { //In case the angle was retrieved with GetPlayerFacingAngle, GetVehicleZAngle, ... a += 90.0; } x += r * floatcos(a, degrees); y += r * floatsin(a, degrees); } //Get the player's position new Float:x, Float:y, Float:z; GetPlayerPos(playerid, x, y, z); //Example with radius = 50.0 GetPointOnEdgeOfCircle(x, y, 50.0, frandom(360.0)); //See this post for frandom |
new Float:X, Float:Y, Float:Z; new objectid = CreateTimedObject(RandomEx(60000, 80000), 1264, DumpsterData[dumpsterid][dumpsterX], DumpsterData[dumpsterid][dumpsterY], (DumpsterData[dumpsterid][dumpsterZ] + 1.20), 0.0, 0.0, random(360)); switch(DumpsterData[dumpsterid][dumpsterSide]) { case true: // Left { GetPointInFront2D(DumpsterData[dumpsterid][dumpsterActionX], DumpsterData[dumpsterid][dumpsterActionY], ((DumpsterData[dumpsterid][dumpsterR] + (RandomFloat(40.0, 50.0))) + 180.0), RandomFloat(1.75, 2.90), X, Y); } case false: // Right { GetPointInFront2D(DumpsterData[dumpsterid][dumpsterActionX], DumpsterData[dumpsterid][dumpsterActionY], ((DumpsterData[dumpsterid][dumpsterR] + (RandomFloat(-40.0, -50.0))) + 180.0), RandomFloat(1.75, 2.90), X, Y); } } GetPlayerPos(playerid, Z, Z, Z); MoveDynamicObject(objectid, X, Y , (Z - 0.50), 9.0);