Jump to content

dxDrawText for all players on server


iPanda

Recommended Posts

Hi,

Each player has a dx text to the left, which shows the message administrator for every player on the server. Message is the same. How outputChatBox() on the server side.

--client 
local sms = '' 
addEventHandler('onClientRender',root,function() 
dxDrawText(sms,5,500,1,1,tocolor(255,255,255,250),1.2,'default-bold','left','top',false,false,false,false,false) 
end) 

and when the administrator writes a command to the server, it is displayed to all players in the line dx text.

--server 
addCommandHandler('sms',function(admin,cmd) 
--my condition if player is admins (no matter) 
--here I need to equate 'cmd' to 'sms' <
end)  

How do I send a variable to the server side and back?

and how to work what I want?

Link to comment

Hey ! U can do it by triggering clientside event from server look.

  
--server 
  
addCommandHandler("sms",function (player,cmd,sms) -- Command 
triggerClientEvent("onSMSTrigger",sms) -- Triggering a clientside event which changes the SMS for all clients. 
end) 
  
-- client 
  
local sms = " " 
addEvent("onSMSTrigger",true) -- Making the Event so the server can trigger it. 
  
  
  
addEventHandler("onSMSTrigger",root,function(newSMS) -- function which changes the text. 
sms = newSMS -- changing the message 
end) 
  
addEventHandler('onClientRender',root,function() -- Drawing event. 
dxDrawText(sms,5,500,1,1,tocolor(255,255,255,250),1.2,'default-bold','left','top',false,false,false,false,false) -- drawing the actual message 
end) 
  
  

Link to comment
triggerClientEvent("onSMSTrigger",sms) -- Triggering a clientside event which changes  

Should be:

triggerClientEvent("onSMSTrigger",player, sms) -- Triggering a clientside event which changes  

And use table.concat to get the words after space.

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