Jump to content

Teleport window


DLmass

Recommended Posts

Posted

Hey guys!

local screenW, screenH = guiGetScreenSize() 
local marker = createMarker(1810.2548, -1293.1728, -3.0, "cylinder", 2.0, 250, 50,0, 150) 
  
window = guiCreateWindow((screenW - 243) / 2, (screenH - 467) / 2, 243, 467, "", false) 
guiWindowSetSizable(window, false) 
gridlist = guiCreateGridList(11, 21, 222, 436, false, window) 
guiGridListAddColumn(gridlist, "Elevator", 0.9) 
guiSetVisible (window, false) 
  
function open(hitPlayer) 
    if hitPlayer == localPlayer and not isPedInVehicle(hitPlayer) then 
    guiSetVisible (window, true) 
    showCursor(true) 
    local file = xmlLoadFile "Teleports.xml" 
    end 
end 
addEventHandler("onClientMarkerHit", marker, open) 
  
function addTeleports() 
    guiGridListClear( gridlist ) 
    if guiGetVisible(window) == true then 
        local file = xmlLoadFile "Teleports.xml" 
        if file then 
            for i,v in ipairs( xmlNodeGetChildren( file ) ) do 
                local name = xmlNodeGetAttribute( v,"name") 
                local row = guiGridListAddRow( gridlist ) 
                guiGridListSetItemText ( gridlist, row, 1, tostring(name), false, true ) 
            end 
        end 
    end 
end 
  
function teleport( ) 
    local row,col = guiGridListGetSelectedItem( source ) 
    if row and col and row ~= -1 and col ~= -1 then 
        local name = guiGridListGetItemText( source, row, 1 ) 
        local file = xmlLoadFile "Teleports.xml" 
        if file then 
            for i,v in ipairs( xmlNodeGetChildren( file ) ) do 
                local teleportName = xmlNodeGetAttribute( v,"name" ) 
                if teleportName == name then 
                    local poX = xmlNodeGetAttribute( v,"posX" ) 
                    local poY = xmlNodeGetAttribute( v,"posY" ) 
                    local poZ = xmlNodeGetAttribute( v,"posZ" ) 
                    setElementPosition( getPedOccupiedVehicle( localPlayer ) or localPlayer, tonumber( poX ), tonumber( poY ), tonumber( poZ + 2 ) ) 
                end 
            end 
        end 
    end 
end 
addEventHandler( "onClientGUIDoubleClick",gridlist, teleport, false) 

When the player enter the marker the GUI shows, but the xml with locations wont load. Can anyone help me?

Posted (edited)

change line 14:

addTeleports() 

change line 22:

local file = xmlLoadFile("Teleports.xml") 

change line 37:

local file = xmlLoadFile("Teleports.xml") 

Edited by Guest

Founder of Kutmode - http://kutmode.com | https://discord.gg/P3FXVnF

(Retired) Leading Developer of Grand Theft International

(Retired) Leading Developer of Full Theft Auto.

(Retired) Owner of SourceMod.

Posted (edited)
change line 14:
addTeleports() 

change line 22:

local file = xmlLoadFile("Teleports.xml") 

change line 37:

local file = xmlLoadFile("Teleports.xml") 

Remove line 14

Edited by Guest

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted
None of those are working, I've replaced everything you guys said. Still no success..

what's the problem? try this

local screenW, screenH = guiGetScreenSize() 
local marker = createMarker(1810.1166992188, -1271.3551025391, 13.6328125, "cylinder", 2.0, 250, 50,0, 150) 
  
window = guiCreateWindow((screenW - 243) / 2, (screenH - 467) / 2, 243, 467, "", false) 
guiWindowSetSizable(window, false) 
gridlist = guiCreateGridList(11, 21, 222, 436, false, window) 
guiGridListAddColumn(gridlist, "Elevator", 0.9) 
guiSetVisible (window, false) 
  
function open(hitPlayer) 
    if hitPlayer == localPlayer and not isPedInVehicle(hitPlayer) then 
    guiSetVisible (window, true) 
    showCursor(true) 
    addTeleports() 
    end 
end 
addEventHandler("onClientMarkerHit", marker, open) 
  
function addTeleports() 
    guiGridListClear( gridlist ) 
    if guiGetVisible(window) == true then 
        local file = xmlLoadFile ("Teleports.xml") 
          local meNodes = xmlNodeGetChildren(file) 
            for i,v in ipairs( meNodes ) do 
                local name = xmlNodeGetAttribute( v,"name") 
                local row = guiGridListAddRow( gridlist ) 
                guiGridListSetItemText ( gridlist, row, 1, tostring(name), false, true ) 
  
        end 
    end 
end 
  
function teleport( ) 
    local row,col = guiGridListGetSelectedItem( source ) 
    if row and col and row ~= -1 and col ~= -1 then 
        local name = guiGridListGetItemText( source, row, 1 ) 
        local file = xmlLoadFile ("Teleports.xml") 
        if file then 
            for i,v in ipairs( xmlNodeGetChildren( file ) ) do 
                local teleportName = xmlNodeGetAttribute( v,"name" ) 
                if teleportName == name then 
                    local poX = xmlNodeGetAttribute( v,"posX" ) 
                    local poY = xmlNodeGetAttribute( v,"posY" ) 
                    local poZ = xmlNodeGetAttribute( v,"posZ" ) 
                    setElementPosition( getPedOccupiedVehicle( localPlayer ) or localPlayer, tonumber( poX ), tonumber( poY ), tonumber( poZ + 2 ) ) 
                end 
            end 
        end 
    end 
end 
addEventHandler( "onClientGUIDoubleClick",gridlist, teleport, false) 

Team, MTA Scripters.

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