Float help -
Equuuuin0X - 28.03.2014
So, I've made a slap command with the function of this:
pawn Код:
GetPlayerPos(id, x, y, z);
SetPlayerPos(id,x,y,z+6);
so, If I want to make it the pos to the right side, instead of goes up, I mean, if i do /forward it'll slap to forward,and other else.
The problem is
should I do this
pawn Код:
GetPlayerPos(id, x, y, z);
SetPlayerPos(id,x+6,y,z);
to make the /goright command, so the pos will goes to the right side ?
Re: Float help -
Vince - 28.03.2014
No, because if the player isn't facing to the north, it won't be his right side. You need GetXYInFrontOfPlayer and variations of it.
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));
}
Not sure who originally wrote this.
Re: Float help -
Equuuuin0X - 28.03.2014
Sorry, could you explain more ? I seems not to be understand them at ALL.
I need something that I could make of these commands:
/fly (same like slap)
/forward (slaps into forward)
/right (slaps into right)
/left (slaps into left)
/back(slaps into back)
Re: Float help -
Matess - 28.03.2014
It's from debug:
pawn Код:
GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{ // Created by ******
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));
}
This will return X, Y in front of you so for behind:
pawn Код:
x += (distance * floatsin(a, degrees));
y += (distance * floatcos(a, degrees));
and for left/right:
pawn Код:
//Right
x += (distance * floatsin(-a+90, degrees));
y += (distance * floatcos(-a+90, degrees));
//Left
x += (distance * floatsin(-a-90, degrees));
y += (distance * floatcos(-a-90, degrees));
Re: Float help -
Equuuuin0X - 30.03.2014
Which one is for forward ? and which one is for behind ?