Jump to content

GUI for more player


Animan99

Recommended Posts

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

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

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 :D 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

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
  • 2 weeks later...
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
  • 2 weeks later...

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

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