RandomTP
#11
[Image: errrr.png]

PHP Code:
function Initialize(Plugin)
    
Plugin:SetName("RandomTP")
    
Plugin:SetVersion(1)

    
cPluginManager.BindCommand("/rtp""randomTP.rtp"Randomtp" ~ Random Teleport");

    
LOG("Initialised " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
    return 
true
end

function Randomtp(SplitPlayer)
    if (
#Split ~= 1) then
        
Player:SendMessage("Usage: /rtp")
        return 
true
    
else
        
local X math.random(-20002000)
        
local Z math.random(-20002000)
        
local _Height
         
        local World 
Player:GetWorld()
        
World:ChunkStay({{math.floor(16), math.floor(16)}}, nil,  
            function()
                
_Height World:TryGetHeight(XZ)
            
end
        
)
        
Player:TeleportToCoords(XHeightZ)
        
Player:SendMessage(cChatColor.Yellow .. "Cords")
        
Player:SendMessage("X: " .. X)
        
Player:SendMessage("Y: " .. Height)
        
Player:SendMessage("Z: " .. Z)
    
end
    
return true
end 
Reply
Thanks given by:
#12
That's really weird. Could you add a "print(X, Height, Z)" before the TeleportToCoords line? And perhaps add "print(Height)" after the TryGetHeight function.
Reply
Thanks given by:
#13
[Image: errrrr.png]

before error is -1227 nil 1235

PHP Code:
function Initialize(Plugin)
    
Plugin:SetName("RandomTP")
    
Plugin:SetVersion(1)

    
cPluginManager.BindCommand("/rtp""randomTP.rtp"Randomtp" ~ Random Teleport");

    
LOG("Initialised " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
    return 
true
end

function Randomtp(SplitPlayer)
    if (
#Split ~= 1) then
        
Player:SendMessage("Usage: /rtp")
        return 
true
    
else
        
local X math.random(-20002000)
        
local Z math.random(-20002000)
        
local _Height
         
        local World 
Player:GetWorld()
        
World:ChunkStay({{math.floor(16), math.floor(16)}}, nil,  
            function()
                
_Height World:TryGetHeight(XZ)
                print(
XHeightZ)
            
end
        
)
        print(
XHeightZ)
        
Player:TeleportToCoords(XHeightZ)
        
Player:SendMessage(cChatColor.Yellow .. "Cords")
        
Player:SendMessage("X: " .. X)
        
Player:SendMessage("Y: " .. Height)
        
Player:SendMessage("Z: " .. Z)
    
end
    
return true
end 

Its a madness. Values are great, teleportation should work :/
Reply
Thanks given by:
#14
Yeah, really strange indeed. I'll try to reproduce the issue.
Reply
Thanks given by:
#15
Oh, I believe ChunkStay is async. Because of that the Height variable isn't filled when trying to teleport the player.
If you move the teleport/sendmessage code in the function where you get the height it should work properly.
Reply
Thanks given by:
#16
And don't forget to use

Code:
Player:SendMessageSuccess("Teleported to coordinates: " .. X .. etc.);

:)
Reply
Thanks given by:
#17
That's a matter of preference. I personally think they look awful, and I will never use them.
Reply
Thanks given by:
#18
Reply
Thanks given by:
#19
Reply
Thanks given by: NiLSPACE




Users browsing this thread: 4 Guest(s)