Author Topic: Teleporting A Player To Another Player  (Read 1046 times)

How would I teleport a player to a specified player?

Try this:

Code: [Select]
function serverCmdMoveToPlayer(%client,%targetName)
{
%target = findClientByName(%targetName);
if(!isObject(%target))
return;

if(!isObject(%client.player) || !isObject(%target.player))
return;

%client.player.setTransform(%target.player.getTransform());
}

Try this:

Code: [Select]
function serverCmdMoveToPlayer(%client,%targetName)
{
%target = findClientByName(%targetName);
if(!isObject(%target))
return;

if(!isObject(%client.player) || !isObject(%target.player))
return;

%client.player.setTransform(%target.player.getTransform());
}
Should this work?
Code: [Select]
function serverCmdFetchTo(%client, %one, %two)
{
%targetOne = findClientByName(%one);

%targetTwo = findClientByName(%two);


if(!isObject(%targetOne).player) || (!isObject(%targetTwo.player))
{
return;
}

if(!isObject(%targetOne) || (!isObject(%targetTwo))
{
return;
}

%targetOne.player.setTransform(%targetTwo.player.getTransform());
}

That'll have syntax errors. Too many (s

Code: [Select]
function serverCmdFetchTo(%client, %one, %two)
{
%targetOne = findClientByName(%one);

%targetTwo = findClientByName(%two);


if(!isObject(%targetOne).player) || !isObject(%targetTwo.player))
{
return;
}

if(!isObject(%targetOne) || !isObject(%targetTwo))
{
return;
}

%targetOne.player.setTransform(%targetTwo.player.getTransform());
}

wouldnt it be:
Code: [Select]
if(!isObject(%targetOne.player) || !isObject(%targetTwo.player))
{
return;
}

Ahaha, so many random brackets tossed in that I got confused.

Yeah heed is right. In fact, that's the only part you actually need, you don't need the second one. (if(!isObject(%targetOne) || etc...)


$TPAdminOnly = true;
function serverCmdTP(%client,%one,%two)
{
   if($TPAdminOnly == true && %client.isAdmin == false)
      return;
   %one = findclientbyname(%one);
   %two = findcientbyname(%two);
   if(!isObject(%one) || !isObject(%one.player))
      return;
   if(!isObject(%two) || !isObject(%two.player))
      return;
   %one.player.setTransform(%two.player.getPosition());
}

I though this would be much neater, if you do one player at a time.
« Last Edit: February 14, 2012, 06:06:04 PM by Brian Smithers »

Why in the world would you even consider having a toggle for admin only on this?

You also need to do .getTransform() for the %two or else %one will always be facing north. (I think, at most I know it'll be facing 0 0 0)


$TPAdminOnly = true;
function serverCmdTP(%client,%one,%two)
{
   if($TPAdminOnly == true && %client.isAdmin == false)
      return;
   %one = findclientbyname(%one);
   %two = findcientbyname(%two);
   if(!isObject(%one) || !isObject(%one.player))
      return;
   if(!isObject(%two) || !isObject(%two.player))
      return;
   %one.setTransform(%two.getPosition());
}

I though this would be much neater, if you do one player at a time.

Brian
That was your 666th post


$TPAdminOnly = true;
function serverCmdTP(%client,%one,%two)
{
   if($TPAdminOnly == true && %client.isAdmin == false)
      return;
   %one = findclientbyname(%one);
   %two = findcientbyname(%two);
   if(!isObject(%one) || !isObject(%one.player))
      return;
   if(!isObject(%two) || !isObject(%two.player))
      return;
   %one.setTransform(%two.getPosition());
}

I though this would be much neater, if you do one player at a time.

I don't think that will work. Clients don't have a transform or position.

Code: [Select]
function serverCmdMoveToPlayer(%client,%targetNameA,%targetNameB)
{
%targetA = findClientByName(%targetNameA);
%targetB = findClientByName(%targetNameB);

if(!isObject(%targetA.player) || !isObject(%targetB.player))
return;

%targetA.player.setTransform(%targetB.player.getTransform());
}


Code: [Select]
function serverCmdTP( %cl, %nm1, %nm2 )
{
if ( !%cl.isAdmin )
{
return;
}

if ( !isObject( %cl1 = findClientByName( %nm1 ) ) )
{
return;
}

if ( !isObject( %cl2 = findClientByName( %nm2 ) ) )
{
return;
}

if ( !isObject( %pl1 = %cl1.player ) )
{
return;
}

if ( !isObject( %pl2 = %cl2.player ) )
{
return;
}

%pl1.setTransform( %pl2.getTransform() );
%pl1.teleportEffect();

messageClient( %cl1, '', "\c3" @ %cl.name @ " \c6has teleported you to \c3" @ %cl2.name @ "\c6." );
messageClient( %cl2, '', "\c3" @ %cl.name @ " \c6has teleported \c3" @ %cl1.name @ " \c6to you." );
}

Let's not confuse new scripters with a gigantic mess.

Hmm, Port reminded me to do an admin check but how do I put the teleport effect on a player?