Jump to content

GUI Help


damien111

Recommended Posts

hey, im working on the beta ver. of my disk system, the very basics, but, i havent scripted in a while. I cant seem to find out whats wrong with this. I cant get it to disappear on start, then when you go into the marker, show up. Please help, Thanks!

server

  
  
disk = createPickup ( 1685.6552734375, 993.8076171875, 10.8203125, 3, 1277 ) 
  
function killPlayer() 
killPlayer(source) 
end 
addEvent("killPlayer", true) 
addEventHandler("killPlayer", root, joinSAPD) 
  
function showgui() 
triggerClientEvent(source,"createGUI",source) 
end 
addEventHandler("onPickupHit",disk,showgui) 
  

client

GUIEditor = { 
    gridlist = {}, 
    button = {}, 
    window = {}, 
} 
  
 GUIEditor.window[1] = guiCreateWindow(56, 55, 680, 284, "", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
  
        GUIEditor.button[1] = guiCreateButton(381, 46, 271, 58, "Kill Yourself!", false, GUIEditor.window[1]) 
        GUIEditor.button[2] = guiCreateButton(381, 115, 271, 58, "Repair Car", false, GUIEditor.window[1]) 
        GUIEditor.button[3] = guiCreateButton(381, 183, 271, 58, "Spawn Car", false, GUIEditor.window[1]) 
        GUIEditor.gridlist[1] = guiCreateGridList(37, 50, 316, 182, false, GUIEditor.window[1]) 
        guiGridListAddColumn(GUIEditor.gridlist[1], "Car NAme", 0.3) 
        guiGridListAddColumn(GUIEditor.gridlist[1], "Damage", 0.3) 
        guiGridListAddColumn(GUIEditor.gridlist[1], "Price To Repair", 0.3)     
function hideGUI ( ) 
guiSetVisible( GUIEditor.window[1] , false) 
end 
addEventHandler ( "onResourceStart", getRootElement(), hideGUI ) 
  
local diskmarker = createMarker( 1685.6552734375, 993.8076171875, 10.8203125, "Cylinder", 1.5, 0, 0, 255, 255) 
  
  
  
          
addEvent("createGUI",true) 
addEventHandler("createGUI",getRootElement(), 
function() 
                       guiSetVisible( GUIEditor.window[1] , true) 
                       showCursor(true) 
end 
) 
          
          
        function KillHim() 
             triggerServerEvent("killPlayer",localPlayer) 
             guiSetVisible(  GUIEditor.window[1] , false) 
             showCursor(false) 
        end 
        addEventHandler("onClientGUIClick", GUIEditor.button[1], KillHim, false) 

Link to comment

Well, that's because you used: "onResourceStart", that's a server side event.

You must add: guiSetVisible after:

GUIEditor.window[1] = guiCreateWindow(56, 55, 680, 284, "", false) 

Like this:

GUIEditor.window[1] = guiCreateWindow(56, 55, 680, 284, "", false) 
guiSetVisible ( GUIEditor.window[1], false ) 

And btw, this:

function killPlayer() 
killPlayer(source) 
end 
addEvent("killPlayer", true) 
addEventHandler("killPlayer", root, joinSAPD) 

Never call a function like a native one, unless you are going to replace it.

Link to comment
  • MTA Team

Using onPickupHit server-side may do some synchronization errors, experience tells, and it's a lot easier anyways.

Server-side

addEvent("killPlayer", true) 
addEventHandler("killPlayer", root, 
    function() 
        killPlayer(source) 
    end 
) 

Client-side

local disk = createPickup(1685.6552734375, 993.8076171875, 10.8203125, 3, 1277) 
  
addEventHandler("onClientPickupHit", disk, 
    function(hitElement, matchingDimension) 
        if getElementType(hitElement) == "player" and matchingDimension then 
            if not isElement(GUIEditor.window[1]) then 
                GUIEditor = { 
                    gridlist = {}, 
                    button = {}, 
                    window = {}, 
                } 
                GUIEditor.window[1] = guiCreateWindow(56, 55, 680, 284, "", false) 
                guiWindowSetSizable(GUIEditor.window[1], false) 
                GUIEditor.button[1] = guiCreateButton(381, 46, 271, 58, "Kill Yourself!", false, GUIEditor.window[1]) 
                GUIEditor.button[2] = guiCreateButton(381, 115, 271, 58, "Repair Car", false, GUIEditor.window[1]) 
                GUIEditor.button[3] = guiCreateButton(381, 183, 271, 58, "Spawn Car", false, GUIEditor.window[1]) 
                GUIEditor.gridlist[1] = guiCreateGridList(37, 50, 316, 182, false, GUIEditor.window[1]) 
                guiGridListAddColumn(GUIEditor.gridlist[1], "Car NAme", 0.3) 
                guiGridListAddColumn(GUIEditor.gridlist[1], "Damage", 0.3) 
                guiGridListAddColumn(GUIEditor.gridlist[1], "Price To Repair", 0.3) 
                 
                addEventHandler("onClientGUIClick", GUIEditor.button[1], 
                    function() 
                        triggerServerEvent("killPlayer", localPlayer) 
                        destroyElement(GUIEditor.window[1]) 
                        showCursor(false) 
                    end 
                ) 
                 
                showCursor(true) 
            else 
                guiBringToFront(GUIEditor.window[1]) 
            end 
        end 
    end 
) 

Link to comment
  • MTA Team

It should open for one player only. It's client-side, you can't open it to all players however you wanted to.

If you mean you want it to only show to an exact player name or team, then do..

getPlayerName 
getPlayerTeam 
getTeamName 

And such.

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