Jump to content

easy problem


Derpy

Recommended Posts

hello im trying practice to know how triggerClientEvent/triggerServerEvent work but need help

server

function sendPlayerCount() 
local playerCount = getPlayerCount() 
triggerClientEvent("onPlayerCountChange",resourceRoot,playerCount) 
end 
addEventHandler("onPlayerJoin",root,sendPlayerCount) 
addEventHandler("onPlayerQuit",root,sendPlayerCount) 

client

addEvent("onPlayerCountChange",true) 
players = 0 
local screenWidth,screenHeight = guiGetScreenSize() 
function drawCount() 
dxDrawText(players,screenWidth/2,screenHeight/2,screenWidth/2,screenHeight/2,tocolor(0,0,255,255),1,"bankgothic") 
end 
addEventHandler("onClientRender",root,drawCount) 
  
function totalFreeroamPlayerNumber(playerCount)  
if playerCount then 
players = playerCount 
else return end 
end 
addEventHandler("onPlayerCountChange",root,totalFreeroamPlayerNumber) 

Link to comment
players = 0 
local screenWidth,screenHeight = guiGetScreenSize() 
function drawCount() 
dxDrawText(tostring(players),screenWidth/2,screenHeight/2,screenWidth/2+150,screenHeight/2+150,tocolor(0,0,255,255),1,"bankgothic") 
end 
addEventHandler("onClientRender",root,drawCount) 
  
function totalFreeroamPlayerNumber(playerCount) 
if playerCount then 
players = playerCount 
else return end 
end 
addEvent("onPlayerCountChange",true) 
addEventHandler("onPlayerCountChange",root,totalFreeroamPlayerNumber) 

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