HUNGRY:3 Posted June 22, 2015 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?
Dealman Posted June 22, 2015 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. If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
HUNGRY:3 Posted June 22, 2015 Author 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
jingzhi Posted June 22, 2015 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
HUNGRY:3 Posted June 22, 2015 Author 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
jingzhi Posted June 22, 2015 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
HUNGRY:3 Posted June 22, 2015 Author 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
Tomas Posted June 22, 2015 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) Currently developing for International Gaming Community - Join us!
Image Posted June 23, 2015 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) Head Developer of SeeMTA Founder and Head Developer of SAS-Network ]
Walid Posted June 23, 2015 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 Do not yield your back to your enemy, might feel something strange in your ass. Two things are infinite the universe and human stupidity and i'm not sure about the universe. UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators
iMr.Dawix~# Posted June 23, 2015 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 My E-mails: [ [email protected] ],[ [email protected] ],[ [email protected] ] " Manners Maketh Man " " الأخلاق تصنع الرجل " ░░░░░███████ ]▄▄▄▄▄▄▄▄ BooM ! ▂▄▅█████████▅▄▃▂ ███████████████████]. ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤
Walid Posted June 23, 2015 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 Do not yield your back to your enemy, might feel something strange in your ass. Two things are infinite the universe and human stupidity and i'm not sure about the universe. UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators
iMr.Dawix~# Posted June 23, 2015 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 My E-mails: [ [email protected] ],[ [email protected] ],[ [email protected] ] " Manners Maketh Man " " الأخلاق تصنع الرجل " ░░░░░███████ ]▄▄▄▄▄▄▄▄ BooM ! ▂▄▅█████████▅▄▃▂ ███████████████████]. ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤
HUNGRY:3 Posted June 23, 2015 Author 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)
Walid Posted June 23, 2015 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) Do not yield your back to your enemy, might feel something strange in your ass. Two things are infinite the universe and human stupidity and i'm not sure about the universe. UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators
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