Jump to content

guiCreateEdit Teleport [Solved]


Recommended Posts

Hi.

I have made a small script where I get the players position, and another script where I can set a new position to spawn/move the player. I get no errors and everything seems to be working fine, but the player is ALWAYS spawned at the same location, no matter what I write in my X,Y,Z guiCreateEdit.

Client side: http://pastebin.com/m0ww1KR6

Server side: http://pastebin.com/LY4rFVyx

Anyone got an idea about what I am doing wrong? :?

Ty :)

Edited by Guest
Link to comment

-- Client side --

-- Creates the admin window -- 
function createAdminControlWindow() 
    showCursor(true) 
    local X = 0.375 
    local Y = 0.375 
    local Width = 0.55 
    local Height = 0.55 
    wdwAdminControl = guiCreateWindow(X, Y, Width, Height, "Admin Control Window", true) 
     
    X = 0.0800 
    Y = 0.10 
    Width = 0.15 
    Height = 0.08 
    guiCreateLabel(X, Y, Width, Height, "Player Options:", true, wdwAdminControl) 
     
    -- Find Player Position -- 
    X = 0.750 
    Y = 0.10 
    playerPositionButton = guiCreateButton(X, Y, Width, Height, "Get Player Pos", true, wdwAdminControl) 
    addEventHandler("onClientGUIClick", playerPositionButton, playerPositionFunction, false) 
    Y = 0.20 
    guiCreateLabel(X, Y, Width, Height, "X: ", true, wdwAdminControl) 
    Y = 0.26 
    guiCreateLabel(X, Y, Width, Height, "Y: ", true, wdwAdminControl) 
    Y = 0.32 
    guiCreateLabel(X, Y, Width, Height, "Z: ", true, wdwAdminControl) 
    X = 0.800 
    Y = 0.20 
    pX = guiCreateLabel(X, Y, Width, Height, "Pos", true, wdwAdminControl) 
    Y = 0.26 
    pY = guiCreateLabel(X, Y, Width, Height, "Pos", true, wdwAdminControl) 
    Y = 0.32 
    pZ = guiCreateLabel(X, Y, Width, Height, "Pos", true, wdwAdminControl) 
     
    -- Set new Player Position -- 
    X = 0.750 
    Y = 0.42 
    setPlayerPositionButton = guiCreateButton(X, Y, Width, Height, "Set New Pos", true, wdwAdminControl) 
    addEventHandler("onClientGUIClick", setPlayerPositionButton, setPlayerPositionFunction, false) 
    Y = 0.52 
    guiCreateLabel(X, Y, Width, Height, "X: ", true, wdwAdminControl) 
    Y = 0.58 
    guiCreateLabel(X, Y, Width, Height, "Y: ", true, wdwAdminControl) 
    Y = 0.64 
    guiCreateLabel(X, Y, Width, Height, "Z: ", true, wdwAdminControl) 
    X = 0.800 
    Y = 0.52 
    Height = 0.05 
    npX = guiCreateEdit(X, Y, Width, Height, "", true, wdwAdminControl) 
    Y = 0.58 
    npY = guiCreateEdit(X, Y, Width, Height, "", true, wdwAdminControl) 
    Y = 0.64 
    npZ = guiCreateEdit(X, Y, Width, Height, "", true, wdwAdminControl) 
     
end 
  
-- Get Player X,Y,Z, Position -- 
function playerPositionFunction(thePlayer) 
    local x,y,z = getElementPosition(getLocalPlayer()) 
        guiSetText (pX, x) 
        guiSetText (pY, y) 
        guiSetText (pZ, z) 
        guiSetText (npX, x) 
        guiSetText (npY, y) 
        guiSetText (npZ, z) 
end 
  
-- Set New Player X,Y,Z Position -- 
function setPlayerPositionFunction( ) 
        local npX = guiGetText (npX) 
        local npY = guiGetText (npY) 
    local npZ = guiGetText (npZ) 
    triggerServerEvent("movePlayerToPosition",getLocalPlayer(), npX, npY, npZ) 
end 
  
function closeAdminControlWindow() 
    guiSetVisible(wdwAdminControl, false) 
    showCursor(false) 
end 
  
  
addCommandHandler("aO", createAdminControlWindow) 
addCommandHandler("aC", closeAdminControlWindow) 

-- Server side --

-- Spawn Player on join -- 
function joinHandler( theplayer ) 
    local x = 1959.55 
    local y = -1714.46 
    local z = 18 
    spawnPlayer(source, x, y, z) 
    fadeCamera(source, true) 
    setCameraTarget(source, source) 
    outputChatBox("#FFFF66Welcome to the server", source , 255, 0, 0, true)  -- I dont think you wanna output Welcome to the server for all players ? 
end 
  
-- Get Player X,Y,Z positions with /myPos command -- 
function getPlayerPosition(thePlayer, command) 
local x,y,z = getElementPosition(thePlayer) 
    outputChatBox("#FF0000--- Your X, Y, Z positions are: ---", thePlayer, 255, 0, 0, true)  -- Same thing here? 
    outputChatBox("X:  " .. x) 
    outputChatBox("Y:  " .. y) 
    outputChatBox("Z:  " .. z) 
end 
  
function moveThePlayer(npX,npY,npZ) 
        spawnPlayer(source,npX,npY,npZ) 
        setCameraTarget(source,source) 
end 
  
addEventHandler("onPlayerJoin", getRootElement(), joinHandler) 
addCommandHandler("myPos", getPlayerPosition) 
addEvent("movePlayerToPosition",true) 
addEventHandler("movePlayerToPosition",getRootElement(),moveThePlayer) 

Maybe works now ?

EDIT: Jaysyds1, i think he's not so stupit that he maked that code, and now he cant edit the x,y,z cordinates in server side, which he have added by heself :roll:

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...