Jump to content

Get Online Players?


Recommended Posts

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!!

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...