creating an explosion in front of player in all sides?
#1

I got a simple cmd:

pawn Код:
new Distance = 10,Float:Poss[4];
        GetPlayerPos(playerid,Poss[0],Poss[1],Poss[2]);
        GetPlayerFacingAngle(playerid,Poss[3]);
        CreateExplosion
        (
          Poss[0] + ( Distance * floatsin( -Poss[3], degrees) ),
          Poss[1] + ( Distance * floatcos( -Poss[3], degrees) ),
          Poss[2],
          11,
          10.0
        );
it should create an explosion in front i guess but it only creates it in east side and the distance is pretty low, i don't really get it how to increase it and do a explosion ALWAYS in front of him?
Reply
#2

Код:
	new Float:x,Float:y,Float:z;
	new Float:xx2,Float:yy2,Float:az;
	new Float:x3,Float:y3;
	new Float:x4,Float:y4;
	new Float:x5,Float:y5;
	new Float:x6,Float:y6;
	new Float:xi,Float:yi;
	new Float:xi2,Float:yi2;
	if( strcmp(cmdtext, "/lalal", true) == 0)
	{
	GetPlayerPos(playerid,x,y,z);
	GetPlayerFacingAngle(playerid, az);
	xi = x + (5 * floatsin(-az, degrees));
	yi = y + (5 * floatcos(-az, degrees));
	xx2 = x + (10 * floatsin(-az, degrees));
	yy2 = y + (10 * floatcos(-az, degrees));
	x3 = x + (15 * floatsin(-az, degrees));
	y3 = y + (15 * floatcos(-az, degrees));
	x4 = x + (20 * floatsin(-az, degrees));
	y4 = y + (20 * floatcos(-az, degrees));
	x5 = x + (25 * floatsin(-az, degrees));
	y5 = y + (25 * floatcos(-az, degrees));
	x6 = x + (30 * floatsin(-az, degrees));
	y6 = y + (30 * floatcos(-az, degrees));
	CreateExplosion(xi2,yi2,z-1,11,0);
	CreateExplosion(xi,yi,z-1,11,2.5);
	CreateExplosion(xx2,yy2,z-1,11,2.5);
	CreateExplosion(x3,y3,z-1,11,2.5);
	CreateExplosion(x4,y4,z-1,11,2.5);
	CreateExplosion(x5,y5,z-1,11,2.5);
	CreateExplosion(x6,y6,z-1,11,10);
	return 1;
}
try this lol !
Reply
#3

Thats so wrong, i don't need bunch of explosions, i need only ONE EXPLOSION which is in about 15 to 20meters away and TO THE FRONT while he is in vehicle not to only 1side. it does west side now
Reply
#4

ah ! xD sorry
Reply
#5

Look @ my Explosion protection.pwn, it is down here.
Reply
#6

i don't understand anything there and besides i already checked it.
Reply
#7

Well, this is the function to do that.

pawn Код:
stock bool:GetPosInFrontOfPoint(&Float:OutputX, &Float:OutputY, Float:Angle, Float:Distance)
{
if(!Distance) return false;
OutputX += floatmul(Distance, floatsin(-Angle, degrees));
OutputY += floatmul(Distance, floatcos(-Angle, degrees));
return true;
}
Do you understand now?
Reply
#8

No i don't understand because i don't even know how to use this function.
Reply
#9

Well, parameter Angle - direction
Distance - it is... a distance from XY point
.....
I just can't show you an example...
Reply
#10

pawn Код:
GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x, y, a);
GetPlayerFacingAngle(playerid, a);
if (GetPlayerVehicleID(playerid))
{
  GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
}
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}
Usage:

pawn Код:
new Float:X, Float:Y, Float:Z;
GetXYInFrontOfPlayer(playerid, X, Y, Z);
CreateExplosion(X, Y, Z, 11, 10.0);
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)