abu5lf Posted March 16, 2012 Share Posted March 16, 2012 server.lua function wla(thePlayer, commandName,...) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ( "user." .. accName, aclGetGroup ( "Admin" ) ) then triggerClientEvent("yanas", getRootElement(),yana) end --- client.lua button = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Output!", true ) editBox = guiCreateEdit( 0.3, 0.1, 0.4, 0.1, "Type your message here!", true ) addEventHandler ( "onClientGUIClick", editBox, outputEditBox ) guiEditSetMaxLength ( editBox, 128 ) function outputEditBox () local text = guiGetText ( editBox ) outputChatBox ( text ) setTimer ( text, 1000, 0 ) end addEventHandler ( "onClientGUIClick", button, outputEditBox ) function bindTheKeys ( player, commandName ) bindKey ( player, "F1", "down", outputEditBox ) end addEvent("yanas", true ) addEventHandler("yanas", getRootElement(), outputEditBox) Link to comment
myonlake Posted March 16, 2012 Share Posted March 16, 2012 Need to use the code tags again since lua is bugged somehow. So, you had few errors there: a missing end in the server side code and you had put (player, cmd) in the client side command event, which is not going to work since client-side works with the source without needing to put the source seperately. Commands triggerClientEvent: /wla bindKey: /bindme Server-side addCommandHandler("wla", function(player, cmd, ...) local accName = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup("user." .. accName, aclGetGroup("Admin")) then triggerClientEvent("yanas", root, yana) end end ) Client-side local button = guiCreateButton(0.7, 0.1, 0.2, 0.1, "Output!", true) local editBox = guiCreateEdit(0.3, 0.1, 0.4, 0.1, "Type your message here!", true) guiEditSetMaxLength(editBox, 128) function outputEditBox () local text = guiGetText(editBox) outputChatBox(text) setTimer(text, 1000, 0) end addEvent("yanas", true) addEventHandler("yanas", root, outputEditBox) addEventHandler("onClientGUIClick", button, outputEditBox) addEventHandler("onClientGUIClick", editBox, outputEditBox) addCommandHandler("bindme", function(cmd) bindKey("F1", "down", outputEditBox) end ) Link to comment
abu5lf Posted March 16, 2012 Author Share Posted March 16, 2012 Did not work properly Show for all and not a group admin Also do not repeat message after time Also when I press "F1" does not show or closed. Also when it wrote "bindme" not taking place is something Link to comment
Kenix Posted March 16, 2012 Share Posted March 16, 2012 Client addEvent( 'yanas', true ) local button = guiCreateButton( 0.7, 0.1, 0.2, 0.1, 'Output!', true ) local editBox = guiCreateEdit( 0.3, 0.1, 0.4, 0.1, 'Type your message here!', true ) guiEditSetMaxLength( editBox, 128 ) guiSetVisible( button, false ) guiSetVisible( editBox, false ) function outputEditBox ( sText ) local text = guiGetText( editBox ) outputChatBox( sText or text ) setTimer( outputEditBox, 1000, 1 ) end addEventHandler( 'yanas', root, outputEditBox ) addEventHandler( 'onClientGUIClick', button, outputEditBox ) addEventHandler( 'onClientGUIClick', editBox, outputEditBox ) bindKey( 'F1', 'down', function( ) guiSetVisible( button, not guiGetVisible( button ) ) guiSetVisible( editBox, not guiGetVisible( editBox ) ) showCursor( not isCursorShowing( ) ) end ) Server addCommandHandler('wla', function( uPlayer ) for _, uPlayer in pairs( getElementsByType 'player' ) do local sName = getAccountName( getPlayerAccount( uPlayer ) ) if isObjectInACLGroup( 'user.' .. sName, aclGetGroup( 'Admin' ) ) then triggerClientEvent( uPlayer, 'yanas', uPlayer, 'yana' ) end end end ) Read it https://wiki.multitheftauto.com/wiki/Scr ... troduction https://wiki.multitheftauto.com/wiki/Int ... ng_the_GUI Link to comment
abu5lf Posted March 17, 2012 Author Share Posted March 17, 2012 It appears from the text without pressing the button Also appear for all, not only a group admin Link to comment
Castillo Posted March 17, 2012 Share Posted March 17, 2012 -- client side: local button = guiCreateButton( 0.7, 0.1, 0.2, 0.1, 'Output!', true ) local editBox = guiCreateEdit( 0.3, 0.1, 0.4, 0.1, 'Type your message here!', true ) guiEditSetMaxLength( editBox, 128 ) guiSetVisible( button, false ) guiSetVisible( editBox, false ) function outputEditBox ( ) local text = guiGetText( editBox ) triggerServerEvent ( "outputMessage", localPlayer, text ) end addEventHandler( 'onClientGUIClick', button, outputEditBox, false ) bindKey( 'F1', 'down', function( ) guiSetVisible( button, not guiGetVisible( button ) ) guiSetVisible( editBox, not guiGetVisible( editBox ) ) showCursor( not isCursorShowing( ) ) end ) -- server side: addEvent ( "outputMessage", true ) addEventHandler ( "outputMessage", root, function ( text ) for index, player in ipairs ( getElementsByType "player" ) do local accountName = getAccountName( getPlayerAccount( player ) ) if isObjectInACLGroup( "user.".. accountName, aclGetGroup( "Admin" ) ) then outputChatBox ( text, player ) end end end ) Link to comment
abu5lf Posted March 17, 2012 Author Share Posted March 17, 2012 local button = guiCreateButton( 0.7, 0.1, 0.2, 0.1, 'Output!', true ) local editBox = guiCreateEdit( 0.3, 0.1, 0.4, 0.1, 'Type your message here!', true ) guiEditSetMaxLength( editBox, 128 ) guiSetVisible( button, false ) guiSetVisible( editBox, false ) function outputEditBox ( ) Time = get("Time") mount = get("mount") local text = guiGetText( editBox ) triggerServerEvent ( "outputMessage", localPlayer, text ) setTimer( outputEditBox, Time, mount ) end addEventHandler( 'onClientGUIClick', button, outputEditBox, false ) bindKey( 'num_3', 'down', function( ) guiSetVisible( button, not guiGetVisible( button ) ) guiSetVisible( editBox, not guiGetVisible( editBox ) ) showCursor( not isCursorShowing( ) ) end ) meta.xml <meta> <info name="X" author="Cx.83" version="1.0" type="script" /> <script src="s_rotep.lua" type="server"/> <script src="client.lua" type="Client"/> <settings> <setting name="*Time" value="1000" /> <setting name="*mount" value="9999" /> </settings> </meta> ERROR: xRoaTep\client.lua:9: attempt to call global 'get' (a nil value) Link to comment
Castillo Posted March 17, 2012 Share Posted March 17, 2012 The function get is server side only, you can't use it client side. 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