GOto with move function error

Started by Nihongo^, Nov 18, 2016, 03:10 PM

Previous topic - Next topic

Nihongo^

i am trying to create goto function which canceled teleport if player move but i got an error

Command

else if ( cmd == "goto" )   
{
try{
if( !text ) MessagePlayer( "[#40FF00][COMMAND] - [#F7FE2E]/goto <player/ID>", player );
else if( !player.IsSpawned ) MessagePlayer( "[#FF0000][ERROR] - [#F7FE2E]You haven't spawned.", player );
else
{   
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if( !plr ) MessagePlayer( "[#FF0000][ERROR] - [#F7FE2E]Unknown player/ID.", player );
else if( !plr.IsSpawned ) MessagePlayer( "[#FF0000][ERROR] - [#F7FE2E]The player you are trying to teleport has not spawned yet.", player );
else if( status[ plr.ID ].ngoto ) MessagePlayer( "[#FF0000][ERROR] - [#F7FE2E]The player you want to teleport to has nogoto on.", player );
else
{
MessagePlayer( "[#40FF00][COMMAND] - [#F7FE2E]You wont be Teleport if you move within 4 secs to prevent from death evade.", player );
NewTimer( "going", 300, 1, player.ID, plr.ID, player.Pos.x, player.Pos.y, player.Pos.z );
}
}
}
catch(e) print( "error goto: " + e)
}

Function


 function going( playerID, x, y, z )

{
local player = FindPlayer(playerID);
    if(player)
{

               local x1 = player.Pos.x;

               local y1 = player.Pos.y;

               local z1 = player.Pos.z;



      if( ( x==x1 ) && ( y==y1 ) && ( z==z1 ) ) PGoto( player );

      else MessagePlayer( "[#FF0000][ERROR] - [#F7FE2E]You have been moved so you haven't been healed.", player);

}

}

function PGoto( playerID, plrID )

local player = FindPlayer(playerID), plr = FindPlayer(plrID);
    if(player && plr)
{
         player.Pos = plr.Pos;

  MessagePlayer( "[#40FF00][COMMAND] - [#F7FE2E]Successfully teleported to " + plr + "." , player );
}
}

KAKAN

Remove the try catch thing and post the error line
oh no

Xmair

if( ( x==x1 ) && ( y==y1 ) && ( z==z1 ) ) PGoto( player );function PGoto( playerID, plrID )

Credits to Boystang!

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

MacTavish

simply use this :)

function going( playerID, plrID)

{
local player = FindPlayer(playerID), target=FindPlayer(plrID);
    if(player && target)
 {

player.Pos = Vector(target.Pos.x, target.Pos.y, target.Pos.z);
      else MessagePlayer( "[#FF0000][ERROR] - [#F7FE2E]You have been moved to the target", player);

}
else print("The player or target has left the server");
}


Replace timer with NewTimer( "going", 2000, 1, player.ID, plr.ID); duration changed from 300ms with 2000ms

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

Nihongo^