AGENT_STEELMEAT Posted February 1, 2011 Share Posted February 1, 2011 I have a script that shows a MOTD, then a window with 3 buttons you can click to select a city to spawn in. Right now, I just want them to output to the console so that I know that they are being triggered. I wrote this script, and right now it just isn't triggering the buttons for some reason. Also, I can't lock the window (with guiSetMovable and guiSetSizable) without having the mouse disappear (regardless of whether showCursor() is true or false). Any help would be appreciated. function initiateSpawn() --after player login , this is called addEventHandler("onClientRender", getRootElement(), spawnTitle) --add the MOTD createTeleportWindow() -- add the teleport menu end addEvent("spawnReady", true) -- event that is called by the login addEventHandler("spawnReady", getRootElement(), initiateSpawn) function createTeleportWindow() -- create the spawn menu local selectMenu = guiCreateWindow(0, 0.75, 1, 0.25, "Select a City to start!", true) local buttonLS = guiCreateButton(0.125, 0.25, 0.25, 0.5, "Los Santos", true, selectMenu) local buttonSF = guiCreateButton(0.375, 0.25, 0.25, 0.5, "San Fierro", true, selectMenu) local buttonLV = guiCreateButton(0.625, 0.25, 0.25, 0.5, "Las Venturas", true, selectMenu) addEventHandler("onClientGUIClick", buttonLS, handleSpawn, false) addEventHandler("onClientGUIClick", buttonSF, handleSpawn, false) addEventHandler("onClientGUIClick", buttonLV, handleSpawn, false) 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 outputConsole("LS Selected.") --testing, but not even this happens. will add the real stuff later. elseif source == buttonSF then outputConsole("SF Selected.") elseif source == buttonLV then outputConsole("LV Selected.") end end end function spawnTitle() -- a MOTD using dxDraw (this works fine), based on wiki example local screenWidth, screenHeight = guiGetScreenSize() local MOTDText = [[ Welcome to SUPERSQUIRELL -- s:D -->! Latest news: -New Login system, MOTD and spawn menu are DONE! -The spawn buttons will be enabled soon, once more of the gamemode is done. -Expect fun gameplay features by the end of the week. **Please disconnect, as there is nothing else to do here at this point. Thank you all for your continued patience while we continue development. -John ([email protected]) ]] local playerName = getPlayerName ( getLocalPlayer() ) -- Get players name. 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/3, y/3, x/2, y/2, tocolor ( 0, 0, 0, 150 ) ) -- Create our black transparent MOTD background Rectangle. dxDrawText ( "Welcome " .. playerName, x/3.5, y/3.6, x, y, tocolor ( 255, 255, 255, 255 ), 1, "bankgothic" ) -- Create Welcome title. dxDrawText ( "Welcome " .. playerName, x/3.48, y/3.58, x, y, tocolor ( 0, 0, 0, 255 ), 1, "bankgothic" ) -- Create Welcome title shadow. 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 Link to comment
Castillo Posted February 1, 2011 Share Posted February 1, 2011 function initiateSpawn() --after player login , this is called addEventHandler("onClientRender", getRootElement(), spawnTitle) --add the MOTD createTeleportWindow() -- add the teleport menu end addEvent("spawnReady", true) -- event that is called by the login addEventHandler("spawnReady", getRootElement(), initiateSpawn) function createTeleportWindow() -- create the spawn menu local 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 outputConsole("LS Selected.") --testing, but not even this happens. will add the real stuff later. elseif source == buttonSF then outputConsole("SF Selected.") elseif source == buttonLV then outputConsole("LV Selected.") end end end function spawnTitle() -- a MOTD using dxDraw (this works fine), based on wiki example local screenWidth, screenHeight = guiGetScreenSize() local MOTDText = [[ Welcome to SUPERSQUIRELL -- s:D -->! Latest news: -New Login system, MOTD and spawn menu are DONE! -The spawn buttons will be enabled soon, once more of the gamemode is done. -Expect fun gameplay features by the end of the week. **Please disconnect, as there is nothing else to do here at this point. Thank you all for your continued patience while we continue development. -John ([email protected]) ]] local playerName = getPlayerName ( getLocalPlayer() ) -- Get players name. 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/3, y/3, x/2, y/2, tocolor ( 0, 0, 0, 150 ) ) -- Create our black transparent MOTD background Rectangle. dxDrawText ( "Welcome " .. playerName, x/3.5, y/3.6, x, y, tocolor ( 255, 255, 255, 255 ), 1, "bankgothic" ) -- Create Welcome title. dxDrawText ( "Welcome " .. playerName, x/3.48, y/3.58, x, y, tocolor ( 0, 0, 0, 255 ), 1, "bankgothic" ) -- Create Welcome title shadow. 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 Btw, wth is this? Welcome to SUPERSQUIRELL <!-- s:D --><img src=\"{SMILIES_PATH}/icon_biggrin.gif\" alt=\":D\" title=\"Very Happy\" /><!-- s:D -->! Link to comment
AGENT_STEELMEAT Posted February 1, 2011 Author Share Posted February 1, 2011 SUPERSQUIRELL was me getting bored, but the rest of that was the forum interpreting a smiley face I put in the code and trying to convert it into a little smiley face picture. lol thanks. 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