SA-MP Forums Archive
creating an explosion in front of player in all sides? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: creating an explosion in front of player in all sides? (/showthread.php?tid=146828)



creating an explosion in front of player in all sides? - 0ne - 09.05.2010

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?


Re: creating an explosion in front of player in all sides? - iJumbo - 09.05.2010

Код:
	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 !


Re: creating an explosion in front of player in all sides? - 0ne - 09.05.2010

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


Re: creating an explosion in front of player in all sides? - iJumbo - 09.05.2010

ah ! xD sorry


Re: creating an explosion in front of player in all sides? - ¤Adas¤ - 09.05.2010

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


Re: creating an explosion in front of player in all sides? - 0ne - 09.05.2010

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


Re: creating an explosion in front of player in all sides? - ¤Adas¤ - 09.05.2010

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?


Re: creating an explosion in front of player in all sides? - 0ne - 09.05.2010

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


Re: creating an explosion in front of player in all sides? - ¤Adas¤ - 09.05.2010

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


Re: creating an explosion in front of player in all sides? - Conroy - 09.05.2010

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);