Jump to content

Need Help with my teleport-script


AlexWo

Recommended Posts

I made this script today but it's not working.

Client-Side:

teleporter = 
{ 
createMarker( 1742, -1944, 13.5, "cylinder", 1.5, 0, 255, 255) 
createMarker( 1745, -1944, 13.5, "cylinder", 1.5, 0, 255, 255) 
} 
  
  
local Teleports = { "LosSantos", "LasVenturas", "SanFierro" } 
  
  
  
addEventHandler ( "onClientResourceStart", resourceRoot, 
    function ( ) 
        for _, marker in ipairs ( teleporter ) do 
            addEventHandler ( "onClientMarkerHit", marker, onMarkerHit ) 
            addEventHandler ( "onClientMarkerLeave", marker, onMarkerLeave ) 
        end 
    end 
) 
     
  
  
function createTeleportGui ( ) 
     MainGui = guiCreateWindow (408,203,240,349,"Teleporter",false) 
     guiWindowSetSizable ( MainGui, false )  
     TeleportGrid = guiCreateGridList(14,32,180,256,false,MainGui) 
     guiGridListSetSelectionMode(TeleportGrid,2) 
     _teleports = guiGridListAddColumn(TeleportGrid,"Teleport",0.85) 
     Teleport = guiCreateButton(15,305,96,35,"Teleport",false,MainGui) 
     guiSetFont(Teleport,"clear-normal") 
     Leave = guiCreateButton(128,305,96,35,"Leave",false,MainGui) 
     guiSetFont(Leave,"clear-normal") 
    for index, teleport in ipairs(Teleports) do 
    local row = guiGridListAddRow (TeleportGrid) 
       guiGridListSetItemText ( TeleportGrid, row, _teleports, tostring(Teleports), false, false ) 
       end   
    end 
    
  
 function onMarkerHit(hitElement) 
    if hitElement == localPlayer then 
            createTeleportGui() 
            if MainGui then 
                guiSetVisible(MainGui,true) 
                showCursor(true) 
                guiSetInputEnabled(true) 
                setElementFrozen(localPlayer,true) 
            end 
        end 
    end 
end 
  
addEventHandler ( "onClientGUIClick", root, 
    function ( ) 
        if ( source == Teleport ) then 
            local row,col = guiGridListGetSelectedItem ( TeleportGrid ) 
            if ( row and col and row ~= -1 and col ~= -1 ) then 
                local teleportName = guiGridListGetItemText(TeleportGrid, row, 1) 
                if teleportName == "LosSantos" then 
                    triggerServerEvent("spawnLosSantos",localPlayer,teleportName) 
                elseif teleportName == "LasVenturas" then 
                    triggerServerEvent("spawnLasVenturas",localPlayer,teleportName) 
                elseif teleportName == "SanFierro" then 
                    triggerServerEvent("spawnSanFierro",localPlayer, teleportName) 
                end 
            else 
                outputChatBox("Error, Please select a Teleport of the list.",255,0,0) 
            end 
            elseif (source == Leave) then 
                triggerEvent("closeWindow", localPlayer ) 
        end 
end 
) 
  
addEventHandler("onClientGUIDoubleClick", root, 
function () 
        if ( source == TeleportGrid ) then 
                local row,col = guiGridListGetSelectedItem(TeleportGrid) 
            if (row and col and row ~= -1 and col ~= -1) then 
                local teleportName = guiGridListGetItemText(TeleportGrid, row, teleportName) 
                if teleportName == "LosSantos" then 
                    triggerServerEvent("spawnLosSantos",localPlayer,teleportName) 
                elseif teleportName == "LasVenturas" then 
                    triggerServerEvent("spawnLasVenturas",localPlayer, teleportName) 
                elseif teleportName == "SanFierro" then 
                    triggerServerEvent("spawnSanfierro",localPlayer, teleportName) 
                 
        end 
            end 
        end 
end 
) 
  
function onMarkerLeave ( leaveElement ) 
    if ( leaveElement == localPlayer ) then 
        triggerEvent("closeWindow", localPlayer ) 
    end 
end 
  
addEvent ( "closeWindow", true ) 
addEventHandler ( "closeWindow", root, 
    function ( ) 
        guiSetVisible ( MainGui, false ) 
        showCursor ( false ) 
        guiSetInputEnabled ( false ) 
        setElementFrozen ( localPlayer, false ) 
    end 
      
     
  
  

Server-Sider:

local x,y,z 
local LosSantos 
local LasVenturas 
local SanFierro 
  
addEvent("spawnLosSantos", true) 
addEventHandler("spawnLosSantos", root, 
function() 
    setElementPosition ( localPlayer, 1544, -1352, 329 ) 
    triggerClientEvent("closeWindow", root) 
end 
) 
  
addEvent("spawnLasVenturas", true) 
addEventHandler("spawnLasVenturas", root, 
function() 
  
    setElementPosition ( localPlayer, 1996, 1588, 26) 
    triggerClientEvent("closeWindow", root) 
end 
) 
  
addEvent("spawnSanFierro", true) 
addEventHandler("spawnSanFierro", root, 
function() 
   
    setElementPosition ( localPlayer, -1790, 567, 332) 
    triggerClientEvent("closeWindow", root) 
end 
) 
  

Maybe you will find a mistake in it...

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