bradio10 Posted October 31, 2012 Share Posted October 31, 2012 Ok, so this wont open the GUI and the map won't load for the gate to be in the location either. Script; function createKeypad local sWidth, sHeight = guiGetScreenSize() local Width,Height = 142,276 local X = (sWidth/2) - (Width/2) local Y = (sHeight/2) - (Height/2) keypadWindow = guiCreateWindow(X,Y,Width,Height,"Keypad",false) guiWindowSetSizable(keypadWindow,false) keypadButton1 = guiCreateButton(13,68,37,36,"1",false,keypadWindow) keypadButton2 = guiCreateButton(53,68,37,36,"2",false,keypadWindow) keypadButton3 = guiCreateButton(93,68,37,36,"3",false,keypadWindow) keypadButton4 = guiCreateButton(13,108,37,36,"4",false,keypadWindow) keypadButton5 = guiCreateButton(53,108,37,36,"5",false,keypadWindow) keypadButton6 = guiCreateButton(93,108,37,36,"6",false'keypadWindow) keypadButton7 = guiCreateButton(13,148,37,36,"7",false,keypadWindow) keypadButton8 = guiCreateButton(53,148,37,36,"8",false,keypadWindow) keypadButton9 = guiCreateButton(93,148,37,36,"9",false,keypadWindow) keypadButtonAsterix = guiCreateButton(13,188,37,36,"*",false,keypadWindow) keypadButton0 = guiCreateButton(53,188,37.36,"0",false,keypadWindow) keypadButtonHash = guiCreateButton(93,188,37,36,"#",false,keypadWindow) keypadButtonExit = guiCreateButton(13,288,37,36,"Exit",false,keypadWindow) keypadButtonEnter = guiCreateButton(53,288,37,36,"Enter",false,keypadWindow) keypadButtonClear = guiCreateButton(93,288,37,36,"Clear",false,keypadWindow) keypadGridListDisplay = guiCreateGridList(13,25,117,33,false,keypadWindow) guiGridListSetSelectionMode(keypadGridListDisplay,2) guiSetAplpha(keypadGridListDisplay,0.6) keypadLabelDisplay = guiCreateLabel(14,26,115,30,"Enter Keycode.",false,keypadWindow) guiLabelSetColor(keypadLabelDisplay,255,000,000) guiLabelSetVerticalAlign(keypadLabelDisplay,"center") guiLabelSetHorizontalAlign(keypadLabelDisplay,"center",false) guiSetVisible(keypadWindow,false) end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),creaeKeypad) function updateDisplay(text) if text then if tonumber(text) or text == "x" or text === "#" then guiSetText(keypadLabelDisplay,guiGetText(keypadLabelDisplay) .. text) else guiSetText(keypadDisplay,text) end else guiSetText(keypadLabelDisplay,"") end end addEventHandler("onClientGUIClick",keypadWindow,processKeypadClicks,true) function processKeypadClicks(button,state) if button == "left" and state == "up" then if getElementType(source) == "gui-button" then triggerEvent("onKeypadButtonClicked",source,getElementData(keypadWindow,"keypadID")) end end end addEvent("onkeypadButtonClicked",false) addEventHandler("onKeypadButtonClicked,rooy, function(keypadID) end ) addEvent("onkeypadButtonClicked",false) addEventHandler("onKeypadButtonClicked",root, function(keypadID) if guiGetText(keypadLabelDisplay) == "Enter Keycode." or guiGetText(keypadLabelDisplay) == "Invalid Keycode." then updateDisplay) end if guiGetText(source) == "Enter" then local code = guiGetText(keypadLabelDisplay) if code then triggerServerEvent("verifyKeypadCode",getLocalPlayer(),code,keypadID) end elseif guiGetText(source) == "Exit" then guiSetVisible(keypadWindow,false) updateDisplay("Enter Keycode.") showcursor(false,false) else updateDisplay(guiGetText(source)) end end ) addEvent("onKeypadVerificationSuccessful",true) addEventHandler("onKeypadVerificationSuccessful",root, function() guiSetVisible(keypadWindow,false) updateDisplay("Enter Keycode.") showcursor(false,false) end ) addEvent("onKeypadVerificationFailed",true) addEventHandler("onKeypadVerificationFailed",root, function() updateDisplay("Invalid Keycode.") end ) addCommandHandler("a51gate",function() guiSetVisible(keypadWindow,true) showCursor(true,true) setElementData(keypadWindow,"keypadID","a51MainGateKeypadCode") end) addEventHandler("onKeypadVerificationSuccessful",root, function(keypadID) local gate = getElementByID(keypadID) if gate then local x = tonumber(getElementData(gate,"newPosX")) local y = tonumber(getElementData(gate,"newPosY")) local z = tonumber(getElementData(gate,"newPosZ")) moveObject(gate,1500,x,y,z) x = tonumber(getELementData(gate,"PosX")) y = tonumber(getElementData(gate,"posY")) z = tonumber(getElementData(gate,"posZ")) setTimer(moveObject,5000,1,gate,1500,x,y,z) end end ) Serverside: local keypadCodes = { ["a51MainGateKeypadCode"]= "4455*#" } addEvent("verifyKeypadCode",true) addEventHandler("verifyKeypadCode",root,function(code,keypadID) if code then if code == keypadCodes[keypadID] then triggerClientEvent(client,"onKeypadVerificationSuccessful",client,keypadID) else triggerClientEvent(client,"onKeypadVerificationFailed",client,keypadID) end end end) Map: <map> <object id="a51MainGateKeypadCode" model="971" posX="96.736" posY="1918.352" posZ="20.694" rotX="0" rotY="0" rotZ="270.40" newPosX="96.751" newPosY="1914.474" newPosZ="20.694" /> </map> Meta: <meta> <script src="keypad.lua" type="client" /> <script src="server.lua" type="server" /> <map src="gate.map" dimension="0"></map> </meta> Any help would be appreciated heaps and I am only a rookie/noob scripter for Lua Thanks heaps Link to comment
Scooby Posted October 31, 2012 Share Posted October 31, 2012 u should use [ /lua ] tags so its easier for us to read. (rather than [ /code ]) at a glance ur line 1 is missing the () from 'function createKeypad' remember to use /debugscript 3 when debugging, it could save u a lot of time Link to comment
bradio10 Posted November 1, 2012 Author Share Posted November 1, 2012 ok, I will post it next time as a Lua script instead of a code. I used /debugscript 3 in-game and yeh, it came up with faults, but when I tryed to fix the faults by doing what it said, it still was saying that it needed to be fixed still. This also happened with my other script aswell. It was saying for me to put brackets over "local", which I did. Then it said to put either or '..' over "local" aswell. I did but it didn't fix it. So now I am more stuck and to be honest, more confused. If there are any other ways of fixing it like maybe a autocorrect script to put in Notpad ++, that would help me HEAPS. 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