Jump to content

GUI Problem


isa_Khamdan

Recommended Posts

Posted

I am getting error in these lines of the GUI " Error unexpected symbol near ')'

so can anyone tell me how to fix this?

addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()), 
    function() 
        createwindowPCS() 
    end 
) 

350x20_FFFFFF_FFFFFF_000000_000000.png
Posted

I am getting problem in the line 60 ' Bad argument #1 to pairs ( table expected , got nill )

else when I write the command the gui never shows up?

local PCSTable = { 
    ["Sparrow"] = 469, 
    ["Stuntplane"] = 513, 
    ["BF-400"] = 581, 
    ["Freeway"] = 463, 
    ["Speeder"] = 452, 
    ["Jester"] = 559, 
    ["Sabre"] = 475, 
    ["Police Ranger"] = 599, 
    ["Utility Van"] = 552, 
    ["Tug"] = 583 
} 
  
  
  
  
     function createwindowPCS() 
  
        windowPCS = guiCreateWindow(266, 170, 217, 365, "Private Cars System", false) 
        guiWindowSetSizable(windowPCS, false) 
        guiSetProperty(windowPCS, "CaptionColour", "FFFE6B00") 
  
         
        PCSbutton = guiCreateButton(53, 298, 115, 36, "Create", false, windowPCS) 
        addEventHandler("onClientGUIClick",PCSbutton,createVehicleHandler,false) 
        guiSetVisible(windowPCS,false) 
        populateGridlist() 
        guiSetProperty(PCSbutton[1], "NormalTextColour", "FFAAAAAA") 
        PCSlabel[2] = guiCreateLabel(158, 342, 50, 19, "by Nexus", false, windowPCS) 
        PCSgridlist = guiCreateGridList(10, 54, 197, 238, false, windowPCS) 
        guiGridListAddColumn(PCSgridlist,"Vehicle",0.2) 
        guiGridListAddColumn(PCSgridlist,"Type",0.2) 
        guiGridListSetColumnWidth(PCSgridlist,1,0.4,true) 
        guiGridListSetColumnWidth(PCSgridlist,2,0.5,true) 
  
        PCSscrollbar = guiCreateScrollBar(182, 3, 15, 235, false, false, PCSgridlist)     
    end 
  
  
  
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()), 
    function() 
     createwindowPCS() 
    end 
) 
  
function showwindowPCS() 
    -- if the window isnt visible, show it 
    if not guiGetVisible(windowPCS) then 
        guiSetVisible(windowPCS,true) 
  
        showCursor(true,true) 
    end 
end 
  
-- add the command /vehicleselection and set it to call the showVehicleSelection function 
addCommandHandler("test",showwindowPCS) 
  
function populateGridlist() 
    for name,vehicle in pairs(vehicleSelectionTable) do 
        local row = guiGridListAddRow(PCSTable) 
  
        -- set the text in the first column to the vehicle name 
        guiGridListSetItemText(vehicleSelectionTable,row,1,name,false,false) 
        -- set the text in the second column to the vehicle type 
        guiGridListSetItemText(vehicleSelectionTable,row,2,getVehicleType(vehicle),false,false) 
        -- set the data for gridlist slot as the vehicle id 
        guiGridListSetItemData(vehicleSelectionTable,row,1,tostring(vehicle)) 
    end 
end 
  
function createVehicleHandler(button,state) 
    if button == "left" and state == "up" then 
        -- get the selected item in the gridlist 
        local row,col = guiGridListGetSelectedItem(PCSgridlist) 
  
        -- if something is selected 
        if row and col and row ~= -1 and col ~= -1 then 
            -- get the vehicle id data from the gridlist that is selected 
            local selected = guiGridListGetItemData(PCSgridlist,row,col) 
  
            -- make sure the vehicle id is a number not a string 
            selected = tonumber(selected) 
  
            -- get the players position and rotation 
            local rotz = getPedRotation(getLocalPlayer()) 
            local x,y,z = getElementPosition(getLocalPlayer()) 
            -- find the position directly infront of the player 
            x = x + ( math.cos ( math.rad ( rotz+90 ) ) * 3) 
            y = y + ( math.sin ( math.rad ( rotz+90 ) ) * 3) 
  
            if selected and x and y and z then 
                -- trigger the server 
                triggerServerEvent("createVehicleFromGUI",getRootElement(),selected,x,y,z) 
  
                -- hide the gui and the cursor 
                guiSetVisible(windowPCS,false) 
                showCursor(false,false) 
            else 
                outputChatBox("Invalid arguments.") 
            end 
        else 
            -- otherwise, output a message to the player 
            outputChatBox("Please select a vehicle.") 
        end 
    end 
end 
  
  
function createMyVehicle(vehicleid,x,y,z) 
    -- check all the arguments exist 
    if vehicleid and x and y and z then 
        createVehicle(vehicleid,x,y,z) 
    end 
end 
  
addEvent("createVehicleFromGUI",true) 
addEventHandler("createVehicleFromGUI",root,createMyVehicle) 

350x20_FFFFFF_FFFFFF_000000_000000.png
Posted
local PCSTable = { 
    ["Sparrow"] = 469, 
    ["Stuntplane"] = 513, 
    ["BF-400"] = 581, 
    ["Freeway"] = 463, 
    ["Speeder"] = 452, 
    ["Jester"] = 559, 
    ["Sabre"] = 475, 
    ["Police Ranger"] = 599, 
    ["Utility Van"] = 552, 
    ["Tug"] = 583 
} 
  
  
  
  
     function createwindowPCS() 
  
        windowPCS = guiCreateWindow(266, 170, 217, 365, "Private Cars System", false) 
        guiWindowSetSizable(windowPCS, false) 
        guiSetProperty(windowPCS, "CaptionColour", "FFFE6B00") 
  
        
        PCSbutton = guiCreateButton(53, 298, 115, 36, "Create", false, windowPCS) 
        addEventHandler("onClientGUIClick",PCSbutton,createVehicleHandler,false) 
        guiSetVisible(windowPCS,false) 
        populateGridlist() 
        guiSetProperty(PCSbutton[1], "NormalTextColour", "FFAAAAAA") 
        PCSlabel[2] = guiCreateLabel(158, 342, 50, 19, "by Nexus", false, windowPCS) 
        PCSgridlist = guiCreateGridList(10, 54, 197, 238, false, windowPCS) 
        guiGridListAddColumn(PCSgridlist,"Vehicle",0.2) 
        guiGridListAddColumn(PCSgridlist,"Type",0.2) 
        guiGridListSetColumnWidth(PCSgridlist,1,0.4,true) 
        guiGridListSetColumnWidth(PCSgridlist,2,0.5,true) 
  
        PCSscrollbar = guiCreateScrollBar(182, 3, 15, 235, false, false, PCSgridlist)     
    end 
  
  
  
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()), 
    function() 
     createwindowPCS() 
    end 
) 
  
function showwindowPCS() 
    -- if the window isnt visible, show it 
    if not guiGetVisible(windowPCS) then 
        guiSetVisible(windowPCS,true) 
  
        showCursor(true,true) 
    end 
end 
  
-- add the command /vehicleselection and set it to call the showVehicleSelection function 
addCommandHandler("test",showwindowPCS) 
  
function populateGridlist() 
    for name,vehicle in pairs(PCSTable) do 
        local row = guiGridListAddRow(PCSTable) 
  
        -- set the text in the first column to the vehicle name 
        guiGridListSetItemText(PCSgridlist,row,1,name,false,false) 
        -- set the text in the second column to the vehicle type 
        guiGridListSetItemText(PCSgridlist,row,2,getVehicleType(vehicle),false,false) 
        -- set the data for gridlist slot as the vehicle id 
        guiGridListSetItemData(PCSgridlist,row,1,tostring(vehicle)) 
    end 
end 
  
function createVehicleHandler(button,state) 
    if button == "left" and state == "up" then 
        -- get the selected item in the gridlist 
        local row,col = guiGridListGetSelectedItem(PCSgridlist) 
  
        -- if something is selected 
        if row and col and row ~= -1 and col ~= -1 then 
            -- get the vehicle id data from the gridlist that is selected 
            local selected = guiGridListGetItemData(PCSgridlist,row,col) 
  
            -- make sure the vehicle id is a number not a string 
            selected = tonumber(selected) 
  
            -- get the players position and rotation 
            local rotz = getPedRotation(getLocalPlayer()) 
            local x,y,z = getElementPosition(getLocalPlayer()) 
            -- find the position directly infront of the player 
            x = x + ( math.cos ( math.rad ( rotz+90 ) ) * 3) 
            y = y + ( math.sin ( math.rad ( rotz+90 ) ) * 3) 
  
            if selected and x and y and z then 
                -- trigger the server 
                triggerServerEvent("createVehicleFromGUI",getRootElement(),selected,x,y,z) 
  
                -- hide the gui and the cursor 
                guiSetVisible(windowPCS,false) 
                showCursor(false,false) 
            else 
                outputChatBox("Invalid arguments.") 
            end 
        else 
            -- otherwise, output a message to the player 
            outputChatBox("Please select a vehicle.") 
        end 
    end 
end 
  
  
function createMyVehicle(vehicleid,x,y,z) 
    -- check all the arguments exist 
    if vehicleid and x and y and z then 
        createVehicle(vehicleid,x,y,z) 
    end 
end 
  
addEvent("createVehicleFromGUI",true) 
addEventHandler("createVehicleFromGUI",root,createMyVehicle) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

there is no errors now but the command that show gui doesn't work?

  
  
local PCSTable = { 
  
    ["Sparrow"] = 469, 
  
    ["Stuntplane"] = 513, 
  
    ["BF-400"] = 581, 
  
    ["Freeway"] = 463, 
  
    ["Speeder"] = 452, 
  
    ["Jester"] = 559, 
  
    ["Sabre"] = 475, 
  
    ["Police Ranger"] = 599, 
  
    ["Utility Van"] = 552, 
  
    ["Tug"] = 583 
  
} 
  
  
  
  
  
  
  
  
  
     function createwindowPCS() 
  
  
  
        windowPCS = guiCreateWindow(266, 170, 217, 365, "Private Cars System", false) 
  
        guiWindowSetSizable(windowPCS, false) 
  
        guiSetProperty(windowPCS, "CaptionColour", "FFFE6B00") 
  
  
  
        
  
        PCSbutton = guiCreateButton(53, 298, 115, 36, "Create", false, windowPCS) 
  
        addEventHandler("onClientGUIClick",PCSbutton,createVehicleHandler,false) 
  
        guiSetVisible(windowPCS,false) 
  
  
        PCSlabel = guiCreateLabel(158, 342, 50, 19, "by Nexus", false, windowPCS) 
  
        PCSgridlist = guiCreateGridList(10, 54, 197, 238, false, windowPCS) 
  
        guiGridListAddColumn(PCSgridlist,"Vehicle",0.2) 
  
        guiGridListAddColumn(PCSgridlist,"Type",0.2) 
  
        guiGridListSetColumnWidth(PCSgridlist,1,0.4,true) 
  
        guiGridListSetColumnWidth(PCSgridlist,2,0.5,true) 
  
  
  
        PCSscrollbar = guiCreateScrollBar(182, 3, 15, 235, false, false, PCSgridlist)     
  
    end 
  
  
  
  
  
  
  
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()), 
  
    function() 
  
     createwindowPCS() 
  
    end 
  
) 
  
  
  
function showwindowPCS() 
  
    -- if the window isnt visible, show it 
  
    if not guiGetVisible(windowPCS) then 
  
        guiSetVisible(windowPCS,true) 
  
  
  
        showCursor(true,true) 
  
    end 
  
end 
  
  
  
-- add the command /vehicleselection and set it to call the showVehicleSelection function 
  
addCommandHandler("test",showwindowPCS) 
  
  
  
  
  
  
function createVehicleHandler(button,state) 
  
    if button == "left" and state == "up" then 
  
        -- get the selected item in the gridlist 
  
        local row,col = guiGridListGetSelectedItem(PCSgridlist) 
  
  
  
        -- if something is selected 
  
        if row and col and row ~= -1 and col ~= -1 then 
  
            -- get the vehicle id data from the gridlist that is selected 
  
            local selected = guiGridListGetItemData(PCSgridlist,row,col) 
  
  
  
            -- make sure the vehicle id is a number not a string 
  
            selected = tonumber(selected) 
  
  
  
            -- get the players position and rotation 
  
            local rotz = getPedRotation(getLocalPlayer()) 
  
            local x,y,z = getElementPosition(getLocalPlayer()) 
  
            -- find the position directly infront of the player 
  
            x = x + ( math.cos ( math.rad ( rotz+90 ) ) * 3) 
  
            y = y + ( math.sin ( math.rad ( rotz+90 ) ) * 3) 
  
  
  
            if selected and x and y and z then 
  
                -- trigger the server 
  
                triggerServerEvent("createVehicleFromGUI",getRootElement(),selected,x,y,z) 
  
  
  
                -- hide the gui and the cursor 
  
                guiSetVisible(windowPCS,false) 
  
                showCursor(false,false) 
  
            else 
  
                outputChatBox("Invalid arguments.") 
  
            end 
  
        else 
  
            -- otherwise, output a message to the player 
  
            outputChatBox("Please select a vehicle.") 
  
        end 
  
    end 
  
end 
  
  
  
  
  
function createMyVehicle(vehicleid,x,y,z) 
  
    -- check all the arguments exist 
  
    if vehicleid and x and y and z then 
  
        createVehicle(vehicleid,x,y,z) 
  
    end 
  
end 
  
  
  
addEvent("createVehicleFromGUI",true) 
  
addEventHandler("createVehicleFromGUI",root,createMyVehicle) 

350x20_FFFFFF_FFFFFF_000000_000000.png
Posted

You're welcome.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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