Jump to content

Phone System Error


micheal1230

Recommended Posts

Title Says All

Error

mtaphoneerror.jpg

Phone Script

Client:

local sx, sy = guiGetScreenSize() 
pVisible = false
local volume = 0.3
local currentPlaying = nil
local state = nil
stationsNames = {}
stations = {}
 
function isNumericKey(key)
    if ( key == "0" or key == "1" or key == "2" or key == "3" or key == "4" or key == "5" or key == "6" or key == "7" or key == "8" or key == "9" ) then
        return true
    else
        return false
    end
end
 
 
function phonePurchase()
phoneWin = guiCreateWindow(0.334,0.4284,0.3467,0.1589,"Phone: Number",true)
guiSetAlpha(phoneWin, 255)
pnL = guiCreateLabel(0.3099,0.1721,0.3662,0.1721,"Select a phone number",true,phoneWin)
local actualPhoneNumber = guiCreateEdit(0.307,0.4098,0.3746,0.1967,"",true,phoneWin)
guiEditSetMaxLength(actualPhoneNumber,5)
subB = guiCreateButton(0.2197,0.7787,0.2479,0.1475,"Submit",true,phoneWin)
addEventHandler("onClientGUIClick", subB,
function()
    realNumber = guiGetText(actualPhoneNumber)
    if (string.len(realNumber)==5) then
        setElementData(localPlayer, "temp.number", guiGetText(actualPhoneNumber))
        triggerServerEvent("verifyNumber", root, localPlayer, getElementData(localPlayer, "temp.number"))
    else
    outputChatBox("((Your phone number must be 5 digits long))", 255,0,0)
    end
end, false)
canB = guiCreateButton(0.5183,0.7787,0.2479,0.1475,"Cancel",true,phoneWin)
addEventHandler("onClientGUIClick", canB,
function()
destroyElement(phoneWin)
end
, false)
end
 
addEvent("purchasePhone", true)
addEventHandler("purchasePhone", root, phonePurchase)
 
 
function phoneContract()
destroyElement(phoneWin)
phoneContractWin = guiCreateWindow(0.334,0.4284,0.3467,0.3,"Phone: Contract",true)
guiSetAlpha(phoneContractWin, 255)
contractL = guiCreateLabel(0.3099,0.1721,0.3662,0.1721,"Select a phone contact",true,phoneContractWin)
contractInfo = guiCreateLabel(.2,.43,.6,.4,"Select view to view contract details. The money value will be deducted from your payday.", true,phoneContractWin)
guiLabelSetHorizontalAlign(contractInfo,"left",true)
contractSel =  guiCreateComboBox(0.25,0.3,0.5,0.5,"Select a contract",true,phoneContractWin)
guiComboBoxAddItem( contractSel, "Basic Contract $10" )
guiComboBoxAddItem( contractSel, "Advanced Contract $50" )
guiComboBoxAddItem( contractSel, "Unlimited Contract $200" )
contractSub = guiCreateButton(0.18,0.8,0.3,0.1,"View",true,phoneContractWin)
addEventHandler("onClientGUIClick", contractSub,
function()
guiSetVisible ( phoneContractWin, false )
local contractOptions = guiComboBoxGetSelected ( contractSel )
    if contractOptions == 0 then
    bContract = guiCreateWindow(0.3936,0.444,0.2246,0.1979,"Basic Contract",true)
    guiSetAlpha(bContract, 255)
    basicL = guiCreateLabel(0.0783,0.1974,0.8609,0.5658,"-SMS \
                                                                -Calling \
                                                                \
                                                                \
                                                                \
                                                                The basics for your phone.",true,bContract)
    guiLabelSetHorizontalAlign(basicL,"left",true)
    basicBuy = guiCreateButton(0.113,0.8289,0.3522,0.1118,"Purchase",true,bContract)
    addEventHandler("onClientGUIClick", basicBuy,
        function()
        triggerServerEvent("registerPhone", root, localPlayer, 1, getElementData(localPlayer,"temp.number"))
        destroyElement(bContract)
        end, false)
    bacisGB = guiCreateButton(0.5522,0.8289,0.3522,0.1118,"Go Back",true,bContract)
    addEventHandler("onClientGUIClick", bacisGB,
        function()
        guiSetVisible ( phoneContractWin, true )
        guiSetVisible ( bContract, false )
        end, false)
       
    elseif contractOptions == 1 then
    aContract = guiCreateWindow(0.3936,0.444,0.2246,0.1979,"Advanced Contract",true)
    guiSetAlpha(aContract, 255)
    advL = guiCreateLabel(0.0783,0.1974,0.8609,0.5658,"-SMS \
                                                  -Calling\
                                                  -Web",true,aContract)
    guiLabelSetHorizontalAlign(advL,"left",true)
    advBuy = guiCreateButton(0.113,0.8289,0.3522,0.1118,"Purchase",true,aContract)
    addEventHandler("onClientGUIClick", advBuy,
        function()
        triggerServerEvent("registerPhone", root, localPlayer, 2, getElementData(localPlayer,"temp.number"))
        destroyElement(aContract)
        end, false)
    advGB = guiCreateButton(0.5522,0.8289,0.3522,0.1118,"Go Back",true,aContract)
    addEventHandler("onClientGUIClick", advGB,
        function()
        guiSetVisible ( phoneContractWin, true )
        guiSetVisible ( aContract, false )
        end, false)
   
    elseif contractOptions == 2 then
    uContract = guiCreateWindow(0.3936,0.444,0.2246,0.1979,"Unlimited Contract",true)
    guiSetAlpha(uContract, 255)
    ultL = guiCreateLabel(0.0783,0.1974,0.8609,0.5658,"-SMS \
                                                  -Calling\
                                                  -Web\
                                                  -Global Caller ID\
                                                  -GPS\
                                                   ",true,uContract)
    guiLabelSetHorizontalAlign(ultL,"left",true)
    ultBuy = guiCreateButton(0.113,0.8289,0.3522,0.1118,"Purchase",true,uContract)
    addEventHandler("onClientGUIClick", ultBuy,
        function()
        triggerServerEvent("registerPhone", root, localPlayer, 3, getElementData(localPlayer,"temp.number"))
        destroyElement(uContract)
        end, false)
    ultGB = guiCreateButton(0.5522,0.8289,0.3522,0.1118,"Go Back",true,uContract)
    addEventHandler("onClientGUIClick", ultGB,
        function()
        guiSetVisible ( phoneContractWin, true )
        guiSetVisible ( uContract, false )
        end, false)
 
    elseif contractOptions == -1 then
    outputChatBox("((You must select a contract to view it))", 255,0,0)
    end
end
, false)
 
contractCan = guiCreateButton(0.5183,0.8,0.3,0.1,"Cancel",true,phoneContractWin)
addEventHandler("onClientGUIClick", contractCan,
        function()
        destroyElement(phoneContractWin)
        end, false)
 
 
end
addEvent("phoneContract", true)
addEventHandler("phoneContract", root, phoneContract)
 
 
 
 
----------------------------------------------------
------------------Phone Graphic---------------------
----------------------------------------------------
 
 
togPhone = function(itemValue)
phoneVal = itemValue
  if getElementHealth(localPlayer) < 1 then
    return
  end
  if iphoneMoving then
    return
  end
  if pVisible then
    showCursor(false)
    addEventHandler("onClientRender", root, iphoneCloseAnim)
    iphoneMoving = true
  else
    showCursor(true)
    addEventHandler("onClientRender", root, iphoneOpenAnim)
    iphoneMoving = true
    togIcon(true)
  end
end
addEvent("showPhoneDX", true)
addEventHandler("showPhoneDX", root, togPhone)
 
local resX, resY = guiGetScreenSize()
iphoneOpenAnim = function()
  for i = 1, 14 do
    local x, y = guiGetPosition(phoneMain, false)
    guiSetPosition(phoneMain, x, y-1, false)
    if y == resY - 500 then
      pVisible = true
      iphoneMoving = false
      removeEventHandler("onClientRender", root, iphoneOpenAnim)
      addEventHandler("onClientClick", root, pHome)
      return
    end
  end
end
 
iphoneCloseAnim = function()
  local x, y = guiGetPosition(phoneMain, false)
  guiSetPosition(phoneMain, x, y+10, false)
  if resY < y then
    pVisible = false
    iphoneMoving = false
    removeEventHandler("onClientRender", root, iphoneCloseAnim)
    removeEventHandler("onClientClick", root, pHome)
  end
end
 
 
 
function phoneFuncts ( button )
    if not phoneVal then
    return
    end
       
    if button == "left" then
        if source == iWeather then
        triggerServerEvent("weatherRepo", root, localPlayer, phoneVal)
        elseif source == mapApp then   
        triggerServerEvent("mapFunc", root, localPlayer, phoneVal)
        elseif source == iRusty then
        triggerServerEvent("rustyApp", root, localPlayer, phoneVal)
        elseif source == iScann then
        outputChatBox("SCANN is coming soon!", 255,0,0)
        elseif source == iBank then
        outputChatBox("Banking is coming soon!", 255,0,0)
        elseif source == iStocks then
        outputChatBox("Stocks are coming soon!", 255,0,0)
        else
        togIcon(false)
        if source == iEmail then
        outputDebugString("Winner")
        elseif source == iNotepad then
        triggerServerEvent("getNotes", root, localPlayer, phoneVal)
        guiSetInputEnabled ( true )
        elseif source == iSettings then
        menuID = 2
        pNumber = guiCreateLabel(0.13,0.25,0.65,0.13,"Your Phone number: "..phoneVal.."",true, phoneMain)
        togPowerp = guiCreateLabel(0.13,0.4,0.65,0.13,"Power On/Off:",true, phoneMain)
        toPowerb = guiCreateButton(0.55,0.4,0.2,0.05,"Off/On",true, phoneMain)
        addEventHandler("onClientGUIClick", toPowerb,
        function()
        triggerServerEvent("togglePhone", root, localPlayer, phoneVal)     
        end,false)
        toContb = guiCreateButton(0.25,0.7,0.5,0.1,"Upgrade Contract",true, phoneMain)
        addEventHandler("onClientGUIClick", toContb,
        function()
        menuID = 1
        destroyElement(pNumber)
        destroyElement(togPowerp)
        destroyElement(toPowerb)
        destroyElement(toContb)
        basPOption =  guiCreateButton(0.25,0.25,0.5,0.1,"Basic Contract $10",true,phoneMain)
        addEventHandler("onClientGUIClick", basPOption, function()
        triggerServerEvent("contractUpdate", root, localPlayer, phoneVal, 1)
        end, false)
        advPOption =  guiCreateButton(0.25,0.4,0.5,0.1,"Advanced Contract $50",true,phoneMain)
       
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...