Sign in to follow this  
Gat

[Help]Massaging gui

Recommended Posts

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

Share this post


Link to post

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

Share this post


Link to post
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 by Gat

Share this post


Link to post
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?

Share this post


Link to post

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.

Share this post


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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.