teleporting to another player / tele other player to me
#1

turns out the the code i made earlier doesnt work. i also have no idea how to put in the interiors ither if a player is in one.

can anyone plz script me a simple script to teleport to another player / also teleporting a player to me!

plz and thx!
Reply
#2

there are millions way to make a player teleport to you, but what way do you want?

a command, a public or stock ( function )?
or a timer?

you gotta be more specific;
Reply
#3

pawn Код:
GetPlayerInterior(playerid); - Returns the current interior of the player
SetPlayerInterior(playerid, interior); - Sets the player's interior to whatever you want
Also, remember to check virtual world and if the player is in a vehicle aswell.
Reply
#4

Bring Player To You
pawn Код:
dcmd_bp(playerid, params[])
{
  new idx, iString[255], strSend[128];
  iString = strtok(params, idx);
  if(!strlen(iString))
  {
    return SendClientMessage(playerid, 0xFF2B2BFF, ":ERR: Correct usage: /bp [id]");
  }
  else
  {
    new eid = strval(iString);
    if(IsPlayerConnected(eid) && eid != playerid)
    {
      new Float:px, Float:py, Float:pz, pi;
      GetPlayerPos(playerid, px, py, pz);
      pi = GetPlayerInterior(playerid);
      SetPlayerInterior(eid, pi);
      SetPlayerPos(eid, px+1, py+1, pz);
      format(strSend, 128, ":SNX: You've been brought to Id:[%d]", playerid);
      SendClientMessage(eid, 0xFFFF00AA, strSend);
      format(strSend, 128, ":SNX: You brought Id:[%d] to you.", eid);
      return SendClientMessage(playerid, 0xFFFF00AA, strSend);
    }
    else return SendClientMessage(playerid, 0xFF2B2BFF, ":ERR: Invalid Player ID");
  }
}
Change a few variables and you got teleport.
pawn Код:
dcmd_tp(playerid, params[])
{
  new idx, iString[255], strSend[128];
  iString = strtok(params, idx);
  if(!strlen(iString))
  {
    return SendClientMessage(playerid, 0xFF2B2BFF, ":ERR: Correct usage: /tp [id]");
  }
  else
  {
    new eid = strval(iString);
    if(IsPlayerConnected(eid) && eid != playerid)
    {
      new Float:px, Float:py, Float:pz, pi;
      GetPlayerPos(eid, px, py, pz);
      pi = GetPlayerInterior(eid);
      SetPlayerInterior(playerid, pi);
      SetPlayerPos(playerid, px+1, py+1, pz);
      format(strSend, 128, ":SNX: Id:[%d] has teleported to you.", playerid);
      SendClientMessage(eid, 0xFFFF00AA, strSend);
      format(strSend, 128, ":SNX: You teleported to Id:[%d].", eid);
      return SendClientMessage(playerid, 0xFFFF00AA, strSend);
    }
    else return SendClientMessage(playerid, 0xFF2B2BFF, ":ERR: Invalid Player ID");
  }
}
And I'm a 100% sure yopu could have found this if you looked for it cus so many did it in so many different ways i did that a year ago.
Reply
#5

thx, and majj: i jsut wanted a /cmd that ill add in for the admins only to use. ill try this code out thx!
Reply
#6

I believe you added "to" onto the commands you originally posted but did not adjust the rest of your code. Plus you had both named the same. I was just gonna edit my last post there and show you but you gave up to quick mate. My fault I thought you may have seen where you went wrong. NVM hope you sort it out.
Reply
#7

It's dcmd..
Reply
#8

Quote:
Originally Posted by MenaceX^
It's dcmd..
Yes it is but the code inside the command will be the same if its strcmp or dcmd. Isn't it?

And theres is no world checking in those commands but its a matter of adding a line or 2 of code.
Reply
#9

ShizNator is there a way you can make it so it starts with
Код:
	if (strcmp("/tele", cmdtext, true, 10) == 0)
	{
so i can atualy use it ina /cmd??
Reply
#10

Quote:
Originally Posted by Ethan1233
ShizNator is there a way you can make it so it starts with
Код:
	if (strcmp("/tele", cmdtext, true, 10) == 0)
	{
so i can atualy use it ina /cmd??
Like I was saying here
Quote:
Originally Posted by ShizNator
Quote:
Originally Posted by MenaceX^
It's dcmd..
Yes it is but the code inside the command will be the same if its strcmp or dcmd. Isn't it?

And theres is no world checking in those commands but its a matter of adding a line or 2 of code.
Lol dude you just did it.

Just grab the code in between the { } of the dcmd command
and put it in between you {} for the if(strcmp("/tele", cmdtext, true) == 0)
[edit] Sorry I forgot to change this line strtok(params, idx) to strtok(cmdtext, idx)
Fixed below.
pawn Код:
if(strcmp("/tele", cmdtext, true) == 0)
{
  new idx, iString[255], strSend[128];
  iString = strtok(cmdtext, idx);
  if(!strlen(iString))
  {
    return SendClientMessage(playerid, 0xFF2B2BFF, ":ERR: Correct usage: /tp [id]");
  }
  else
  {
    new eid = strval(iString);
    if(IsPlayerConnected(eid) && eid != playerid)
    {
      new Float:px, Float:py, Float:pz, pi;
      GetPlayerPos(eid, px, py, pz);
      pi = GetPlayerInterior(eid);
      SetPlayerInterior(playerid, pi);
      SetPlayerPos(playerid, px+1, py+1, pz);
      format(strSend, 128, ":SNX: Id:[%d] has teleported to you.", playerid);
      SendClientMessage(eid, 0xFFFF00AA, strSend);
      format(strSend, 128, ":SNX: You teleported to Id:[%d].", eid);
      return SendClientMessage(playerid, 0xFFFF00AA, strSend);
    }
    else return SendClientMessage(playerid, 0xFF2B2BFF, ":ERR: Invalid Player ID");
  }
}
And I don't think I need to say more or show you how the other one is done
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)