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
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.
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
Quote from: Mr_Motley on Mar 09, 2016, 05:14 AMQuote 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...
When i remove local player it becomes an error. If i keep the local it reads as unknown command, odd
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.
Awesome Thanks so Much, Extremely helpful.
I just did not like the typical goto player.name
^^^ Kudos Thanks :D
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;
}
}
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