Stranger Posted November 7, 2013 Share Posted November 7, 2013 hello guys i have a little problem in this code : addEventHandler("onClientMarkerHit", marker, function () guiSetVisible(win, true) showCursor(true) local pla = getPlayerFromName(getLocalPlayer()) for _,v in ipairs (pla) do guiGridListAddRow(v) end end ) will i try to make the players show in the 'gridlist' but no, i don't know why, so can you help me Link to comment
TAPL Posted November 7, 2013 Share Posted November 7, 2013 You know what is getPlayerFromName does? This is much stupid to do such thing. You trying to get the local player using getPlayerFromName which it's require string not element and it actually make no sense to do because local player is already predefined!? This make no sense at all. local pla = getPlayerFromName(getLocalPlayer()) pla is not table and it's not even a element because it would be always false regarding to what you did above. for _,v in ipairs (pla) do This is not a magic, it only will add the row and you also need to set a text to the row using guiGridListSetItemText guiGridListAddRow(v) I don't understand why you did all this mess which you can simply open the wiki and copy the example of function guiGridListAddRow. Link to comment
Stranger Posted November 7, 2013 Author Share Posted November 7, 2013 so how can i refresh the list ? Link to comment
pa3ck Posted November 7, 2013 Share Posted November 7, 2013 Read this: guiGridListAddRow. Its the best example. Link to comment
TAPL Posted November 7, 2013 Share Posted November 7, 2013 You can use this and be sure to replace gridList and column with your. function updateList(old, new) if eventName == "onClientPlayerJoin" then local row = guiGridListAddRow(gridList) guiGridListSetItemText(gridList, row, column, getPlayerName(source), false, false) elseif eventName == "onClientPlayerQuit" then for i=0, guiGridListGetRowCount(gridList) do if guiGridListGetItemText(gridList, i, column) == getPlayerName(source) then guiGridListRemoveRow(gridList, i) end end elseif eventName == "onClientPlayerChangeNick" then for i=0, guiGridListGetRowCount(gridList) do if guiGridListGetItemText(gridList, i, column) == old then guiGridListSetItemText(gridList, i, column, new, false, false) end end end end addEventHandler("onClientPlayerJoin", root, updateList) addEventHandler("onClientPlayerQuit", root, updateList) addEventHandler("onClientPlayerChangeNick", root, updateList) Link to comment
Stranger Posted November 7, 2013 Author Share Posted November 7, 2013 your code it's work fine, but when player join, his name don't show but the other people they can see it, but if he quit and join all the name in the grid will removed, i didn't mean like that, i mean when someone click the 'close' button then clear grid list, i wan't the grid refresh every 5 secs, is that possible ? Link to comment
TAPL Posted November 7, 2013 Share Posted November 7, 2013 This code was for ***update*** the list ONLY, you still need to use the example of guiGridListAddRow. Link to comment
Stranger Posted November 7, 2013 Author Share Posted November 7, 2013 now i did use it with your code, but another porblem show, that if player quit "his name still in the grid list", or if he change his nick ... Link to comment
Stranger Posted November 7, 2013 Author Share Posted November 7, 2013 will thank you 'TAPL' i use that when i click 'close' button then clear grid list and put timer to add the players again after 2 sec any way, thank you for helping me Link to comment
Stranger Posted November 7, 2013 Author Share Posted November 7, 2013 what is the problem in this code ? addEventHandler("onClientGUIClick", root, function () local row2, col = guiGridListGetSelectedItem(grid) local select = guiGridListGetItemText(grid, row2, col) if (source == warp) then if select then triggerServerEvent("warp", getLocalPlayer()) end end end ) server : addEvent("warp", true) addEventHandler("warp", root, function () x,y,z = getElementPosition(client) setElementPosition(source, x+1,y+1,z+1) end ) the problem is when i select player and press warp nothing happend, i wan't when some one select a player and press warp then warp to him Link to comment
Price. Posted November 7, 2013 Share Posted November 7, 2013 well this is weird getElementPosition(client) ? try this addEvent("warp", true) addEventHandler("warp", root, function () local x,y,z = getElementPosition(source) setElementPosition(source, x+1,y+1,z+1) end ) not sure. Link to comment
Price. Posted November 7, 2013 Share Posted November 7, 2013 addEventHandler("onClientGUIClick", root, function () local row2, col = guiGridListGetSelectedItem(grid) local select = guiGridListGetItemText(grid, row2, col) if (source == warp) then triggerServerEvent("warp", getLocalPlayer()) end end ) Link to comment
Stranger Posted November 7, 2013 Author Share Posted November 7, 2013 (edited) not working if i select someone he is not go to him he go to himself Edited November 7, 2013 by Guest Link to comment
Stranger Posted November 7, 2013 Author Share Posted November 7, 2013 no but, if i select someone he is not go to him he go to himself Link to comment
Price. Posted November 7, 2013 Share Posted November 7, 2013 uhm btw you need to use setElementPosition Link to comment
Stranger Posted November 7, 2013 Author Share Posted November 7, 2013 it really in use addEvent("warp", true) addEventHandler("warp", root, function () local x,y,z = getElementPosition(source) setElementPosition(source, x+1,y+1,z+1) end ) Link to comment
TAPL Posted November 7, 2013 Share Posted November 7, 2013 now i did use it with your code, but another porblem show, that if player quit "his name still in the grid list", or if he change his nick ... That's because you didn't follow this: You can use this and be sure to replace gridList and column with your. what is the problem in this code ? addEventHandler("onClientGUIClick", root, function () local row2, col = guiGridListGetSelectedItem(grid) local select = guiGridListGetItemText(grid, row2, col) if (source == warp) then if select then triggerServerEvent("warp", getLocalPlayer()) end end end ) server : addEvent("warp", true) addEventHandler("warp", root, function () x,y,z = getElementPosition(client) setElementPosition(source, x+1,y+1,z+1) end ) the problem is when i select player and press warp nothing happend, i wan't when some one select a player and press warp then warp to him addEventHandler("onClientGUIClick", root, function () if (source == warp) then local row, col = guiGridListGetSelectedItem(grid) local select = guiGridListGetItemText(grid, row, col) if select and select ~= "" then local player = getPlayerFromName(select) if player then local x, y, z = getElementPosition(player) setElementPosition(localPlayer, x+1, y+1, z+1) end end end end) No need for server side. Link to comment
Stranger Posted November 7, 2013 Author Share Posted November 7, 2013 Thank you so much 'TAPL' 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