/goto [Player.ID]

Started by Mötley, Mar 09, 2016, 04:54 AM

Previous topic - Next topic

Mötley

Is it Possible to add a local to get the players name that you are going to in this command

  if (cmd == "g" || cmd == "g")
  {
    local id = FindPlayer(text.tointeger());
 
    if (!text) MessagePlayer("CMD /go [id]", player);
    else if (!id)
    {   
MessagePlayer("Player is not connected", player);
    }
    else
    {
        player.Pos = id.Pos;
    }

    return true;
  }
^ edited Messed up a ID check

Xmair

Do you mean.....
if ( cmd == "go" || cmd == "goto )
{
local plr;
if( text && IsNum( text ) ) plr = FindPlayer( text.tointeger() );
else if ( !text || !IsNum( text ) ) MessagePlayer("Text must be integer | /goto [ player.ID ]" , player );
else if  ( !plr ) MessagePlayer("This player is not connected!" , player );
else
{
player.Pos = plr.Pos;
MessagePlayer("Teleported to " + plr.Name + "." , player );
}
}
Untested cuz on mobile.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Mötley

Quote from: Xmair on Mar 09, 2016, 05:11 AMDo you mean.....
if ( cmd == "go" || cmd == "goto )
{
local plr;
if( text && IsNum( text ) ) plr = FindPlayer( text.tointeger() );
else if ( !text || !IsNum( text ) ) MessagePlayer("Text must be integer | /goto [ player.ID ]" , player );
else if  ( !plr ) MessagePlayer("This player is not connected!" , player );
else
{
player.Pos = plr.Pos;
MessagePlayer("Teleported to " + plr.Name + "." , player );
}
}
Untested cuz on mobile.

??? you did you script that on your mobile?
Testing right now i will edit this post

Xmair

Quote from: Mr_Motley on Mar 09, 2016, 05:14 AM
Quote from: Xmair on Mar 09, 2016, 05:11 AMDo you mean.....
if ( cmd == "go" || cmd == "goto )
{
local plr;
if( text && IsNum( text ) ) plr = FindPlayer( text.tointeger() );
else if ( !text || !IsNum( text ) ) MessagePlayer("Text must be integer | /goto [ player.ID ]" , player );
else if  ( !plr ) MessagePlayer("This player is not connected!" , player );
else
{
player.Pos = plr.Pos;
MessagePlayer("Teleported to " + plr.Name + "." , player );
}
}
Untested cuz on mobile.

??? you did you script that on your mobile?
Testing right now i will edit this post
Yes...

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Mötley

When i remove local player it becomes an error. If i keep the local it reads as unknown command, odd

Xmair

else if ( cmd == "go" || cmd == "goto" )
{
if ( !text ) MessagePlayer("/" + cmd + " [ ID ]" , player);
else if ( !IsNum( text ) ) MessagePlayer("Text must be an integer." , player);
else if ( !FindPlayer ( text.tointeger() ) ) MessagePlayer("Unknown player." , player);
else{
local plr = FindPlayer( text.tointeger() );
player.Pos = plr.Pos;
MessagePlayer("Teleported to " + plr.Name + "." , player);
}
}
Tested.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Mötley

Awesome Thanks so Much, Extremely helpful.

I just did not like the typical goto player.name

^^^ Kudos Thanks :D

KAKAN

function GetPlayer( plr )
{
    if ( plr )
    {
        if ( IsNum( plr ) )
        {
            plr = FindPlayer( plr.tointeger() );
            if ( plr ) return plr;
            else return null;
        }
        else
        {     
            plr = FindPlayer( plr );
            if ( plr ) return plr;
            else return null;
        }
    }
    else return null;
}
Got it from my old ADM script, this would help you even more. So, here's a simple command:
if( cmd == "goto" ){
if(!text) return PrivMessage( player, "Syntax Error - Use /" + cmd + " <player's name/ID>" ); //You can use break too, if you don't like returns.
local plr = GetPlayer( text );
if( !plr ) return PrivMessage( player, "Error - The specified player doesn't exist." );
else{
//Do stuff here.
PrivMessage( plr, player.Name + " has teleported to you." );
PrivMessage( player, "You've been teleported to " + plr.Name );
player.Pos = plr.Pos;
}
}
oh no

Mötley

Thanks a lot. I will use both as examples to write my own version as the command i listed is not the style i use. i modifyed it for others to understand..

Big thanks as this is added to the administration base. as well as to Players with Specialty accounts. ;D