Hi! I've started learning to script LUA and i want to warp players TO me by command instead of admin panel but my currect script isn't working, some help would be appreciated.
addCommandHandler( "w2m",
function( sourcePlayer, command, targetPlayerName )
if targetPlayerName then -- We check if an target has been set
if getPlayerFromName(targetPlayerName) then -- We get the player element instead of the player name.
if not (targetPlayerName == getPlayerName(sourcePlayer)) then -- We make sure the player isn't trying to warp to himself
setElementPosition( targetPlayerName, 0, 0, 3 )
else
outputChatBox("[Error] You can't warp to yourself!", sourcePlayer, 255, 0, 0, false)
return false
end
else
outputChatBox("[Error] Player could not be found, maybe he/she is offline?", sourcePlayer, 255, 0, 0, false)
return false
end
else
outputChatBox("[Error] Please choose a target", sourcePlayer, 255, 0, 0, false)
return false
end
end
)
Error:
Thanks in advance!