FlyingSpoon Posted June 27, 2015 Posted June 27, 2015 How can I get all the players in the server and create a label showing how many there are.
tuaos Posted June 27, 2015 Posted June 27, 2015 How can I get all the players in the server and create a label showing how many there are. getPlayerCount
xeon17 Posted June 27, 2015 Posted June 27, 2015 getPlayerCount textCreateTextItem or use triggerServerEvent to get the player count and display it on client-side
FlyingSpoon Posted June 27, 2015 Author Posted June 27, 2015 I dont understand, how would I do it so it displays on client-side like on a label.
tuaos Posted June 27, 2015 Posted June 27, 2015 I dont understand, how would I do it so it displays on client-side like on a label. Use this code client only.. you can see no. of players in bottom left of screen in ur server. local screenWidth, screenHeight = guiGetScreenSize ( ) -- Get the screen resolution (width and height) function createText ( ) local count = getPlayerCount() dxDrawText ( count, 44, screenHeight - 41, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown" ) -- Draw zone name text. dxDrawText ( count, 44, screenHeight - 43, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "pricedown" ) end function HandleTheRendering ( ) addEventHandler ( "onClientRender", root, createText ) -- keep the text visible with onClientRender. end addEventHandler ( "onClientResourceStart", resourceRoot, HandleTheRendering ) local originalGetPlayerCount = getPlayerCount -- Store the original getPlayerCount function to a variable function getPlayerCount() -- If originalGetPlayerCount is defined, that means that this function is executed serverside. -- The next line returns the result of the original function if it's defined. If not, it counts the number of player elements (to also work clientside). return originalGetPlayerCount and originalGetPlayerCount() or #getElementsByType("player") end Now change the position as you like!!
Walid Posted June 27, 2015 Posted June 27, 2015 @ tuaos getPlayerCount() it's a server side function. use #getElementsByType("player") works the same as this function and works client side.
tuaos Posted June 27, 2015 Posted June 27, 2015 @ tuaos getPlayerCount() it's a server side function.use #getElementsByType("player") works the same as this function and works client side. You can use it in client side with the getPlayerCount function..
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