cG-Ciasteczkowy Posted April 2, 2018 Share Posted April 2, 2018 Hey! Would someone tell me how to do getPlayerPing for the php sdk library? I only managed to make a list of players on the server function listPlayer( ) local players = {} for k, player in ipairs( getElementsByType ("player") ) do local player = getPlayerName( player ) table.insert( players, player ) end return players end Link to comment
Moderators Patrick Posted April 2, 2018 Moderators Share Posted April 2, 2018 (edited) Send the ping, with the names to the php. local playername = getPlayerName( player ) local ping = getPlayerPing( player ) table.insert( players, {playername, ping} ) Edited April 2, 2018 by gpetersz 1 Link to comment
cG-Ciasteczkowy Posted April 2, 2018 Author Share Posted April 2, 2018 Use, function listPing () local players = {} local playername = getPlayerName( player ) local ping = getPlayerPing( player ) table.insert( players, {playername, ping} ) return players end And ... Link to comment
Moderators Patrick Posted April 2, 2018 Moderators Share Posted April 2, 2018 function listPlayer( ) local table = {} for _, player in ipairs( getElementsByType ("player") ) do local name = getPlayerName( player ) local ping = getPlayerPing( player ) table.insert( table, {name, ping} ) end return table end 1 Link to comment
cG-Ciasteczkowy Posted April 2, 2018 Author Share Posted April 2, 2018 Bad, Okey, function listPlayer( ) local players = {} for _, player in ipairs( getElementsByType ("player") ) do local name = getPlayerName( player ) local ping = getPlayerPing( player ) table.insert( players, ping ) end return players end Link to comment
Moderators Patrick Posted April 2, 2018 Moderators Share Posted April 2, 2018 function listPlayer( ) local playersTable = {} for _, player in ipairs( getElementsByType ("player") ) do local name = getPlayerName( player ) local ping = getPlayerPing( player ) table.insert( playersTable, {name, ping} ) end return playersTable end addCommandHandler("testfunction", function() -- function test command outputChatBox(tostring(toJSON(listPlayer())), getRootElement()) end) 1 Link to comment
cG-Ciasteczkowy Posted April 2, 2018 Author Share Posted April 2, 2018 (edited) 27 minutes ago, gpetersz said: function listPlayer( ) local playersTable = {} for _, player in ipairs( getElementsByType ("player") ) do local name = getPlayerName( player ) local ping = getPlayerPing( player ) table.insert( playersTable, {name, ping} ) end return playersTable end addCommandHandler("testfunction", function() -- function test command outputChatBox(tostring(toJSON(listPlayer())), getRootElement()) end) [ [ [ "Ciastuus", 28 ] ] ] I create a list of players with information about them in php. And that's how it looks The problem is that if there are more players, everything breaks down @gpetersz do you have a discord? Edited April 2, 2018 by cG-Ciasteczkowy 1 Link to comment
Ahmed Ly Posted April 2, 2018 Share Posted April 2, 2018 function getPlayersName () local playerNames = {} for i, player in pairs(getElementsByType("player")) do table.insert(playerNames, getPlayerName(player)) end return unpack(playerNames) end 1 Link to comment
cG-Ciasteczkowy Posted April 2, 2018 Author Share Posted April 2, 2018 5 minutes ago, Ahmed Ly said: function getPlayersName () local playerNames = {} for i, player in pairs(getElementsByType("player")) do table.insert(playerNames, getPlayerName(player)) end return unpack(playerNames) end I just wanted him to read the ping. Will this correct the error related to what I wrote? Link to comment
Ahmed Ly Posted April 2, 2018 Share Posted April 2, 2018 function list () local ping = {} for i, player in pairs(getElementsByType("player")) do table.insert(ping, getPlayerPing(player)) end return unpack(ping) end 1 Link to comment
cG-Ciasteczkowy Posted April 2, 2018 Author Share Posted April 2, 2018 2 minutes ago, Ahmed Ly said: function list () local ping = {} for i, player in pairs(getElementsByType("player")) do table.insert(ping, getPlayerPing(player)) end return unpack(ping) end Will this improve my errors I wrote above? Please answer 1 Link to comment
cG-Ciasteczkowy Posted April 2, 2018 Author Share Posted April 2, 2018 6 minutes ago, Ahmed Ly said: probably yes do u have a discord? Link to comment
Ahmed Ly Posted April 2, 2018 Share Posted April 2, 2018 Just now, cG-Ciasteczkowy said: do u have a discord? Ahmed Ly#6818 1 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