SA-MP Forums Archive
Question about a command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Question about a command (/showthread.php?tid=91933)



Question about a command - FreeSoul - 17.08.2009

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 !


Re: Question about a command - Eazy_Efolife - 17.08.2009

https://sampwiki.blast.hk/wiki/SetPlayerFacingAngle


Re: Question about a command - FreeSoul - 17.08.2009

That has nothing to do with what I asked


Re: Question about a command - Eazy_Efolife - 17.08.2009

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.


Re: Question about a command - FreeSoul - 17.08.2009

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


Re: Question about a command - Joe Staff - 17.08.2009

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.


Re: Question about a command - FreeSoul - 17.08.2009

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;
}




Re: Question about a command - Joe Staff - 17.08.2009

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.


Re: Question about a command - FreeSoul - 17.08.2009

I'm very confused right now...


Re: Question about a command - Zeex - 17.08.2009

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?