Jump to content

[HELP] Wiki script not working


bradio10

Recommended Posts

I have made a city teleporter from the wiki. When I type t/teleportme (what the command is as shown in the wiki,) it just shows the cursor and nothing else AKA the GUI.

Here is the script and I followed the wiki as well as I can and I can't figure what I did wrong.

Here is the code:

function createTeleportWindow() 
local sWdith, sHeight = guiGetScreenSize() 
  
local Width,Height = 231,188 
local X = (sWidth/2) - (Width/2) 
local Y = (sHeight/2) - (Height/2) 
  
teleportWindow = guiCreateWindow(X,Y,Width,Height,"City Teleporter",false) 
guiWindowSetSizeable(teleportWindow,false) 
teleportLabel = guiCreateLabel(18.23,191,33,"click a button to teleport to that location",false,teleportWindow) 
guiLabelSetHorizontalAlign(teleportLabel,"center",true) 
teleportButtonLS = guiCreateButton(18,63,195,35,"Los Santos",false,teleportWindow) 
addEventHandler("onClientGUIClick", teleportButtonLS, teleportPlayer, false) 
teleportButtonSF = guiCreateButton(18,103,195,35,"San Fierro",false,teleportWindow) 
addEventHandler("onClientGUIClick", teleportButtonSF, teleportPlayer, false) 
teleportButtonLV = guiCreateButton(18,143,195,35,"Las Venturas",false,teleportWindow) 
addEventHandler("onClientGUIClick", teleportButtonLV, teleportPlayer, false) 
guiSetVisible(teleportWindow,false) 
end 
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), 
function() 
createTeleportWindow() 
end 
) 
  
function openTeleportWindow() 
guiSetVisible(TeleportWindow,true) 
showCursor(true,true) 
end 
addCommandHandler("teleportme",openTeleportWindow) 
  
function teleportPlayer(button,state) 
if button == "left" and state == "up" then 
if source == teleportButtonLS then 
triggerServerEvent("movePlayerToPosition",getLocalPlayer(),1479.6,-1612.8,14.0,0) 
ouputChatBox("Welcome to Los Santos!") 
elseif source == teleportButtonSF then 
tiggerServerEvent("movePlayerToPosition",getLocalPlayer(),-2265.5,534.0,35.0,270) 
outputChatBox("Welcome to San Fierro!") 
elseif source == teleportButtonLV then 
triggerServerEvent("movePlayerToPosition",getLocalPlayer(),2036.9,1545.2,10.8,270) 
outputChatBox("Welcome to Las Venturas!") 
end 
guiSetVisible(teleportWindow, false) 
showCursor(false) 
end 
end 

And here is the other code that you need aswell (serverside:)

function moveThePlayer(x,y,z) 
if x and y and z and rotation then 
local skin = getElementModel(client) 
spawnPlayer(client,x,y,z,rotation,skin) 
setCameraTarget(client,client) 
end 
end 
addEvent("movePlayerToPosition",true 
addEventHandler("movePlayerToPosition",root,moveThePlayer) 

Hope somone can help. Also all of the other wiki GUI tutorials I made aswell didn't work.

Thanks, regards, bradio10

Link to comment

Server side not needed.

-- Client Side --

local sWdith, sHeight = guiGetScreenSize()  
local Width,Height = 231,188 
local X = (sWdith/2) - (Width/2) 
local Y = (sHeight/2) - (Height/2) 
  
teleportWindow = guiCreateWindow(X,Y,Width,Height,"City Teleporter",false) 
guiWindowSetSizable(teleportWindow,false) 
guiSetVisible(teleportWindow,false) 
teleportLabel = guiCreateLabel(18.23,30,195,33,"click a button to teleport to that location",false,teleportWindow) 
guiLabelSetHorizontalAlign(teleportLabel,"center",true) 
teleportButtonLS = guiCreateButton(18,63,195,35,"Los Santos",false,teleportWindow) 
teleportButtonSF = guiCreateButton(18,103,195,35,"San Fierro",false,teleportWindow) 
teleportButtonLV = guiCreateButton(18,143,195,35,"Las Venturas",false,teleportWindow) 
  
function openTeleportWindow() 
guiSetVisible(teleportWindow,true) 
showCursor(true,true) 
end 
addCommandHandler("teleportme", openTeleportWindow) 
  
function teleportPlayer(button,state) 
   if button == "left" and state == "up" then 
      if source == teleportButtonLS then 
         setElementPosition(localPlayer, 1479.6, -1612.8, 14.0) 
         setPedRotation(localPlayer, 0) 
         outputChatBox("Welcome to Los Santos!") 
      elseif source == teleportButtonSF then 
         setElementPosition(localPlayer, -2265.5, 534.0, 35.0) 
         setPedRotation(localPlayer, 270) 
         outputChatBox("Welcome to San Fierro!") 
      elseif source == teleportButtonLV then 
         setElementPosition(localPlayer, 2036.9, 1545.2, 10.8 ) 
         setPedRotation(localPlayer, 270) 
         outputChatBox("Welcome to Las Venturas!") 
      end 
         guiSetVisible(teleportWindow, false) 
         showCursor(false) 
   end 
end 
addEventHandler("onClientGUIClick", teleportButtonLS, teleportPlayer, false) 
addEventHandler("onClientGUIClick", teleportButtonSF, teleportPlayer, false) 
addEventHandler("onClientGUIClick", teleportButtonLV, teleportPlayer, false) 

Link to comment

Commands

  • /teleportme - Toggles the teleporter GUI window

meta.xml

<meta> 
    <info name="Teleporter" /> 
    <script src="c_teleporter.lua" type="client" /> 
</meta> 

Client-side

local sWdith, sHeight = guiGetScreenSize() 
local Width, Height = 231, 188 
local X = (sWdith/2) - (Width/2) 
local Y = (sHeight/2) - (Height/2) 
  
addCommandHandler("teleportme", 
    function(cmd) 
        if not isElement(teleportWindow) then 
            teleportWindow = guiCreateWindow(X, Y, Width, Height, "City Teleporter", false) 
            guiWindowSetSizable(teleportWindow, false) 
            showCursor(true) 
             
            teleportLabel = guiCreateLabel(18.23, 30, 195, 33, "click a button to teleport to that location", false, teleportWindow) 
            guiLabelSetHorizontalAlign(teleportLabel, "center", true) 
             
            teleportButtonLS = guiCreateButton(18, 63, 195, 35, "Los Santos", false, teleportWindow) 
            teleportButtonSF = guiCreateButton(18, 103, 195, 35, "San Fierro", false, teleportWindow) 
            teleportButtonLV = guiCreateButton(18, 143, 195, 35, "Las Venturas", false, teleportWindow) 
             
            addEventHandler("onClientGUIClick", teleportButtonLS, teleportPlayer, false) 
            addEventHandler("onClientGUIClick", teleportButtonSF, teleportPlayer, false) 
            addEventHandler("onClientGUIClick", teleportButtonLV, teleportPlayer, false) 
        else 
            destroyElement(teleportWindow) 
            showCursor(false) 
        end 
    end 
) 
  
function teleportPlayer(button, state) 
    if button == "left" and state == "down" then 
        if source == teleportButtonLS then 
            setElementPosition(localPlayer, 1479.6, -1612.8, 14.0) 
            setPedRotation(localPlayer, 0) 
            outputChatBox("Welcome to Los Santos!") 
        elseif source == teleportButtonSF then 
            setElementPosition(localPlayer, -2265.5, 534.0, 35.0) 
            setPedRotation(localPlayer, 270) 
            outputChatBox("Welcome to San Fierro!") 
        elseif source == teleportButtonLV then 
            setElementPosition(localPlayer, 2036.9, 1545.2, 10.8 ) 
            setPedRotation(localPlayer, 270) 
            outputChatBox("Welcome to Las Venturas!") 
        end 
        destroyElement(teleportWindow) 
        showCursor(false) 
    end 
end 

Link to comment

:D

Commands

  • /teleportme - Toggles the teleporter GUI window

meta.xml

<meta> 
    <info name="Teleporter" /> 
    <script src="c_teleporter.lua" type="client" /> 
</meta> 

Client-side

local sWdith, sHeight = guiGetScreenSize() 
local Width, Height = 231, 188 
local X = (sWdith/2) - (Width/2) 
local Y = (sHeight/2) - (Height/2) 
  
addCommandHandler("teleportme", 
    function(cmd) 
        if not isElement(teleportWindow) then 
            teleportWindow = guiCreateWindow(X, Y, Width, Height, "City Teleporter", false) 
            guiWindowSetSizable(teleportWindow, false) 
            showCursor(true) 
             
            teleportLabel = guiCreateLabel(18.23, 30, 195, 33, "click a button to teleport to that location", false, teleportWindow) 
            guiLabelSetHorizontalAlign(teleportLabel, "center", true) 
             
            teleportButtonLS = guiCreateButton(18, 63, 195, 35, "Los Santos", false, teleportWindow) 
            teleportButtonSF = guiCreateButton(18, 103, 195, 35, "San Fierro", false, teleportWindow) 
            teleportButtonLV = guiCreateButton(18, 143, 195, 35, "Las Venturas", false, teleportWindow) 
             
            addEventHandler("onClientGUIClick", teleportButtonLS, teleportPlayer, false) 
            addEventHandler("onClientGUIClick", teleportButtonSF, teleportPlayer, false) 
            addEventHandler("onClientGUIClick", teleportButtonLV, teleportPlayer, false) 
        else 
            destroyElement(teleportWindow) 
            showCursor(false) 
        end 
    end 
) 
  
function teleportPlayer(button, state) 
    if button == "left" and state == "down" then 
        if source == teleportButtonLS then 
            setElementPosition(localPlayer, 1479.6, -1612.8, 14.0) 
            setPedRotation(localPlayer, 0) 
            outputChatBox("Welcome to Los Santos!") 
        elseif source == teleportButtonSF then 
            setElementPosition(localPlayer, -2265.5, 534.0, 35.0) 
            setPedRotation(localPlayer, 270) 
            outputChatBox("Welcome to San Fierro!") 
        elseif source == teleportButtonLV then 
            setElementPosition(localPlayer, 2036.9, 1545.2, 10.8 ) 
            setPedRotation(localPlayer, 270) 
            outputChatBox("Welcome to Las Venturas!") 
        end 
        destroyElement(teleportWindow) 
        showCursor(false) 
    end 
end 

Ok, thanks, but that didn't work either.

I am not sure if I am doing somthing wrong but none of the wiki scripts have worked.

Only the scripts I have downloaded from the community page have worked.

I must be doing somthing wrong then

EDIT: Never mind, it worked. I am a idiot, I still had the numbers in the script that were copyed when I pasted it from here. :D

Anyway thx man. The only thing is, it doesn't teleport me anywhere, it just stays there and nothing happens

Link to comment
Server side not needed.

-- Client Side --

local sWdith, sHeight = guiGetScreenSize()  
local Width,Height = 231,188 
local X = (sWdith/2) - (Width/2) 
local Y = (sHeight/2) - (Height/2) 
  
teleportWindow = guiCreateWindow(X,Y,Width,Height,"City Teleporter",false) 
guiWindowSetSizable(teleportWindow,false) 
guiSetVisible(teleportWindow,false) 
teleportLabel = guiCreateLabel(18.23,30,195,33,"click a button to teleport to that location",false,teleportWindow) 
guiLabelSetHorizontalAlign(teleportLabel,"center",true) 
teleportButtonLS = guiCreateButton(18,63,195,35,"Los Santos",false,teleportWindow) 
teleportButtonSF = guiCreateButton(18,103,195,35,"San Fierro",false,teleportWindow) 
teleportButtonLV = guiCreateButton(18,143,195,35,"Las Venturas",false,teleportWindow) 
  
function openTeleportWindow() 
guiSetVisible(teleportWindow,true) 
showCursor(true,true) 
end 
addCommandHandler("teleportme", openTeleportWindow) 
  
function teleportPlayer(button,state) 
   if button == "left" and state == "up" then 
      if source == teleportButtonLS then 
         setElementPosition(localPlayer, 1479.6, -1612.8, 14.0) 
         setPedRotation(localPlayer, 0) 
         outputChatBox("Welcome to Los Santos!") 
      elseif source == teleportButtonSF then 
         setElementPosition(localPlayer, -2265.5, 534.0, 35.0) 
         setPedRotation(localPlayer, 270) 
         outputChatBox("Welcome to San Fierro!") 
      elseif source == teleportButtonLV then 
         setElementPosition(localPlayer, 2036.9, 1545.2, 10.8 ) 
         setPedRotation(localPlayer, 270) 
         outputChatBox("Welcome to Las Venturas!") 
      end 
         guiSetVisible(teleportWindow, false) 
         showCursor(false) 
   end 
end 
addEventHandler("onClientGUIClick", teleportButtonLS, teleportPlayer, false) 
addEventHandler("onClientGUIClick", teleportButtonSF, teleportPlayer, false) 
addEventHandler("onClientGUIClick", teleportButtonLV, teleportPlayer, false) 

Ok thanks to all the people. This script was the one that teleported me and all I had to do was to fix the numbers on the scripts and now I know what I did worng. I put the addEventHandlers for the buttons in the worng place. Thanks guys.

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...