AGENT_STEELMEAT Posted February 24, 2011 Share Posted February 24, 2011 I have a client-side script that brings up a GUI to select a spawn point and show a MOTD. After that player clicks a button, the server spawns the player, then triggers the client event to clean up the GUI and such. Everything is working other that the GUI refusing to hide. Any ideas? function initiateSpawn() --after player login , this is called addEventHandler("onClientRender", getRootElement(), spawnTitle) --add the MOTD createTeleportWindow() -- add the teleport menu end addEvent("startSpawn", true) -- event that is called by the login addEventHandler("startSpawn", getLocalPlayer(), initiateSpawn) function createTeleportWindow() -- create the spawn menu selectMenu = guiCreateWindow(0, 0.75, 1, 0.25, "Select a City to start!", true) buttonLS = guiCreateButton(0.125, 0.25, 0.25, 0.5, "Los Santos", true, selectMenu) buttonSF = guiCreateButton(0.375, 0.25, 0.25, 0.5, "San Fierro", true, selectMenu) buttonLV = guiCreateButton(0.625, 0.25, 0.25, 0.5, "Las Venturas", true, selectMenu) addEventHandler("onClientGUIClick", root, handleSpawn) showCursor(true) end function handleSpawn(button,state) --handler that is called by the spawn menu if button == "left" and state == "up" then if source == buttonLS then removeEventHandler("onClientRender", getRootElement(), spawnTitle) guiSetVisible(selectMenu, false) triggerServerEvent( "spawnMe", getLocalPlayer(), 1) elseif source == buttonSF then removeEventHandler("onClientRender", getRootElement(), spawnTitle) guiSetVisible(selectMenu, false) triggerServerEvent( "spawnMe", getLocalPlayer(), 2) elseif source == buttonLV then removeEventHandler("onClientRender", getRootElement(), spawnTitle) guiSetVisible(selectMenu, false) triggerServerEvent( "spawnMe", getLocalPlayer(), 3) end end end function spawnTitle() -- a MOTD using dxDraw (this works fine), based on wiki example local screenWidth, screenHeight = guiGetScreenSize() local MOTDText = [[ Welcome to ------! Latest news: - New GUIs are complete and look a lot nicer than the old ones. - Fixed the webadmin stuff for easy administration (by me -- s:P --> ). New features will be coming as I have time to add them. Meanwhile, I have decided to enable the freeroam GUI for you convenience. Remember that this is a TEMPORARY luxury! Thank you all for your continued patience while we continue development. ------ ]] local x,y = guiGetScreenSize() -- Get players resolution. dxDrawText( "Read the MOTD, or select a city to spawn in!", screenWidth/10, screenHeight/10, screenWidth, screenHeight, tocolor ( 0, 255, 255, 255 ), 1.5, "pricedown" ) dxDrawRectangle ( x/4, y/4, screenWidth/2, screenHeight/2, tocolor ( 0, 0, 0, 175 ) ) -- Create our black transparent MOTD background Rectangle. dxDrawText ( "Message of the Day:", x/3.5, y/3.6, x, y, tocolor ( 255, 255, 255, 255 ), 1, "bankgothic" ) -- Create Welcome title. dxDrawLine ( x/3.59, y/3.275, x/1.348, y/3.275, tocolor ( 0, 0, 255, 255 ), 2 ) -- Create underline shadow. dxDrawText ( MOTDText, x/3.6, y/3, x, y, tocolor ( 255, 255, 255, 255 ), 1, "clear" ) end function startNormalPlay() showPlayerHudComponent("ammo", true) showPlayerHudComponent("area_name", true) showPlayerHudComponent("armour", true) showPlayerHudComponent("breath", true) showPlayerHudComponent("clock", true) showPlayerHudComponent("health", true) showPlayerHudComponent("money", true) showPlayerHudComponent("radar", true) showPlayerHudComponent("vehicle_name", true) showPlayerHudComponent("weapon", true) setCameraTarget(getLocalPlayer()) showChat(true) showCursor ( false ) guiSetVisible(selectMenu, false) outputChatBox("test") end addEvent("readyToPlay", true) addEventHandler("readyToPlay", getRootElement(), startNormalPlay) Link to comment
Castillo Posted February 24, 2011 Share Posted February 24, 2011 local selectMenu function initiateSpawn() --after player login , this is called addEventHandler("onClientRender", getRootElement(), spawnTitle) --add the MOTD createTeleportWindow() -- add the teleport menu end addEvent("startSpawn", true) -- event that is called by the login addEventHandler("startSpawn", getLocalPlayer(), initiateSpawn) function createTeleportWindow() -- create the spawn menu selectMenu = guiCreateWindow(0, 0.75, 1, 0.25, "Select a City to start!", true) buttonLS = guiCreateButton(0.125, 0.25, 0.25, 0.5, "Los Santos", true, selectMenu) buttonSF = guiCreateButton(0.375, 0.25, 0.25, 0.5, "San Fierro", true, selectMenu) buttonLV = guiCreateButton(0.625, 0.25, 0.25, 0.5, "Las Venturas", true, selectMenu) addEventHandler("onClientGUIClick", root, handleSpawn) showCursor(true) end function handleSpawn(button,state) --handler that is called by the spawn menu if button == "left" and state == "up" then if source == buttonLS then removeEventHandler("onClientRender", getRootElement(), spawnTitle) guiSetVisible(selectMenu, false) triggerServerEvent( "spawnMe", getLocalPlayer(), 1) elseif source == buttonSF then removeEventHandler("onClientRender", getRootElement(), spawnTitle) guiSetVisible(selectMenu, false) triggerServerEvent( "spawnMe", getLocalPlayer(), 2) elseif source == buttonLV then removeEventHandler("onClientRender", getRootElement(), spawnTitle) guiSetVisible(selectMenu, false) triggerServerEvent( "spawnMe", getLocalPlayer(), 3) end end end function spawnTitle() -- a MOTD using dxDraw (this works fine), based on wiki example local screenWidth, screenHeight = guiGetScreenSize() local MOTDText = [[ Welcome to ------! Latest news: - New GUIs are complete and look a lot nicer than the old ones. - Fixed the webadmin stuff for easy administration (by me -- s:P --> ). New features will be coming as I have time to add them. Meanwhile, I have decided to enable the freeroam GUI for you convenience. Remember that this is a TEMPORARY luxury! Thank you all for your continued patience while we continue development. ------ ]] local x,y = guiGetScreenSize() -- Get players resolution. dxDrawText( "Read the MOTD, or select a city to spawn in!", screenWidth/10, screenHeight/10, screenWidth, screenHeight, tocolor ( 0, 255, 255, 255 ), 1.5, "pricedown" ) dxDrawRectangle ( x/4, y/4, screenWidth/2, screenHeight/2, tocolor ( 0, 0, 0, 175 ) ) -- Create our black transparent MOTD background Rectangle. dxDrawText ( "Message of the Day:", x/3.5, y/3.6, x, y, tocolor ( 255, 255, 255, 255 ), 1, "bankgothic" ) -- Create Welcome title. dxDrawLine ( x/3.59, y/3.275, x/1.348, y/3.275, tocolor ( 0, 0, 255, 255 ), 2 ) -- Create underline shadow. dxDrawText ( MOTDText, x/3.6, y/3, x, y, tocolor ( 255, 255, 255, 255 ), 1, "clear" ) end function startNormalPlay() showPlayerHudComponent("ammo", true) showPlayerHudComponent("area_name", true) showPlayerHudComponent("armour", true) showPlayerHudComponent("breath", true) showPlayerHudComponent("clock", true) showPlayerHudComponent("health", true) showPlayerHudComponent("money", true) showPlayerHudComponent("radar", true) showPlayerHudComponent("vehicle_name", true) showPlayerHudComponent("weapon", true) setCameraTarget(getLocalPlayer()) showChat(true) showCursor ( false ) guiSetVisible(selectMenu, false) outputChatBox("test") end addEvent("readyToPlay", true) addEventHandler("readyToPlay", getRootElement(), startNormalPlay) Try that, i'm not sure if will work. Link to comment
AGENT_STEELMEAT Posted February 24, 2011 Author Share Posted February 24, 2011 Did not work. Oddly enough, I tried on a different computer and the GUI hides just fine. This is confusing. Link to comment
Dev Posted February 25, 2011 Share Posted February 25, 2011 Try this, I believe the reason behind the script not working is because you're calling a function which is below the eventHandler, try this, I am pretty sure it'll work. function spawnTitle() -- a MOTD using dxDraw (this works fine), based on wiki example local screenWidth, screenHeight = guiGetScreenSize() local MOTDText = [[ Welcome to ------! Latest news: - New GUIs are complete and look a lot nicer than the old ones. - Fixed the webadmin stuff for easy administration (by me <!-- s:P --><img src=\"{SMILIES_PATH}/icon_razz.gif\" alt=\":P\" title=\"Razz\" /><!-- s:P --> ). New features will be coming as I have time to add them. Meanwhile, I have decided to enable the freeroam GUI for you convenience. Remember that this is a TEMPORARY luxury! Thank you all for your continued patience while we continue development. ------ ]] local x,y = guiGetScreenSize() -- Get players resolution. dxDrawText( "Read the MOTD, or select a city to spawn in!", screenWidth/10, screenHeight/10, screenWidth, screenHeight, tocolor ( 0, 255, 255, 255 ), 1.5, "pricedown" ) dxDrawRectangle ( x/4, y/4, screenWidth/2, screenHeight/2, tocolor ( 0, 0, 0, 175 ) ) -- Create our black transparent MOTD background Rectangle. dxDrawText ( "Message of the Day:", x/3.5, y/3.6, x, y, tocolor ( 255, 255, 255, 255 ), 1, "bankgothic" ) -- Create Welcome title. dxDrawLine ( x/3.59, y/3.275, x/1.348, y/3.275, tocolor ( 0, 0, 255, 255 ), 2 ) -- Create underline shadow. dxDrawText ( MOTDText, x/3.6, y/3, x, y, tocolor ( 255, 255, 255, 255 ), 1, "clear" ) end function initiateSpawn() --after player login , this is called addEventHandler("onClientRender", getRootElement(), spawnTitle) --add the MOTD createTeleportWindow() -- add the teleport menu end addEvent("startSpawn", true) -- event that is called by the login addEventHandler("startSpawn", getLocalPlayer(), initiateSpawn) function createTeleportWindow() -- create the spawn menu selectMenu = guiCreateWindow(0, 0.75, 1, 0.25, "Select a City to start!", true) buttonLS = guiCreateButton(0.125, 0.25, 0.25, 0.5, "Los Santos", true, selectMenu) buttonSF = guiCreateButton(0.375, 0.25, 0.25, 0.5, "San Fierro", true, selectMenu) buttonLV = guiCreateButton(0.625, 0.25, 0.25, 0.5, "Las Venturas", true, selectMenu) addEventHandler("onClientGUIClick", root, handleSpawn) showCursor(true) end function handleSpawn(button,state) --handler that is called by the spawn menu if button == "left" and state == "up" then if source == buttonLS then removeEventHandler("onClientRender", getRootElement(), spawnTitle) guiSetVisible(selectMenu, false) triggerServerEvent( "spawnMe", getLocalPlayer(), 1) elseif source == buttonSF then removeEventHandler("onClientRender", getRootElement(), spawnTitle) guiSetVisible(selectMenu, false) triggerServerEvent( "spawnMe", getLocalPlayer(), 2) elseif source == buttonLV then removeEventHandler("onClientRender", getRootElement(), spawnTitle) guiSetVisible(selectMenu, false) triggerServerEvent( "spawnMe", getLocalPlayer(), 3) end end end function startNormalPlay() showPlayerHudComponent("ammo", true) showPlayerHudComponent("area_name", true) showPlayerHudComponent("armour", true) showPlayerHudComponent("breath", true) showPlayerHudComponent("clock", true) showPlayerHudComponent("health", true) showPlayerHudComponent("money", true) showPlayerHudComponent("radar", true) showPlayerHudComponent("vehicle_name", true) showPlayerHudComponent("weapon", true) setCameraTarget(getLocalPlayer()) showChat(true) showCursor ( false ) guiSetVisible(selectMenu, false) outputChatBox("test") end addEvent("readyToPlay", true) addEventHandler("readyToPlay", getRootElement(), startNormalPlay) Link to comment
AGENT_STEELMEAT Posted February 25, 2011 Author Share Posted February 25, 2011 Sorry, I already fixed the issue. I went through all the resource's scripts and balanced the showCursor and setGuiInputEnabled lines. Thanks for the help anyway! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now