HUNGRY:3 Posted June 22, 2015 Share Posted June 22, 2015 hello every body i'm trying to make a window.... with 1 button and a grid list in the grid list i want it to show online players nicks that has an elementData getElementData(source,"RUN") == true can some body tell me how to do it? Link to comment
Dealman Posted June 22, 2015 Share Posted June 22, 2015 Get all the players using getElementsByType. Then loop through the player and get their data using getElementData. If the data is true, you can either add them to a new table - or just add it directly to the gridlist. Link to comment
HUNGRY:3 Posted June 22, 2015 Author Share Posted June 22, 2015 (edited) i did it but it shows all the players how to make it for the players who has the data of "RUN" code: setTimer( function( ) guiSetText(GUIEditor.label[8], 'ONLINE PLAYERS IN RUN: '.. #getElementsByType('player') ) end, 100, 0 ) Edited June 22, 2015 by Guest Link to comment
jingzhi Posted June 22, 2015 Share Posted June 22, 2015 i did it but it shows all the players how to make it for the players who has the data of "RUN"code: setTimer( function( ) guiSetText(GUIEditor.label[8], 'ONLINE PLAYERS IN RUN: '.. if #getElementsByType('player') ) end, 100, 0 ) for i,v in ipairs(getElementsByType("player")) if getElementData(v,"RUN") then --Here is your code end end Link to comment
HUNGRY:3 Posted June 22, 2015 Author Share Posted June 22, 2015 i did it but it shows all the players how to make it for the players who has the data of "RUN"code: setTimer( function( ) guiSetText(GUIEditor.label[8], 'ONLINE PLAYERS IN RUN: '.. if #getElementsByType('player') ) end, 100, 0 ) for i,v in ipairs(getElementsByType("player")) if getElementData(v,"RUN") then --Here is your code end end not working Link to comment
jingzhi Posted June 22, 2015 Share Posted June 22, 2015 i did it but it shows all the players how to make it for the players who has the data of "RUN"code: setTimer( function( ) guiSetText(GUIEditor.label[8], 'ONLINE PLAYERS IN RUN: '.. if #getElementsByType('player') ) end, 100, 0 ) for i,v in ipairs(getElementsByType("player")) if getElementData(v,"RUN") then --Here is your code end end Show me your code not working Link to comment
HUNGRY:3 Posted June 22, 2015 Author Share Posted June 22, 2015 for i,v in ipairs(getElementsByType("player")) if getElementData(v,"RUN") then setTimer( function( ) guiSetText(GUIEditor.label[8], 'ONLINE PLAYERS IN RUN: '.. #getElementsByType('player') ) end, 100, 0 ) end Link to comment
Tomas Posted June 22, 2015 Share Posted June 22, 2015 function getPlayers() playersInRun = {} for index, players in ipairs ( getElementsByType("player") ) do if getElementData(players, "RUN") then table.insert(playersInRun, players) end end end setTimer(getPlayers, 2500, 0) guiSetText(GUIEditor.label[8], 'ONLINE PLAYERS IN RUN: '.. #playersInRun) Link to comment
Image Posted June 23, 2015 Share Posted June 23, 2015 function getPlayers() local playersInRun = {} for index, players in pairs ( getElementsByType("player") ) do if getElementData(players, "RUN") then table.insert(playersInRun, players) end end guiSetText(GUIEditor.label[8], 'ONLINE PLAYERS IN RUN: '.. #playersInRun) end setTimer(getPlayers, 2500, 0) Link to comment
Walid Posted June 23, 2015 Share Posted June 23, 2015 (edited) Try this it should : -- Server side function getPlayers() local playersInRun = {} for index, players in ipairs (getElementsByType("player")) do if getElementData(players, "RUN") then table.insert(playersInRun, players) end end return playersInRun end function hijackerDC () if getElementData(source, "RUN") then table.removevalue( readyPlayerList, source ) end end addEventHandler("onPlayerQuit",root, hijackerDC) -- table.removevalue function, in case you don't already have it function table.removevalue(t, val) for i,v in ipairs(t) do if v == val then table.remove(t, i) return i end end return false end -- use triggerClientEvent then send the whole table to the client side -- Client side function addRunPlayer(table) local playerGrid = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) local column = guiGridListAddColumn( playerGrid, "Player", 0.85 ) if column then for id, player in ipairs(table) do local row = guiGridListAddRow ( playerGrid ) guiGridListSetItemText ( playerGrid, row, column, getPlayerName ( player ), false, false ) end end end -- Add you event handler here Edited June 23, 2015 by Guest Link to comment
iMr.Dawix~# Posted June 23, 2015 Share Posted June 23, 2015 Try this it should : function getPlayers() local playersInRun = {} for index, players in ipairs (getElementsByType("player")) do if getElementData(players, "RUN") then table.insert(playersInRun, players) end end return playersInRun end function hijackerDC () if getElementData(players, "RUN") then table.removevalue( readyPlayerList, source ) end end addEventHandler("onPlayerQuit",root, hijackerDC) -- table.removevalue function, in case you don't already have it function table.removevalue(t, val) for i,v in ipairs(t) do if v == val then table.remove(t, i) return i end end return false end 12. if getElementData(players, "RUN") then players = nil Link to comment
Walid Posted June 23, 2015 Share Posted June 23, 2015 if getElementData(players, "RUN") then players = ? What ??? open your eyes I didn't finish the code. for index, players in ipairs (getElementsByType("player")) do end Link to comment
iMr.Dawix~# Posted June 23, 2015 Share Posted June 23, 2015 if getElementData(players, "RUN") then players = ? What ??? open your eyes I didn't finish the code. for index, players in ipairs (getElementsByType("player")) do end i was mean line 12 , but you edit it Link to comment
HUNGRY:3 Posted June 23, 2015 Author Share Posted June 23, 2015 did i do some thing wrong? client: function addRunPlayer(table) GUIEditor.gridlist[8] = guiCreateGridList(9, 104, 589, 273, false, GUIEditor.window[8]) column = guiGridListAddColumn( GUIEditor.gridlist[8], "Players", 0.85 ) if column then for id, player in ipairs(table) do row = guiGridListAddRow ( GUIEditor.gridlist[8] ) guiGridListSetItemText ( GUIEditor.gridlist[8], row, column, getPlayerName ( player ), false, false ) end end end addEvent( "RUN3", true ) addEventHandler( "RUN3", root, addRunPlayer ) server: function getPlayers() local playersInRun = {} for index, players in ipairs (getElementsByType("player")) do if getElementData(players, "RUN") then table.insert(playersInRun, players) end end return playersInRun end function hijackerDC () if getElementData(source, "RUN") then table.removevalue( readyPlayerList, source ) end end addEventHandler("onPlayerQuit",root, hijackerDC) function table.removevalue(t, val) for i,v in ipairs(t) do if v == val then table.remove(t, i) return i end end return false end triggerClientEvent (source,"RUN3",source) Link to comment
Walid Posted June 23, 2015 Share Posted June 23, 2015 :3 Wrong ,many things wrong. Example using button -- Client function open() triggerServerEvent("EventNameHere",localPlayer) end bindKey("F2", "down",open) -- Server function YourFunction () local table = getPlayers() triggerClientEvent(source, "RUN3",source,table) end addEvent("EventNameHere",true) addEventHandler("EventNameHere",root,YourFunction) 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