Jump to content

Phone-system HELP!


Animan99

Recommended Posts

Posted

Hi. I am writing my own (First) phone system, i am learning LUA about 2 months. I advance nicely with the phone, but i have a little problem with the chat part. When i click on the "send" button, this code runs:

-- this code adds a value to the table, that i will loop through in the next code.  
function sendCallMSG(msg) 
    for _, player in pairs(getElementsByType("player")) do 
         
             
                 targetPlayer = player 
                 msgFrom = getElementData(localPlayer, "phoneNumber") 
                 msgTo = getElementData(targetPlayer, "phoneNumber") 
                 theMsg = tostring(msg) 
                callMessages[#callMessages + 1] = theMsg 
                setElementData(targetPlayer, "char.tempCall", {msgFrom, msgTo, theMsg})          
                       
                renderData.msgCounter = renderData.msgCounter + 1 
                --renderData.currentRow = renderData.currentRow + 1 
                 
                break 
    end 
end  

And the second code loops the "callMessages" table, and write out the value:

if getElementData(localPlayer, "phone") == "goingCall" then 
        dxDrawImage(X, Y + 35, Width, Height, "files/ongoingcall.png") 
        renderData.smsLatestLine = renderData.currentRow + renderData.maxRow - 1 
         
        for k,v in ipairs(callMessages) do 
            if k >= renderData.currentRow then 
               if k <= renderData.smsLatestLine and v then 
                     
                    renderData.smsDrawX = X + 70 
             
                    renderData.smsDrawY = Y + 125 + (renderData.sorokKozKihagyas * (renderData.uzenetSzamolo - 1)) -- this is the important thing, this moves the value, but my problem is when i click again the send button all the values are moving with this. I want that the values are move 10 pixels down from the previous value, but all the messages are moving. 
                    if vanUjSzoveg == true then 
                        renderData.smsDrawY = renderData.uzenetSzamolo * 10  
                    end 
                    dxDrawText(string.gsub(v, "_", " "), renderData.smsDrawX, renderData.smsDrawY, 50, 0, tocolor(255, 255, 255, 255), 2, "arial", "left", "top", false, true, true) 
                end 
            end 
        end 
    end 

So, basically, I want that the values are move 10 pixels down from the previous value. Thank you, i will be so glad if you guys can help me :)

Posted
Hi. I am writing my own (First) phone system, i am learning LUA about 2 months. I advance nicely with the phone, but i have a little problem with the chat part. When i click on the "send" button, this code runs:
-- this code adds a value to the table, that i will loop through in the next code.  
function sendCallMSG(msg) 
    for _, player in pairs(getElementsByType("player")) do 
         
             
                 targetPlayer = player 
                 msgFrom = getElementData(localPlayer, "phoneNumber") 
                 msgTo = getElementData(targetPlayer, "phoneNumber") 
                 theMsg = tostring(msg) 
                callMessages[#callMessages + 1] = theMsg 
                setElementData(targetPlayer, "char.tempCall", {msgFrom, msgTo, theMsg})          
                       
                renderData.msgCounter = renderData.msgCounter + 1 
                --renderData.currentRow = renderData.currentRow + 1 
                 
                break 
    end 
end  

And the second code loops the "callMessages" table, and write out the value:

if getElementData(localPlayer, "phone") == "goingCall" then 
        dxDrawImage(X, Y + 35, Width, Height, "files/ongoingcall.png") 
        renderData.smsLatestLine = renderData.currentRow + renderData.maxRow - 1 
         
        for k,v in ipairs(callMessages) do 
            if k >= renderData.currentRow then 
               if k <= renderData.smsLatestLine and v then 
                     
                    renderData.smsDrawX = X + 70 
             
                    renderData.smsDrawY = Y + 125 + (renderData.sorokKozKihagyas * (renderData.uzenetSzamolo - 1)) -- this is the important thing, this moves the value, but my problem is when i click again the send button all the values are moving with this. I want that the values are move 10 pixels down from the previous value, but all the messages are moving. 
                    if vanUjSzoveg == true then 
                        renderData.smsDrawY = renderData.uzenetSzamolo * 10  
                    end 
                    dxDrawText(string.gsub(v, "_", " "), renderData.smsDrawX, renderData.smsDrawY, 50, 0, tocolor(255, 255, 255, 255), 2, "arial", "left", "top", false, true, true) 
                end 
            end 
        end 
    end 

So, basically, I want that the values are move 10 pixels down from the previous value. Thank you, i will be so glad if you guys can help me :)

I don't really understand what are you trying to do here, but it seems like the message will be sent to all the players in the server

Posted

when i send a message it moves correctly, but when i send another one, the second and the first message are at the same position, i want that the second msg move down 10 px from the previous one. http://kepfeltoltes.hu/150622/mta-scree ... es.hu_.png

on the photo you can see the 2 messages are at the same pos. Sorry for my bad english, hope you can understand now.

(Yes, sends to everyone, i didn't finished it yet)

Posted

Can't you just insert linebreaks using "Message1\nMessage2"...?

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

In that case store a variable outside of the for loop which increases after every index.

exampleIndex = 10 
  
for k, v in ipairs() do 
   exampleIndex = exampleIndex+10 
   -- 10 -> 20 -> 30 -> 40 etc... 
end 

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
if you can tell me another way of making this chat part, it will good, but i have no idea how to do this.
x,y,z = 0,0,0 
  
for k, v in ipairs() do 
   y = y + 10 
   --Script continues.. 
end 

For a better way, i think you should not use dxDrawText for the messages

Posted

This isn't my problem. My problem with the loop, because i use for loop to get the value of the tables and if i use this, the messages are all moves. i want that when i send a message that message down from the previous one. All the messages are in one table, that is why i ant separate them from eachother.

Posted
This isn't my problem. My problem with the loop, because i use for loop to get the value of the tables and if i use this, the messages are all moves. i want that when i send a message that message down from the previous one. All the messages are in one table, that is why i ant separate them from eachother.

Why don't you use a memo you start from a new line with each message?

Posted

I made it with GUI, but i cannot destroy it. When i click on the send button, creates a GUI label. if i try to destroy it, the last label dissapears, the rest of messages are stay there.

Thanks for your help :)

Posted
I made it with GUI, but i cannot destroy it. When i click on the send button, creates a GUI label. if i try to destroy it, the last label dissapears, the rest of messages are stay there.

Thanks for your help :)

You're welcome, don't hesitate to ask if you have further problems :)

Posted

my next problem is i cannot destroy the GUI :D When i click on the send button, creates a GUI label. if i try to destroy it, the last label dissapears, the rest of messages are stay there.

Posted

Post your code and we might be able to help you :D

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.

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