Jump to content

Client Side script not working


Recommended Posts

I have this dialog, and this happens:

-When I click a button, nothing happens and i cant close the dialog.

Heres my code:

function playerOptions(sourcePlayer) 
    createOptionDialog() 
end 
  
addCommandHandler("options", playerOptions) 
  
function guiButton1() 
    showCursor(false) 
    guiSetVisible(GUIEditorButton[1], false) 
end 
  
function guiButton2() 
    showCursor(false) 
    guiSetVisible(GUIEditorButton[2], false) 
    setElementHealth(localPlayer, 0) 
end 
  
function guiButton3() 
    showCursor(false) 
    guiSetVisible(GUIEditorButton[3], false) 
    spawnPlayer (localPlayer, 132.8504, 1936.7646, 19.2756) -- spawns player with random skin 
    fadeCamera (localPlayer, true) 
    setCameraTarget (localPlayer, source) 
end 
  
function guiButton4() 
    local pX, pY, pZ = getElementPosition(localPlayer)  
    showCursor(false) 
    guiSetVisible(GUIEditorButton[4], false) 
    createExplosion(pX, pY, pZ, 10) 
end 
  
function guiButton5() 
    local pX, pY, pZ = getElementPosition(localPlayer)  
    showCursor(false) 
    guiSetVisible(GUIEditorButton[5], false) 
    createFire(pX, pY, pZ, 10) 
end 
  
function guiButton6() 
    showCursor(false) 
    guiSetVisible(GUIEditorButton[6], false) 
    setTimer(setElementHealth, 10000, 1, localPlayer, 0) 
    outputChatBox("You have 10 seconds before you die!", localPlayer) 
end 
  
function guiButton7() 
    showCursor(false) 
    guiSetVisible(GUIEditorButton[7], false) 
    setTimer(spawnPlayer, 10000, 1, localPlayer, 132.8504, 1936.7646, 19.2756) 
    outputChatBox("10 seconds before you spawn!", localPlayer) 
end 
  
  
function createOptionDialog() 
    GUIEditor_Window = {} 
    GUIEditor_Button = {} 
    GUIEditor_Window[1] = guiCreateWindow(133,172,554,310,"Player Options",false) 
    GUIEditor_Button[1] = guiCreateButton(207,273,131,22,"Close",false,GUIEditor_Window[1]) 
    GUIEditor_Button[2] = guiCreateButton(68,78,169,26,"Kill",false,GUIEditor_Window[1]) 
    guiSetFont(GUIEditor_Button[2],"sa-header") 
    GUIEditor_Button[3] = guiCreateButton(65,124,177,27,"Spawn",false,GUIEditor_Window[1]) 
    guiSetFont(GUIEditor_Button[3],"sa-header") 
    GUIEditor_Button[4] = guiCreateButton(65,172,177,27,"Explode Yourself",false,GUIEditor_Window[1]) 
    guiSetFont(GUIEditor_Button[4],"sa-header") 
    GUIEditor_Button[5] = guiCreateButton(301,78,177,27,"Create Fire",false,GUIEditor_Window[1]) 
    guiSetFont(GUIEditor_Button[5],"sa-header") 
    GUIEditor_Button[6] = guiCreateButton(303,123,177,27,"Kill Timer",false,GUIEditor_Window[1]) 
    guiSetFont(GUIEditor_Button[6],"sa-header") 
    GUIEditor_Button[7] = guiCreateButton(306,171,177,27,"Spawn Timer",false,GUIEditor_Window[1]) 
    guiSetFont(GUIEditor_Button[7],"sa-header") 
    showCursor(true) 
    addEventHandler("onClientGUIClick", GUIEditor_Button[1], guiButton1, false) 
    addEventHandler("onClientGUIClick", GUIEditor_Button[2], guiButton2, false) 
    addEventHandler("onClientGUIClick", GUIEditor_Button[3], guiButton3, false) 
    addEventHandler("onClientGUIClick", GUIEditor_Button[4], guiButton4, false) 
    addEventHandler("onClientGUIClick", GUIEditor_Button[5], guiButton5, false) 
    addEventHandler("onClientGUIClick", GUIEditor_Button[6], guiButton6, false) 
    addEventHandler("onClientGUIClick", GUIEditor_Button[7], guiButton7, false) 
end 

Link to comment

Your button names is GUIEditor_Window but you are using GUIEditorButton in functions guiSetVisible.

and spawnPlayer in line 21 and 50 is Server-only function.

and outputChatBox in Client does not require argument visibleTo.

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