Jump to content

Get Online Players?


Recommended Posts

Posted
getPlayerCount 
textCreateTextItem 

or use triggerServerEvent to get the player count and display it on client-side

A unique GangWar gamemode waiting for you!
Click here for more information.

560x95_FFFFFF_FF9900_000000_000000.png

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

350x20_FF0090_FFFFFF_0C0A36_FF0090.png
Posted

@ tuaos getPlayerCount() it's a server side function.

use #getElementsByType("player") works the same as this function and works client side.

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

Posted
@ 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..

350x20_FF0090_FFFFFF_0C0A36_FF0090.png

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