22.09.2010, 16:35
Quote:
Hello guys.
I'm making a simple flying script, but it keeps making me face 0.0. Код:
public OnPlayerUpdate(playerid) { if(GetPVarInt(playerid, "Superman") == 1) { GetPlayerKeys(playerid,Keys,ud,lr); if(Keys & KEY_SPRINT) { GetPlayerPos(playerid, x2, y2, z2); GetPlayerCameraFrontVector(playerid, x, y, z); GetAngle(x, y, x2, y2, Anglez); SetPlayerFacingAngle(playerid, Anglez); SetPlayerVelocity(playerid, x*1.07, y*1.07, z*1.07); ApplyAnimation(playerid,"PARACHUTE","FALL_SkyDive_Accel",4.1,1,1,1,1,0); } else { SetPlayerVelocity(playerid, 0, 0, 0); ApplyAnimation(playerid,"FAT","FatIdle",4.1,0,1,1,1,0); } } return 1; } //------------------------------------------------------- stock GetAngle(Float:X, Float:Y, Float:CurrentX, Float:CurrentY, &Float:Angle) { Angle = atan2(Y-CurrentY, X-CurrentX); Angle = floatsub(Angle, 90.0); if(Angle < 0.0){ Angle = floatadd(Angle, 360.0); } } |
pawn Код:
public OnPlayerUpdate(playerid)
{
if(GetPVarInt(playerid, "Superman") == 1)
{
new Keys, ud, lr;
GetPlayerKeys(playerid,Keys,ud,lr);
if(Keys & KEY_SPRINT)
{
new Float:Anglez, Float:x, Float:y, Float:z, Float:x2, Float:y2, Float:z2;
GetPlayerPos(playerid, x2, y2, z2);
GetPlayerCameraPos(playerid, x, y, z);
GetAngleTo(x2, y2, x, y, Anglez);
SetPlayerFacingAngle(playerid, Anglez);
GetPlayerCameraFrontVector(playerid, x, y, z);
SetPlayerVelocity(playerid, x*1.07, y*1.07, z*1.09);
ApplyAnimation(playerid,"PARACHUTE","FALL_SkyDive_Accel",4.1,1,1,1,1,0);
} else {
SetPlayerVelocity(playerid, 0, 0, 0);
ApplyAnimation(playerid,"FAT","FatIdle",4.1,0,1,1,1,0);
}
}
return 1;
}