Jump to content

I'm having a problem


abu5lf

Recommended Posts

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

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

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

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

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