Deltanic Posted July 23, 2010 Share Posted July 23, 2010 (edited) local thisPlayer = getLocalPlayer ( ) function populateWarpToGridlist ( ) -- Populating and showing the gridlist with all the players inside guiGridListClear ( GUIPopupGrid_Grid ) guiSetText ( GUIPopupGrid_Window, "Warp To" ) for _,player in ipairs ( getElementsByType ( "player" ) ) do local row = guiGridListAddRow ( GUIPopupGrid_Grid ) local name = getPlayerName ( player ) guiGridListSetItemText ( GUIPopupGrid_Grid, row, 1, name, false, false) guiGridListSetItemData ( GUIPopupGrid_Grid, row, 1, tostring ( player ) ) end showGridlistGUI ( ) setElementData ( thisPlayer, "PopupType", "warpto" ) end That clientscript looks fine to me. It builds up all players, without faults. But, I cannot warp to them by doubleclicking someone. The itemdata seem to give always an error. local row, col = guiGridListGetSelectedItem ( GUIPopupGrid_Grid ) local selected = guiGridListGetItemData ( GUIPopupGrid_Grid, row, col ) if getElementData ( thisPlayer, "PopupType" ) == "warpto" then selected = tonumber ( selected ) if selected then triggerServerEvent ( "warpMeTo", getLocalPlayer( ), selected ) else outputChatBox ( "Error while warping you." ) -- Always returns this end end But it's the same technique as all my other gridlists, and they all work, except this one. WHY? Edited July 23, 2010 by Guest Link to comment
50p Posted July 23, 2010 Share Posted July 23, 2010 What's thisPlayer? And what error are you talking about? Link to comment
12p Posted July 23, 2010 Share Posted July 23, 2010 function populateWarpToGridlist ( ) -- Populating and showing the gridlist with all the players inside guiGridListClear ( GUIPopupGrid_Grid ) guiSetText ( GUIPopupGrid_Window, "Warp To" ) for _,player in ipairs ( getElementsByType ( "player" ) ) do local row = guiGridListAddRow ( GUIPopupGrid_Grid ) local name = getPlayerName ( player ) guiGridListSetItemText ( GUIPopupGrid_Grid, row, 1, name, false, false) guiGridListSetItemData ( GUIPopupGrid_Grid, row, 1, tostring ( player ) ) end showGridlistGUI ( ) setElementData ( thisPlayer, "PopupType", "warpto" ) end I guess the problem is here (if there is a problem : function populateWarpToGridlist ( ) -- No defined "thisPlayer" as an element. guiGridListClear ( GUIPopupGrid_Grid ) Link to comment
Deltanic Posted July 23, 2010 Author Share Posted July 23, 2010 What's thisPlayer? And what error are you talking about? Forgot to mention that, but it wouldnt be too hard by considering about this: getLocalPlayer ( ), isn't it? And the error is described the second script, it always returns me the error message. --.... Blah if selected then triggerServerEvent ( "warpMeTo", getLocalPlayer ( ), selected ) else outputChatBox ( "Error while warping you." ) -- Always returns this end end Link to comment
50p Posted July 23, 2010 Share Posted July 23, 2010 To me it looks like you try to convert selected a string like: "userdata: " to a number which is never going to work because tonumber will not convert "userdata: " to a number. Link to comment
Deltanic Posted July 23, 2010 Author Share Posted July 23, 2010 Well, with or without tonumber, it doesn't work. But I use the same system to build weather, weapon, skin and animation gridlists, with almost the same code, and they all work. The only difference is that they work with XML files and the warpto with getElementsByType. So I still don't know the problem. Link to comment
50p Posted July 23, 2010 Share Posted July 23, 2010 Well, with or without tonumber, it doesn't work. But I use the same system to build weather, weapon, skin and animation gridlists, with almost the same code, and they all work. The only difference is that they work with XML files and the warpto with getElementsByType. So I still don't know the problem. guiGridListSetItemData ( GUIPopupGrid_Grid, row, 1, tostring ( player ) ) This is the problem... Do you have any idea what tostring does? Or what tostring( player ) will return? Then go and check it for yourself.. Don't expect me to spoon feed you this information. Other scripts work because you probably convert a number to a string which you then convert back to a number. Link to comment
Deltanic Posted July 23, 2010 Author Share Posted July 23, 2010 And what if I tell you it still doesn't work by just using player? That's why I don't know the problem, I tried it already. Link to comment
50p Posted July 23, 2010 Share Posted July 23, 2010 And what if I tell you it still doesn't work by just using player? That's why I don't know the problem, I tried it already. Because the data has to be string not an element. You probably get a warning message in your debug window if you use something else than string. Either use their names or account name or ID if you have an id system. Link to comment
Deltanic Posted July 23, 2010 Author Share Posted July 23, 2010 Using their names like guiGridListSetItemData(... , name ) doesn't work either. Link to comment
50p Posted July 23, 2010 Share Posted July 23, 2010 Are you trying to convert name to a number? You have to modify rest of the script to work the way you want... It won't start working just because you put name in there... Link to comment
Deltanic Posted July 24, 2010 Author Share Posted July 24, 2010 No-hooh, I'm not converting it to a number. Damn, I'm not completely that dumb as you might think. But thanx anyway, it works now. I don't know what's different from first, I don't what caused the problem, and I don't know what fixed it.. WTF again, but now it isn't a problem anyomore. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now