Question about a command
#1

Ok,so I have the following command

Quote:

if(strcmp(cmd, "/stp", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if (PlayerInfo[playerid][pAdmin] >= 1337)
{
GetPlayerPos(playerid, rx, ry, rz);
if (IsPlayerConnected(playerid))
{
SetPlayerPos(playerid,rx+40, ry, rz+5);
SendClientMessage(playerid,COLOR_GREY," You just did a short jump !");
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, " you are not authorized to use that command!");
}
}
return 1;
}

As you may see,the players it's tped 40 meters away from his X location.But I would like him to be TPed 40 meters away from the location where he is facing(front)

Anybody knows if that is possible? Thanks !
Reply
#2

https://sampwiki.blast.hk/wiki/SetPlayerFacingAngle
Reply
#3

That has nothing to do with what I asked
Reply
#4

Quote:
Originally Posted by FreeSoul
That has nothing to do with what I asked
where he is facing(front)

Yes it does, when you do the setPlayerFaceingAngle, you can make him faceing Front.
Reply
#5

I want him to be TPed 40 meters away in the direction he is looking at.I hope you understand now
Reply
#6

GetXYInFrontOfPlayer is a very common function, I think it's in MIC.inc but I'm not sure, as I never use includes. Search anyway.
Reply
#7

Quote:
Originally Posted by Joe Staff
GetXYInFrontOfPlayer is a very common function, I think it's in MIC.inc but I'm not sure, as I never use includes. Search anyway.
I tried using it,here is my code,but same result

Quote:

if(strcmp(cmd, "/stp", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if (PlayerInfo[playerid][pAdmin] >= 1337)
{
GetXYInFrontOfPlayer(playerid, rx, ry, rz);
if (IsPlayerConnected(playerid))
{
SetPlayerPos(playerid,rx+40, ry, rz+5);
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, " you are not authorized to use that command!");
}
}
return 1;
}

Reply
#8

I don't believe that to be the proper usage of that function. Also note that you're still modifying the coordinates in SetPlayerPosition when you shouldn't need to.
Reply
#9

I'm very confused right now...
Reply
#10

you need calculate position where to TP using cosinus and sinus of facing angle, so try this:
pawn Код:
if(strcmp(cmd, "/stp", true) == 0)
{
   if (PlayerInfo[playerid][pAdmin] >= 1337)
   {
       new Float:px, Float:py, Float:pz, Float:angle;
       GetPlayerPos(playerid, px, py, pz);
       GetPlayerFacingAngle(playerid, angle);
       SetPlayerPos(playerid, x+40*floatcos(angle), y+40*floatsin(angle), pz+40);
   }
   else
   {
       SendClientMessage(playerid, COLOR_GRAD1, "  you are not authorized to use that command!");
   }
   return 1;
}
Why do you check whether player connected or not? Not connected player may not send command, doesn't he?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)