Kazafka Posted January 24, 2020 Share Posted January 24, 2020 (edited) I guess here addEventHandler("onPlayerChat", resourceRoot, function(message, type_) if(type_ == 0) then triggerClientEvent("dxDrawMessageText", getRootElement(), message) setTimer( function() triggerClientEvent("dxDrawMessageText", getRootElement(), "") end, 10000, 1) end end) is the problem, with triggerClientEvent(), client: addEvent("dxDrawMessageText", true) addEventHandler("dxDrawMessageText", getLocalPlayer(), function(message) UNITED_MESSAGE = message end) addEventHandler("onClientRender", root, function() dxDrawTextOnElement(localPlayer, UNITED_MESSAGE, 1, 20, 255, 255, 255, 255, 1, "default-bold") end) So, I tried to outputChatBox() inside event handler of dxDrawMessageText, but it keept doing completely nothing. My code for outputChatBox(): --Code from event handler of dxDrawMessageText outputChatBox(UNITED_MESSAGE) --Rest of code from event handler of dxDrawMessageText BTW: dxDrawTextOnElement() exists. Any idea? Edited January 24, 2020 by VaporZ Link to comment
Moderators IIYAMA Posted January 24, 2020 Moderators Share Posted January 24, 2020 (edited) triggerClientEvent("dxDrawMessageText", getRootElement(), message) triggerClientEvent("dxDrawMessageText", getRootElement(), "") addEventHandler("dxDrawMessageText", getLocalPlayer(), function(message) triggerClientEvent("dxDrawMessageText", resourceRoot, message) triggerClientEvent("dxDrawMessageText", resourceRoot, "") addEventHandler("dxDrawMessageText", resourceRoot, function(message) If you do not understand how the event system works, then you can better replace the baseElement of the triggerclient/serverEvent + addEventHandler with resourceRoot until you have studied that. Documentation: https://wiki.multitheftauto.com/wiki/AddEvent https://wiki.multitheftauto.com/wiki/Event_system https://wiki.multitheftauto.com/wiki/AddEventHandler https://wiki.multitheftauto.com/wiki/Element_tree https://wiki.multitheftauto.com/wiki/Event_Source_Element Edited January 24, 2020 by IIYAMA 1 Link to comment
Kazafka Posted January 24, 2020 Author Share Posted January 24, 2020 (edited) 6 minutes ago, IIYAMA said: triggerClientEvent("dxDrawMessageText", getRootElement(), message) triggerClientEvent("dxDrawMessageText", getRootElement(), "") addEventHandler("dxDrawMessageText", getLocalPlayer(), function(message) I've seen that in tutorial of triggerClientEvent() on MTA Wiki, but OK BTW: Still nothing Edited January 24, 2020 by VaporZ Link to comment
Kazafka Posted January 24, 2020 Author Share Posted January 24, 2020 What can u guys say to this ? Link to comment
Moderators IIYAMA Posted January 24, 2020 Moderators Share Posted January 24, 2020 Just now, VaporZ said: What can u guys say to this ? You didn't update the code, so I can't say anything. That tutorial is using different sourceElement, baseElement and sendTo elements. Nothing like your code. 1 Link to comment
Kazafka Posted January 24, 2020 Author Share Posted January 24, 2020 Just now, IIYAMA said: You didn't update the code, so I can't say anything. Server-side: addEventHandler("onPlayerChat", resourceRoot, function(message, type_) if(type_ == 0) then triggerClientEvent("messageText", resourceRoot, message) setTimer( function() triggerClientEvent("messageText", resourceRoot, "") end, 10000, 1) end end) Client-side: addEvent("messageText", true) addEventHandler("messageText", resourceRoot, function(message) UNITED_MESSAGE = message end) addEventHandler("onClientRender", root, function() dxDrawTextOnElement(localPlayer, UNITED_MESSAGE, 1, 20, 255, 255, 255, 255, 1, "default-bold") end) Link to comment
Moderators IIYAMA Posted January 24, 2020 Moderators Share Posted January 24, 2020 (edited) 3 minutes ago, VaporZ said: Server-side: addEventHandler("onPlayerChat", resourceRoot, function(message, type_) if(type_ == 0) then triggerClientEvent("messageText", resourceRoot, message) setTimer( function() triggerClientEvent("messageText", resourceRoot, "") end, 10000, 1) end end) Client-side: addEvent("messageText", true) addEventHandler("messageText", resourceRoot, function(message) UNITED_MESSAGE = message end) addEventHandler("onClientRender", root, function() dxDrawTextOnElement(localPlayer, UNITED_MESSAGE, 1, 20, 255, 255, 255, 255, 1, "default-bold") end) Where are your debuglines? There are absolutely 0 of them in your code. Edited January 24, 2020 by IIYAMA 1 Link to comment
Kazafka Posted January 24, 2020 Author Share Posted January 24, 2020 Just now, IIYAMA said: Where are your debuglines? There is absolutely 0 of them in your code. Bro Idk what are u saying 'bout. Really. I am sooo newbie to programmin' in MTA Link to comment
Moderators Patrick Posted January 24, 2020 Moderators Share Posted January 24, 2020 (edited) 5 minutes ago, VaporZ said: Server-side: addEventHandler("onPlayerChat", resourceRoot, function(message, type_) if(type_ == 0) then triggerClientEvent("messageText", resourceRoot, message) setTimer( function() triggerClientEvent("messageText", resourceRoot, "") end, 10000, 1) end end) Client-side: addEvent("messageText", true) addEventHandler("messageText", resourceRoot, function(message) UNITED_MESSAGE = message end) addEventHandler("onClientRender", root, function() dxDrawTextOnElement(localPlayer, UNITED_MESSAGE, 1, 20, 255, 255, 255, 255, 1, "default-bold") end) You attached the onPlayerChat event to resourceRoot. A resource can't use chat (like a player ). You need to change it to root, what contains players. (https://wiki.multitheftauto.com/wiki/Element_tree) Edited January 24, 2020 by stPatrick 1 Link to comment
Kazafka Posted January 24, 2020 Author Share Posted January 24, 2020 (edited) 2 minutes ago, stPatrick said: You attached the onPlayerChat event to resourceRoot. A resource can't send messages. You need to change it to root, what contains players. (https://wiki.multitheftauto.com/wiki/Element_tree) Actually that helped me Simple answer, simple result Forgot about magic word: T H A N K S Edited January 24, 2020 by VaporZ 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