Jump to content

GUI for more player


Animan99

Recommended Posts

Posted

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

Posted

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.

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

Posted

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

Posted

Of course both work, but I believe using element data would be much less efficient. Especially if set to synchronize the data.

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

Posted

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

Posted

You can not use client-side events in a server-side script. guiGetText and guiCreateLabel are client-side only.

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

Posted

Client A -> Server -> Client B

triggerServerEvent -> triggerClientEvent

triggerClientEvent("eventName", playerElementToSendTo, messageVariable) 

Read the wiki pages thoroughly, they're usually well documented.

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

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

Miscellaneous stuff

Gameloft Live!

holygamer22

Modern Combat 4 stats

GameCenter:

Mr_Bubbles

You may send a PM to me!

  • 2 weeks later...
Posted

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.

Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS.

Developer and owner of

https://projectbea.st - Project Beast

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