Teleport to facing angle.
#1

I'm trying to make the command /ff which would teleport you like 10 meters to where you where looking at.
Let's say I was looking in front of me, and I would use /ff it would teleport me 10 meters in the direction I was looking at.
The thing is, I have no idea how to do so..
Reply
#2

PHP Code:
CMD:ff(playerid){
    new 
Float:xFloat:yFloat:zFloat:rxFloat:rzFloat:txFloat:tyFloat:tz;
    
GetPlayerPos(playerid,x,y,z);
    
GetPlayerCameraRotation(playerid,rx,rz);
    
GetPointInFront3D(x,y,z,rx,rz,10.0,tx,ty,tz);
    
SetPlayerPos(playerid,tx,ty,tz);
    return 
1;

Include:
3DTryg.inc
Reply
#3

Updated code, might work better.

pawn Code:
CMD:ff(playerid, params)
{
    new Float:fPX, Float:fPY, Float:fVX, Float:fVY, Float:object_x, Float:object_y, Float:player_x, Float:player_y, Float:player_z;
 
    const Float:fScale = 10.0;
 
    GetPlayerCameraPos(playerid, fPX, fPY, player_z); //Ignore player_z here
    GetPlayerCameraFrontVector(playerid, fVX, fVY, player_z); //Ignore player_z here
 
    object_x = fPX + floatmul(fVX, fScale);
    object_y = fPY + floatmul(fVY, fScale);
 
    GetPlayerPos(playerid, player_x, player_y, player_z);
    SetPlayerPos(playerid, object_x, object_y, player_z);
 
    return 1;
}
Won't work great if you're looking into the ground.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)