TimJ Posted May 16, 2009 Posted May 16, 2009 Im confused with GUI triggering server events I tried a couple of times, i tried to use the wiki to help, What i got was: Server: function greetingHandler ( message ) outputChatBox ( "lalala:", source ) end addEvent( "onGreeting", true ) addEventHandler( "onGreeting", getRootElement(), greetingHandler ) Client: button = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Test", true ) function spawner ( commandName ) triggerServerEvent ( "onGreeting", getLocalPlayer(), " wowow" ) end addEventHandler ( "onClientGUIClick", button, spawner ) Help would be very kindly appreciated
robhol Posted May 16, 2009 Posted May 16, 2009 I don't see anything wrong in the code after a quick look, more info would be nice. What exactly is the problem? Error messages, etc.
TimJ Posted May 16, 2009 Author Posted May 16, 2009 i just added a command handler to the spawner function... which worked which means ive done something wrong with the button i guess...
robhol Posted May 16, 2009 Posted May 16, 2009 Ah, I think I know it. Add an event handler for onClientResourceStart and put the function that creates a button inside it.
TimJ Posted May 16, 2009 Author Posted May 16, 2009 i thought about that then thought it might just trigger the event on the client resource start, so i just tried it and it made no difference just triggered the event on resource start
50p Posted May 16, 2009 Posted May 16, 2009 i thought about that then thought it might just trigger the event on the client resource start, so i just tried it and it made no difference just triggered the event on resource start How did you do that? -- SERVER -- function greetingHandler ( message ) outputChatBox ( message, source ); end addEvent( "onGreeting", true ); addEventHandler( "onGreeting", getRootElement(), greetingHandler ); -- CLIENT -- addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource( ) ), function ( ) button = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Test", true ); addEventHandler( "onClientGUIClick", button, spawner, false ); end ) function spawner ( ) triggerServerEvent ( "onGreeting", getLocalPlayer(), " wowow" ) end
TimJ Posted May 16, 2009 Author Posted May 16, 2009 Im trying to make the cursor show but it wont and im getting: Bad argument @ 'showCursor' in the console. im typing: showCursor(source, true) help EDIT: Scrap That- Fixed
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