Teleporting players ahead?
#1

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.
Reply
#2

Show use GetXYInFrontOfPlayer and the line you use it and leave the last sentence away
Reply
#3

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;
}
Reply
#4

Change
Код:
GetXYInFrontOfPlayer(playerid, x, y, 5.0);
to:
Код:
GetXYInFrontOfPlayer(playerid, x, y, 2.0);
Reply
#5

If you want 2 cm than replace the last number with "0.02" (m) but I don't think you will notice that
Reply
#6

Guys, sometimes when i'm facing north it's going south, why that?
Reply
#7

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
Reply
#8

Thanks !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)