SA-MP Forums Archive
/Goto Question - 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: /Goto Question (/showthread.php?tid=117579)



/Goto Question - JoeDaDude - 31.12.2009

I have a /goto command in dcmd,
It works ingame and everything,
But i want it to check to see if the person typing the command,
Is trying to teleport to himself and if he is to tell him he cannot teleport to himself,
So if my id was 0, And i typed /goto 0, The server wud say: You cannot teleport to yourself,
Like that, So i was wondering if someone could help me,
My code:

pawn Код:
dcmd_goto(playerid, params[])
{
if (strlen(params))
{
new id = strval(params);
if (IsPlayerConnected(id))
{
if(IsPlayerAdmin(playerid))
{
new
Float:pPos[ 3 ];
GetPlayerPos(id, pPos[ 0 ], pPos[ 1 ], pPos[ 2 ] );
SetPlayerPos( playerid, pPos[ 0 ], pPos[ 1 ], pPos[ 2 ] );
SetPlayerInterior(playerid, GetPlayerInterior(id));
SendClientMessage(playerid, COLOR_WHITE, "You've been teleported to the player!");
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "You are not an Administrator");
}
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "Player not found!");
}
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/goto <playerid>\"");
}
return 1;
}
If someone could possibly edit that for me.


Re: /Goto Question - Norck - 31.12.2009

Try this:
Код:
dcmd_goto(playerid, params[])
{
if (strlen(params))
{
new id = strval(params);
if(playerid == id)//If typed ID is playerid
{
  SendClientMessage(playerid,0xFF0000AA,"You cannot teleport to yourself");//then player will receive this messsage
  return 1;
}
if (IsPlayerConnected(id))
{
if(IsPlayerAdmin(playerid))
{
new
Float:pPos[ 3 ];
GetPlayerPos(id, pPos[ 0 ], pPos[ 1 ], pPos[ 2 ] );
SetPlayerPos( playerid, pPos[ 0 ], pPos[ 1 ], pPos[ 2 ] );
SetPlayerInterior(playerid, GetPlayerInterior(id));
SendClientMessage(playerid, COLOR_WHITE, "You've been teleported to the player!");
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "You are not an Administrator");
}
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "Player not found!");
}
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/goto <playerid>\"");
}
return 1;
}