Jump to content

Invalid data or something? I can't figure the problem out.


Deltanic

Recommended Posts

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 by Guest
Link to comment
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
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? :P

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

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

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

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