Gat Posted June 6, 2018 Share Posted June 6, 2018 (edited) I made an script that make staffs can open an panel by using /dm then choose a player and type a message then send it... But my problem is i don't know how to trigger this to put this code in server side outputChatBox(msg, selectedplayer, 255, 255, 255, true) I mean to send the message to selected player only... client variables: msg = guiGetText(editbox) selectedplayer = guiGridListGetSelectedItem(gridlist) Help pls Edited June 6, 2018 by Gat Link to comment
Ryan2233 Posted June 6, 2018 Share Posted June 6, 2018 (edited) Hi there, their is a few ways to trigger code on another script type. The most common way is to create a custom event, and trigger it. How you'd do it is: Make a custom event below the function you wish to trigger. So since you didn't provide your function where the outputChatBox(msg, selectedplayer, 255, 255, 255, true) Is. So I'll make one, but obviously, use your own. So here's what we have now. function outputTheMessage() outputChatBox(msg, selectedplayer, 255, 255, 255, true) end Then, we add addEvent("outputMessage", getRootElement, outputTheMessage) ) So now we have function outputTheMessage() outputChatBox(msg, selectedplayer, 255, 255, 255, true) end addEvent("outputMessage", getRootElement, outputTheMessage) ) Then on the server side, we can trigger the event. Now remember, this method can be used on any side. If you wish to trigger a server function on a client script, do the above there also. But the triggers are different for both sides. Client ~ triggerClientEvent() (Just to clear up, triggerClientEvent is used on the server to trigger the outputMessage custom event we made above) Server ~ triggerServerEvent() So in backup, triggerServerEvent is used to trigger a server event on a client script. And vice versa. So to finish this off, we want triggerClientEvent since we want to trigger a client event we made in a server client. So go to your server script, to the function you want to call the function outputTheMessage() outputChatBox(msg, selectedplayer, 255, 255, 255, true) end And inside of the server function, put triggerClientEvent(outputMessage, getRootElement) I've not tested it, if you get further errors, please say. Edited June 6, 2018 by Ryan2233 Link to comment
Gat Posted June 6, 2018 Author Share Posted June 6, 2018 (edited) 1 hour ago, Ryan2233 said: Hi there, their is a few ways to trigger code on another script type. The most common way is to create a custom event, and trigger it. How you'd do it is: Make a custom event below the function you wish to trigger. So since you didn't provide your function where the outputChatBox(msg, selectedplayer, 255, 255, 255, true) Is. So I'll make one, but obviously, use your own. So here's what we have now. function outputTheMessage() outputChatBox(msg, selectedplayer, 255, 255, 255, true) end Then, we add addEvent("outputMessage", getRootElement, outputTheMessage) ) So now we have function outputTheMessage() outputChatBox(msg, selectedplayer, 255, 255, 255, true) end addEvent("outputMessage", getRootElement, outputTheMessage) ) Then on the server side, we can trigger the event. Now remember, this method can be used on any side. If you wish to trigger a server function on a client script, do the above there also. But the triggers are different for both sides. Client ~ triggerClientEvent() (Just to clear up, triggerClientEvent is used on the server to trigger the outputMessage custom event we made above) Server ~ triggerServerEvent() So in backup, triggerServerEvent is used to trigger a server event on a client script. And vice versa. So to finish this off, we want triggerClientEvent since we want to trigger a client event we made in a server client. So go to your server script, to the function you want to call the function outputTheMessage() outputChatBox(msg, selectedplayer, 255, 255, 255, true) end And inside of the server function, put triggerClientEvent(outputMessage, getRootElement) I've not tested it, if you get further errors, please say. Before testing it.. outputChatBox in client side contains txt, r, g, b only so it won't work, listen... I mean when i select a player and press send button.. It sends the message that i typed in editbox to selected player...can u make a short explain for working one without much explaining pls, I'm not new in scripting so I'll understand a short explaining. Edit: addEvent has 1 arg and 1 optional arg... Why u used it as addEventHandler with 3 args?! Edited June 6, 2018 by Gat Link to comment
Ryan2233 Posted June 6, 2018 Share Posted June 6, 2018 1 hour ago, Gat said: Before testing it.. outputChatBox in client side contains txt, r, g, b only so it won't work Can you share your full code? Link to comment
Discord Moderators Pirulax Posted June 8, 2018 Discord Moderators Share Posted June 8, 2018 So you made a "massaging" panel, or whatever. But if its a massaging panel, than why the heck you want to output the message that the admin typed in, into the chatbox? I dont undestang you, and I dont understand why you want to output the message to the chatbox. 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