Jump to content

I need help with 1 line, about gridlist.


Adde

Recommended Posts

Hello, I got 1 line here that doesn´t do what it is ment to do. I have tried with "if ( guiGridListGetSelectedItem(teamGridlist) ) then" and "if guiGridListGetSelectedItem(teamGridlist) then" but non of them works.

If the player haven´t selected anything in the gridlist then it should do "outputChatBox" instead of this "triggerClientEvent, showCursor and setGuiVisible". But it doesn´t work. It closes the gui even if I have selected a row in gridlist or not.

Would be thankfull if I got a little help in this part.

Here´s the function I need help with:

function click () 
if guiGridListGetSelectedItem(teamGridlist) then 
    local theRow, theCol = guiGridListGetSelectedItem(teamGridlist) 
      local teamName = guiGridListGetItemText(teamGridlist, theRow, theCol) 
        triggerServerEvent("chooseTeam", localPlayer, teamName) 
        guiSetVisible(spawnWindow, false) 
        showCursor(false) 
else 
outputChatBox("You have to choose a team before you press spawn", localPlayer, 220, 0, 0) 
  end 
end 
addEventHandler("onClientGUIClick", spawnButton, click) 

Link to comment
Hello, I got 1 line here that doesn´t do what it is ment to do. I have tried with "if ( guiGridListGetSelectedItem(teamGridlist) ) then" and "if guiGridListGetSelectedItem(teamGridlist) then" but non of them works.

If the player haven´t selected anything in the gridlist then it should do "outputChatBox" instead of this "triggerClientEvent, showCursor and setGuiVisible". But it doesn´t work. It closes the gui even if I have selected a row in gridlist or not.

Would be thankfull if I got a little help in this part.

Here´s the function I need help with:

function click () 
if guiGridListGetSelectedItem(teamGridlist) then 
    local theRow, theCol = guiGridListGetSelectedItem(teamGridlist) 
      local teamName = guiGridListGetItemText(teamGridlist, theRow, theCol) 
        triggerServerEvent("chooseTeam", localPlayer, teamName) 
        guiSetVisible(spawnWindow, false) 
        showCursor(false) 
else 
outputChatBox("You have to choose a team before you press spawn", localPlayer, 220, 0, 0) 
  end 
end 
addEventHandler("onClientGUIClick", spawnButton, click) 

Change it to :

if guiGridListGetSelectedItem (teamGridlist) ~= -1 then 

And try it again.

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