hey how to detect this cords
#1

hey how to detect this cord for make explosion

Reply
#2

Get the X Y Z, and ad +4 to the X and ?

pawn Код:
new Float: X, Float: Y, Float: Z;
GetPlayerPos(playerid, X, Y, Z);

CreateExplosion(X+4, Y, Z, 2, 10);
That will create +4 units in the X direction, do the same with Y, and X and Y at the same time for oblique

Or did I misunderstood your question?
Reply
#3

Samp rotations seem to be incopatible to the pawn sin/cos values, I have no idea why.

This means, at first, you need to invert the players facing angle.
The inverted angle now points to the front of the player, if you want to get a point e.g. 100° right of him or so, add an offset. I think -degrees to go right, and +degrees to go left (-90 would point to the right of the player, 180 to the back, ...)
Now you can use floatsin, floatcos and some basic math knowledge to calculate the point you want to have.

The result could look like this:

pawn Код:
public GetPlayerRelativeCoords(playerid, Float:angle, Float:distance, &Float:x, &Float:y, &Float:z)
{
    new Float:rot;
    GetPlayerFacingAngle(playerid, rot);
    rot = 360 - rot + angle;

    GetPlayerPos(playerid, x, y, z);
    x = x + floatsin(rot, degrees) * distance;
    y = y + floatcos(rot, degrees) * distance;
    return 1;
}
It may work, but i just wrote it from nothing + there is some green smoke here in my room, so i cant guarantee for it to work
Reply
#4

pawn Код:
#define EXPLOSION_OFFSET                (3.5)

new
    Float:x,
    Float:y,
    Float:z;
GetPlayerPos(playerid, x, y, z);
CreateExplosion(x, y - EXPLOSION_OFFSET, z, 2, 3.0);
CreateExplosion(x, y + EXPLOSION_OFFSET, z, 2, 3.0);
CreateExplosion(x - EXPLOSION_OFFSET, y - EXPLOSION_OFFSET, z, 2, 3.0);
CreateExplosion(x + EXPLOSION_OFFSET, y + EXPLOSION_OFFSET, z, 2, 3.0);
CreateExplosion(x - EXPLOSION_OFFSET, y + EXPLOSION_OFFSET, z, 2, 3.0);
CreateExplosion(x + EXPLOSION_OFFSET, y - EXPLOSION_OFFSET, z, 2, 3.0);
Reply
#5

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
Samp rotations seem to be incopatible to the pawn sin/cos values, I have no idea why.

This means, at first, you need to invert the players facing angle.
The inverted angle now points to the front of the player, if you want to get a point e.g. 100° right of him or so, add an offset. I think -degrees to go right, and +degrees to go left (-90 would point to the right of the player, 180 to the back, ...)
Now you can use floatsin, floatcos and some basic math knowledge to calculate the point you want to have.

The result could look like this:

pawn Код:
public GetPlayerRelativeCoords(playerid, Float:angle, Float:distance, &Float:x, &Float:y, &Float:z)
{
    new Float:rot;
    GetPlayerFacingAngle(playerid, rot);
    rot = 360 - rot + angle;

    GetPlayerPos(playerid, x, y, z);
    x = x + floatsin(rot, degrees) * distance;
    y = y + floatcos(rot, degrees) * distance;
    return 1;
}
It may work, but i just wrote it from nothing + there is some green smoke here in my room, so i cant guarantee for it to work
Yep, just make this a stock. No need to be a public. Then call it like so:

pawn Код:
#define EXPLOSION_DISTANCE  3.5
#define EXPLOSION_TYPE      8
#define EXPLOSION_RADIUS    7.0

new Float:playerPos[4];
for (new angle = 0; angle < 360; angle += 45) {
    // Get the player's position and angle
    GetPlayerPos(playerid, playerPos[0], playerPos[1], playerPos[2]);
    GetPlayerFacingAngle(playerid, playerPos[3]);
   
    // Store the new position calculated by our function
    GetPlayerRelativeCoords(playerid, playerPos[3], EXPLOSION_DISTANCE, playerPos[0], playerPos[1], playerPos[2]);
   
    // Create the explosion
    CreateExplosion(playerPos[0], playerPos[1], playerPos[2], EXPLOSION_TYPE, EXPLOSION_RADIUS);
}
This code is not tested either, and there is also tons of green smoke in my room. Good luck!

Edit: Bigcomfycouch's solution will probably get the desired effect visually, but it is entirely wrong mathematically and it won't scale to larger distances.
Reply
#6

thx all works :d
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)