Explode help -
kbalor - 13.04.2014
Can you please help me do the explode command? I need to get the player facing angle and around 5 meters away when I do the explode command then there will be an explosion at that 5 meters away where the player is facing the angle.
Re: Explode help -
Dignity - 13.04.2014
You do it like this: (I'm not sure if X is the correct coordinate though, but you get my point).
pawn Код:
CMD:explode(playerid, params[])
{
new Float: X, Float: Y, Float: Z;
GetPlayerPos(playerid, X, Y, Z);
CreateExplosion(X +5, Y, Z, 12, 10.0);
return 1;
}
Re: Explode help -
kbalor - 13.04.2014
Quote:
Originally Posted by Mionee
You do it like this: (I'm not sure if X is the correct coordinate though, but you get my point).
pawn Код:
CMD:explode(playerid, params[]) { new Float: X, Float: Y, Float: Z; GetPlayerPos(playerid, X, Y, Z); CreateExplosion(X +5, Y, Z, 12, 10.0);
return 1; }
|
EDIT: It works! But it doesn't get the player facing angle. When I do the command it explodes at South but i'm facing at North.
Re: Explode help -
Dignity - 13.04.2014
You could try increasing the range. Also, perhaps creating smaller explosions and using a small explosion radius might help.
Re: Explode help -
Konstantinos - 13.04.2014
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));
}
pawn Код:
CMD:explode(playerid, params[])
{
new Float: X, Float: Y, Float: Z;
GetPlayerPos(playerid, X, Y, Z);
GetXYInFrontOfPlayer(playerid, X, Y, 5.0)
CreateExplosion(X, Y, Z, 12, 10.0);
return 1;
}
Re: Explode help -
kbalor - 13.04.2014
Man I edited my post but I think you didn't notice.
EDIT: Konstantinos i'll try yours.
Kons this line CreateExplosion(X,Y,Z, 12, 10.0);
Quote:
expected token ; but found identiffier
|
GOT IT forgot the ;
Re: Explode help -
iBanner - 13.04.2014
EDIt
Re: Explode help -
Konstantinos - 13.04.2014
I forgot the semicolon in the above line, sorry:
pawn Код:
GetXYInFrontOfPlayer(playerid, X, Y, 5.0);
Re: Explode help -
Kyance - 13.04.2014
pawn Код:
CMD:aexplode(playerid, params[]) {
new Float:X, Float:Y, Float:Z, Float:vX, Float:vY, Float:vZ, Float:oX, Float:oY, Float:oZ; //PlayerPos(3), CameraVectorPos(3), ObjectPos(3)..
const Float:fScale = 100.0; //The max distance
GetPlayerCameraPos(playerid, X, Y, Z); //Gets PlayerCameraPos
GetPlayerCameraFrontVector(playerid, vX, vY, vZ); //Gets PlayerCamerasFrontVector
oX = X + floatmul(vX, fScale); //Dunno D:
oY = Y + floatmul(vY, fScale); //Dunno D:
oZ = Z + floatmul(vZ, fScale); //Dunno D:
CreateExplosion(oX, oY, oZ, 3, 50); //Creates the explosion
return 1;
}
This works kinda the same as Konstantinos i guess xd
EDIT: You can use this, simplified verison or w.e
pawn Код:
CMD:aexplode(playerid, params[]) {
new Float:pPos[3], Float:vPos[3], Float:oPos[3];
const Float:fScale = 250.0; //The max distance
GetPlayerCameraPos(playerid, pPos[0], pPos[1], pPos[2]); //Gets PlayerCameraPos
GetPlayerCameraFrontVector(playerid, vPos[0], vPos[1], vPos[2]);
oPos[0] = pPos[0] + floatmul(vPos[0], fScale); //Dunno D:
oPos[1] = pPos[1] + floatmul(vPos[1], fScale); //Dunno D:
oPos[2] = pPos[2] + floatmul(vPos[2], fScale); //Dunno D:
CreateExplosion(oPos[0], oPos[1], oPos[2], 3, 50); //Creates the explosion
return 1;
}
Re: Explode help -
kbalor - 13.04.2014
@Kons - This one works nice! +rep. Also I have a question why is that when I press a key and then if I press another one. The second one key hangs a little bit. I think it is not possible to executive two keys at the same time?
@Kyance - Yes it also works but I only heard the explosion but the object I couldn't. The explosion you use is visible so we don't have any problem from that. I also tried to fly above the sky. And do the explode command many times but still it is not visible.