Teleporting players ahead? -
Karan007 - 15.03.2015
Hey guys,
I want to teleport a player 2 centimetre infront of himself when he perform this command /test.
Yes, i'm using GetXYInFrontOfPlayer but when i perform the command /test after adding the function GetXYInFrontOfPlayer, it's going 5 metres infront of the player!
Please help me guys, you will be repped.
AW: Teleporting players ahead? -
Nero_3D - 15.03.2015
Show use GetXYInFrontOfPlayer and the line you use it and leave the last sentence away
Re: Teleporting players ahead? -
Karan007 - 16.03.2015
Here it is.
Код:
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));
}
//------------------------------------------------TELEPORTING TEST
CMD:test(playerid,params[])
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
GetXYInFrontOfPlayer(playerid, x, y, 5.0);
SetPlayerPos(playerid, x+5, y+5, z);
return 1;
}
Re: Teleporting players ahead? -
X337 - 16.03.2015
Change
Код:
GetXYInFrontOfPlayer(playerid, x, y, 5.0);
to:
Код:
GetXYInFrontOfPlayer(playerid, x, y, 2.0);
AW: Teleporting players ahead? -
Nero_3D - 16.03.2015
If you want 2 cm than replace the last number with "0.02" (m) but I don't think you will notice that
Re: Teleporting players ahead? -
Karan007 - 16.03.2015
Guys, sometimes when i'm facing north it's going south, why that?
AW: Re: Teleporting players ahead? -
Kaliber - 16.03.2015
Quote:
Originally Posted by karan007
Guys, sometimes when i'm facing north it's going south, why that?
|
Just write it like this:
Код:
CMD:test(playerid,params[])
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
GetXYInFrontOfPlayer(playerid, x, y, 5.0);
SetPlayerPos(playerid, x, y, z);
return 1;
}
Greekz
Re: Teleporting players ahead? -
Karan007 - 16.03.2015
Thanks !