Jump to content

triggerServerEvent


External

Recommended Posts

Server side:-

function Updates(plr)
    local text = guiGetText(Edit)
    outputChatBox("UPDATE:" .. text, plr)
end
addEvent("myEvent", true)
addEventHandler("myEvent", root, Updates)

Client side:-

GUIEditor = {
    button = {},
    window = {},
    edit = {}
}

function GUI()
    Button = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Output!", true )
    Edit = guiCreateEdit( 0.3, 0.1, 0.4, 0.1, "Type your message here!", true )
    guiEditSetMaxLength ( Edit, 128 )
    showCursor(true)
    addEventHandler( "onClientGUIClick", Button, Updates, false )   
    end
addCommandHandler("updates", GUI)

function Updates()
    triggerServerEvent( "myEvent", localPlayer, guiGetText )
end

I want to know whats wrong with this cuz its not working

Link to post

First of all, in your server's side:

local text = guiGetText(Edit)

'Edit' is nothing, you haven't declared it anywhere.

 

Second of all, in your server's side you're expecting a playersource as first variable which you called 'plr'. In your client side, you're sending a function:

triggerServerEvent( "myEvent", localPlayer, guiGetText )

 

If you would've put on debugscript 3, you would've gotten an error. Go to your server, turn on /debugscript 3 and read the errors.

Link to post
10 minutes ago, tosfera said:

First of all, in your server's side:


local text = guiGetText(Edit)

'Edit' is nothing, you haven't declared it anywhere.

 

Second of all, in your server's side you're expecting a playersource as first variable which you called 'plr'. In your client side, you're sending a function:


triggerServerEvent( "myEvent", localPlayer, guiGetText )

 

If you would've put on debugscript 3, you would've gotten an error. Go to your server, turn on /debugscript 3 and read the errors.

Can you fix this for me please?

Link to post
2 hours ago, tosfera said:

As I said, turn on debugscript 3 to read the errors. If you really can't work it out then I can, but you have to try it yourself first. We're not just giving things away without you even trying.

so I've turned it on and the debug was.

'attempt  to call global 'guiGetText' (a nil value).

Thats cuz it's client side only

but how can I fix that issue?

I'm not pro in triggering events

if u can show me an example of a script that u made, I would be thankful

Link to post
-- On client
Button = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Output!", true )
Edit = guiCreateEdit( 0.3, 0.1, 0.4, 0.1, "Type your message here!", true )
guiSetVisible ( Button,false )
guiSetVisible ( Edit,false )
guiEditSetMaxLength ( Edit, 128 )
addCommandHandler ( 'updates',
    function (      )
    guiSetVisible ( Button,not guiGetVisible ( Button ) ) 
    guiSetVisible ( Edit,not guiGetVisible ( Edit )  )        
    showCursor ( guiGetVisible ( Button ) ) 
    end
)
addEventHandler ( 'onClientGUIClick',Button,
    function (      )   
      triggerServerEvent( "myEvent", localPlayer, guiGetText ( Edit ) )
    end,false
)
-- On server showing it for all players in the game

function Updates( text )
    outputChatBox ( 'UPDATE : '..text,root )
end
addEvent("myEvent", true)
addEventHandler("myEvent", root, Updates)

-- if you want it only for the player how sent the trigger use source or client instead of root.

 

@External

Link to post

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