Jump to content

Phone System


shaio

Recommended Posts

I need help creating a phone system with dx GUI, I can't get it to work, this is my code so far.. Please help me out :o

Client.lua -

addEventHandler("onClientRender",root,function() 
    for _,phone in ipairs(getElementsByType("Object")) do 
        if (getObjectModel(phone) == 1216) or (getObjectModel(phone) == 1363) then 
            local x,y,z = getElementPosition(getLocalPlayer()) 
            local vx,vy,vz = getElementPosition(phone) 
            if (getDistanceBetweenPoints3D(x,y,z,vx,vy,vz) <= 4) then 
                addEventHandler("onClientRender",root,function() 
                    dxDrawLine(18 - 1, 536, 286, 536, tocolor(0, 0, 0, 254), 1, false) 
                    dxDrawLine(286, 536, 286, 479 - 1, tocolor(0, 0, 0, 254), 1, false) 
                    dxDrawRectangle(18, 479, 268, 57, tocolor(0, 0, 16, 238), false) 
                    dxDrawImage(28, 487, 44, 39, "/images/phone.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
                    dxDrawText("Press E to use the phone.", 78, 487, 276, 526, tocolor(236, 233, 0, 254), 0.45, "bankgothic", "center", "center", false, false, false, false, false) 
                end) 
            end 
        end 
    end 
end) 

Meta.xml -

<meta> 
    <script src="client.lua" type="client"/> 
    <file src="images/phone.png"/> 
</meta> 

phone.png -

phone-128.png

Link to comment
I need help creating a phone system with dx GUI, I can't get it to work, this is my code so far.. Please help me out :o

Client.lua -

addEventHandler("onClientRender",root,function() 
    for _,phone in ipairs(getElementsByType("object")) do 
        if (getObjectModel(phone) == 1216) or (getObjectModel(phone) == 1363) then 
            local x,y,z = getElementPosition(getLocalPlayer()) 
            local vx,vy,vz = getElementPosition(phone) 
            if (getDistanceBetweenPoints3D(x,y,z,vx,vy,vz) <= 4) then 
                addEventHandler("onClientRender",root,function() 
                    dxDrawLine(18 - 1, 536, 286, 536, tocolor(0, 0, 0, 254), 1, false) 
                    dxDrawLine(286, 536, 286, 479 - 1, tocolor(0, 0, 0, 254), 1, false) 
                    dxDrawRectangle(18, 479, 268, 57, tocolor(0, 0, 16, 238), false) 
                    dxDrawImage(28, 487, 44, 39, "/images/phone.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
                    dxDrawText("Press E to use the phone.", 78, 487, 276, 526, tocolor(236, 233, 0, 254), 0.45, "bankgothic", "center", "center", false, false, false, false, false) 
                end) 
            end 
        end 
    end 
end) 

Meta.xml -

<meta> 
    <script src="client.lua" type="client"/> 
    <file src="images/phone.png"/> 
</meta> 

phone.png -

phone-128.png

Try this one:

addEventHandler("onClientRender",root,function() 
    for _,phone in ipairs(getElementsByType("Object")) do 
        if (getObjectModel(phone) == 1216) or (getObjectModel(phone) == 1363) then 
            local x,y,z = getElementPosition(getLocalPlayer()) 
            local vx,vy,vz = getElementPosition(phone) 
            if (getDistanceBetweenPoints3D(x,y,z,vx,vy,vz) <= 4) then 
                    dxDrawLine(18 - 1, 536, 286, 536, tocolor(0, 0, 0, 254), 1, false) 
                    dxDrawLine(286, 536, 286, 479 - 1, tocolor(0, 0, 0, 254), 1, false) 
                    dxDrawRectangle(18, 479, 268, 57, tocolor(0, 0, 16, 238), false) 
                    dxDrawImage(28, 487, 44, 39, "images/phone.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
                    dxDrawText("Press E to use the phone.", 78, 487, 276, 526, tocolor(236, 233, 0, 254), 0.45, "bankgothic", "center", "center", false, false, false, false, false) 
                end 
            end 
        end 
    end 
end) 

Make sure that the phones are added by script or .map file

Link to comment
Try this one:
addEventHandler("onClientRender",root,function() 
    for _,phone in ipairs(getElementsByType("Object")) do 
        if (getObjectModel(phone) == 1216) or (getObjectModel(phone) == 1363) then 
            local x,y,z = getElementPosition(getLocalPlayer()) 
            local vx,vy,vz = getElementPosition(phone) 
            if (getDistanceBetweenPoints3D(x,y,z,vx,vy,vz) <= 4) then 
                    dxDrawLine(18 - 1, 536, 286, 536, tocolor(0, 0, 0, 254), 1, false) 
                    dxDrawLine(286, 536, 286, 479 - 1, tocolor(0, 0, 0, 254), 1, false) 
                    dxDrawRectangle(18, 479, 268, 57, tocolor(0, 0, 16, 238), false) 
                    dxDrawImage(28, 487, 44, 39, "images/phone.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
                    dxDrawText("Press E to use the phone.", 78, 487, 276, 526, tocolor(236, 233, 0, 254), 0.45, "bankgothic", "center", "center", false, false, false, false, false) 
                end 
            end 
        end 
    end 
end) 

Make sure that the phones are added by script or .map file

But by doing this

for _,phone in ipairs(getElementsByType("Object")) do 
if (getObjectModel(phone) == 1216) or (getObjectModel(phone) == 1363) then 

it grabs all of the phone OBJECTS in the map, whether they are added by map, script or not added at all.. The script doesn't work yet :(

Link to comment
Try this one:
addEventHandler("onClientRender",root,function() 
    for _,phone in ipairs(getElementsByType("Object")) do 
        if (getObjectModel(phone) == 1216) or (getObjectModel(phone) == 1363) then 
            local x,y,z = getElementPosition(getLocalPlayer()) 
            local vx,vy,vz = getElementPosition(phone) 
            if (getDistanceBetweenPoints3D(x,y,z,vx,vy,vz) <= 4) then 
                    dxDrawLine(18 - 1, 536, 286, 536, tocolor(0, 0, 0, 254), 1, false) 
                    dxDrawLine(286, 536, 286, 479 - 1, tocolor(0, 0, 0, 254), 1, false) 
                    dxDrawRectangle(18, 479, 268, 57, tocolor(0, 0, 16, 238), false) 
                    dxDrawImage(28, 487, 44, 39, "images/phone.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
                    dxDrawText("Press E to use the phone.", 78, 487, 276, 526, tocolor(236, 233, 0, 254), 0.45, "bankgothic", "center", "center", false, false, false, false, false) 
                end 
            end 
        end 
    end 
end) 

Make sure that the phones are added by script or .map file

But by doing this

for _,phone in ipairs(getElementsByType("Object")) do 
if (getObjectModel(phone) == 1216) or (getObjectModel(phone) == 1363) then 

it grabs all of the phone OBJECTS in the map, whether they are added by map, script or not added at all.. The script doesn't work yet

Look what Wumbaloo said..

for _,phone in ipairs(getElementsByType("object")) do 

and use

getElementModel() not getObjectModel()

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