require "lib.moonloader"
local FilePath = getWorkingDirectory().."/CoordsForTP.txt"
local FileRead
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
sampRegisterChatCommand("tp", cmdteleport)
while true do
wait(-1)
end
end
function cmdteleport()
if doesFileExist(FilePath) then
FileRead = io.open(FilePath, "r")
posX, posY, posZ = FileRead:match("x=(%d+),y=(%d+),z=(%d+)")
setCharCoordinates(PLAYER_PED, posX, posY, posZ)
sampAddChatMessage("Телепортировались на координаты - "..posX.." "..posY.." "..posZ, -1)
else
FileRead = io.open(FilePath, "w")
FilePath:write("x=100,y=30,z=100")
sampAddChatMessage("Отсутсвует файл с координатами, он был автоматически создан, запишите в него координаты", -1)
sampAddChatMessage("Координаты записываются в файл например - x=100,y=30,z=100", -1)
end
end