Animan99 Posted June 23, 2015 Share Posted June 23, 2015 Hi. I am working on a phone system, doing the chat part right now. I want my GUI shown for my partner i am talking with. I tried this method, dont work. function gui() for k, v in ipairs(getElementsByType ("player")) do if getElementData(localPlayer, "phone") == "goingCall" and getElementData (v, "phone") == "goingCall" then guiCreateLabel(--labelstuff) -- should draw the label, only draws for the local player end end end THX for your help Link to comment
Animan99 Posted June 23, 2015 Author Share Posted June 23, 2015 this is my full code contains the part i need Link to comment
Dealman Posted June 24, 2015 Share Posted June 24, 2015 You can use either element data for this, or you can use events. Personally, I think I'd go with events as it allows for more control. You'll have to think logically, if it helps, try to draw on paper or in some software(You'd be amazed how many professional programmers draw their solutions before actually making them). Think of it this way; 1. Player A tries to send a text message to Player B. 2. Player A submits the message, which is then sent to the server using triggerServentEvent. 3. Server handles the submission, and if everything looks alright - passes it on to Player B. 4. Server uses triggerClientEvent to trigger a client-side event on Player B, and Player B only. 5. The phone system is updated for both Player A and Player B upon sending/receiving the message. It's a very simple procedure once you get accustomed to triggering client- and server-sided events. Link to comment
Animan99 Posted June 24, 2015 Author Share Posted June 24, 2015 Thank you i did this element data way for the other parts of the script you cannot see. I have about 20 element data right now for player A and player B I try your method tomorrow. I know the triggering stuff, used many times but i thought that i can make it without it Thanks. I will post a comment here, if its working or not Link to comment
Dealman Posted June 24, 2015 Share Posted June 24, 2015 Of course both work, but I believe using element data would be much less efficient. Especially if set to synchronize the data. Link to comment
Animan99 Posted June 25, 2015 Author Share Posted June 25, 2015 can you help me with this triggerServer - Client event? i tried it, but cannot recognize guiGetText(editbox) local renderData = {} addEvent("UzenetKuldes", true) addEventHandler("UzenetKuldes", root, function() for k, v in ipairs(getElementsByType("player")) do if getElementData(localPlayer, "phone") == "goingCall" then renderData.asdlabel = guiCreateLabel(renderData.smsDrawX, renderData.smsDrawY, 200, 500, guiGetText(callInput), false, renderData.labelParent) outputChatBox("triggerelve") end end end) attempt to call global guiGetText etc.. .a nil value Link to comment
Dealman Posted June 25, 2015 Share Posted June 25, 2015 You can not use client-side events in a server-side script. guiGetText and guiCreateLabel are client-side only. Link to comment
Animan99 Posted June 25, 2015 Author Share Posted June 25, 2015 Then how to send the message to player B? you said with triggerServer - Client events. Link to comment
Dealman Posted June 25, 2015 Share Posted June 25, 2015 Client A -> Server -> Client B triggerServerEvent -> triggerClientEvent triggerClientEvent("eventName", playerElementToSendTo, messageVariable) Read the wiki pages thoroughly, they're usually well documented. Link to comment
Animan99 Posted July 4, 2015 Author Share Posted July 4, 2015 player B does not see the message, hovever i send it to server and back to client ( Anybody? Link to comment
Mr. Bubbles Posted July 4, 2015 Share Posted July 4, 2015 You can use either element data for this, or you can use events. Personally, I think I'd go with events as it allows for more control.You'll have to think logically, if it helps, try to draw on paper or in some software(You'd be amazed how many professional programmers draw their solutions before actually making them). Think of it this way; 1. Player A tries to send a text message to Player B. 2. Player A submits the message, which is then sent to the server using triggerServentEvent. 3. Server handles the submission, and if everything looks alright - passes it on to Player B. 4. Server uses triggerClientEvent to trigger a client-side event on Player B, and Player B only. 5. The phone system is updated for both Player A and Player B upon sending/receiving the message. It's a very simple procedure once you get accustomed to triggering client- and server-sided events. I use this all the time! except I lay it out in the code editor first - at least the basic structure of the program. I find that by defining the goals of what this script is supposed to do really helps. Drawing it out is especially useful when implementing DX GUIs since I can visualize what is going to be there and what functions are associated with what. Link to comment
Animan99 Posted July 5, 2015 Author Share Posted July 5, 2015 can Anybody help me, how to solve this? i know there are lots of clever people here. Please, help Link to comment
GTX Posted July 15, 2015 Share Posted July 15, 2015 Send message to the server sided script, then from there, send it to client side using first optional argument bool triggerClientEvent ( [table/element sendTo=getRootElement()], string name, element sourceElement, [arguments...] ) sendTo - To which player you want to send. Link to comment
Animan99 Posted July 15, 2015 Author Share Posted July 15, 2015 did that already, doesnt work. however tried with in another resource just with a label, worked... dunno why 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