scienziato-pazzo Posted January 15, 2014 Posted January 15, 2014 Hi, I wrote this script for the client: showPlayerHudComponent("clock", false) function updateHud() outputChatBox("function test") -- It doesn't work local screenWidth, screenHeight = guiGetScreenSize() local sx, sy = screenWidth/1400, screenHeight/900 --[[local realtime = getRealTime() local hour = realtime.hour local minute = realtime.minute]]-- dxDrawText("00:00", 1229*sx, 56*sy, 140*sx, 148*sy) end function timeHudF() addEventHandler("onClientRender", getRootElement(), updateHud) end addEventHandler("timeHud", getRootElement(), timeHudF) But the function updateHud is not called. Why?
Dzejki Posted January 15, 2014 Posted January 15, 2014 timeHud event doesn't work, check code for it.
scienziato-pazzo Posted January 15, 2014 Author Posted January 15, 2014 timeHud event doesn't work, check code for it. It's called by the server. EDIT: Yes, it doesn't work. The server script is this: function hudChanger() triggerClientEvent("timeHud", getRootElement()) end addEventHandler("onPlayerSpawn", getRootElement(), hudChanger)
Dzejki Posted January 15, 2014 Posted January 15, 2014 add before addEventHandler("timeHud", getRootElement(), timeHudF) this addEvent("timeHud", true)
scienziato-pazzo Posted January 15, 2014 Author Posted January 15, 2014 add before addEventHandler("timeHud", getRootElement(), timeHudF) this addEvent("timeHud", true) Thanks! I missed that.
scienziato-pazzo Posted January 15, 2014 Author Posted January 15, 2014 I added that showPlayerHudComponent("clock", false) function updateHud() outputChatBox("function test") -- It doesn't work local screenWidth, screenHeight = guiGetScreenSize() local sx, sy = screenWidth/1400, screenHeight/900 --[[local realtime = getRealTime() local hour = realtime.hour local minute = realtime.minute]]-- dxDrawText("00:00", 1229*sx, 56*sy, 140*sx, 148*sy) end function timeHudF() outputChatBox("test") -- It doesn't work addEventHandler("onClientRender", getRootElement(), updateHud) end addEvent("timeHud", true) addEventHandler("timeHud", getRootElement(), timeHudF) But it doesn't work.
Dzejki Posted January 15, 2014 Posted January 15, 2014 I can't see any mistake. Make sure that your clientside script is included in meta.
scienziato-pazzo Posted January 15, 2014 Author Posted January 15, 2014 I can't see any mistake. Make sure that your clientside script is included in meta. Yes, it is.
Dealman Posted January 15, 2014 Posted January 15, 2014 Well then it's obvious, isn't it? It's the server-side code that's likely to be messed up. And we can't assist any further if you don't post that part of the code.
scienziato-pazzo Posted January 15, 2014 Author Posted January 15, 2014 Well then it's obvious, isn't it? It's the server-side code that's likely to be messed up. And we can't assist any further if you don't post that part of the code. I already posted it up. function hudChanger() triggerClientEvent("timeHud", getRootElement()) end addEventHandler("onPlayerSpawn", getRootElement(), hudChanger)
Dealman Posted January 15, 2014 Posted January 15, 2014 function hudChanger() triggerClientEvent("timeHud", getRootElement()) end addEventHandler("onPlayerSpawn", getRootElement(), hudChanger) Sorry, missed that. It looks ay-okay. That should trigger for all clients though. What if you put a message there, is the function "hudChanger" being executed at all?
scienziato-pazzo Posted January 15, 2014 Author Posted January 15, 2014 Now all works. I don't know why, but it's a miracle.
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