scienziato-pazzo Posted January 15, 2014 Share 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? Link to comment
Dzejki Posted January 15, 2014 Share Posted January 15, 2014 timeHud event doesn't work, check code for it. Link to comment
scienziato-pazzo Posted January 15, 2014 Author Share 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) Link to comment
Dzejki Posted January 15, 2014 Share Posted January 15, 2014 add before addEventHandler("timeHud", getRootElement(), timeHudF) this addEvent("timeHud", true) Link to comment
scienziato-pazzo Posted January 15, 2014 Author Share Posted January 15, 2014 add before addEventHandler("timeHud", getRootElement(), timeHudF) this addEvent("timeHud", true) Thanks! I missed that. Link to comment
Dzejki Posted January 15, 2014 Share Posted January 15, 2014 No problem, have fun with scripting Link to comment
scienziato-pazzo Posted January 15, 2014 Author Share 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. Link to comment
Dzejki Posted January 15, 2014 Share Posted January 15, 2014 I can't see any mistake. Make sure that your clientside script is included in meta. Link to comment
scienziato-pazzo Posted January 15, 2014 Author Share Posted January 15, 2014 I can't see any mistake. Make sure that your clientside script is included in meta. Yes, it is. Link to comment
Dealman Posted January 15, 2014 Share 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. Link to comment
scienziato-pazzo Posted January 15, 2014 Author Share 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) Link to comment
Dealman Posted January 15, 2014 Share 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? Link to comment
scienziato-pazzo Posted January 15, 2014 Author Share Posted January 15, 2014 Now all works. I don't know why, but it's a miracle. Link to comment
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