TrickyTommy Posted August 17, 2017 Posted August 17, 2017 Hi! I am making a script, that writes above your head that you are typing if you do so. The only problem is, it does barely work, and strangely. When i escape from input, it won't disappear. What i have done so far: Client: function recieveConsoleImput(client) function render() --if client ~= localPlayer then dxDrawTextOnElement (client, "l'écriture... / Writing... / Ír...", _, _, _, _, _, _, 2) --end removeEventHandler ("onClientRender", getRootElement(), render) end addEventHandler ("onClientRender", getRootElement(), render) end addEvent ("recieveConsoleImput", true) addEventHandler ("recieveConsoleImput", getRootElement(), recieveConsoleImput) function checkConsoleImput() if isChatBoxInputActive(localPlayer) then triggerServerEvent ("forwardConsoleImput", getRootElement(), localPlayer) end end addEventHandler ("onClientRender", getRootElement(), checkConsoleImput) Server: function forwardConsoleImput(client) triggerClientEvent ("recieveConsoleImput", getRootElement(), client) end addEvent ("forwardConsoleImput", true) addEventHandler ("forwardConsoleImput", getRootElement(), forwardConsoleImput) heyyy whats wrong?
Pembo Posted August 19, 2017 Posted August 19, 2017 (edited) In the client code you have made it so the render function will only run for one frame only simply because you removed the event immediately after. You need a way to make the render function end when the player stops typing. Also, I would not advise that you use the same name for your event as your function as this can cause confusion. Edited August 19, 2017 by Pembo
_DrXenon Posted August 19, 2017 Posted August 19, 2017 I have not taken a look at your code but a very simple way to do this trick is by that; addEventHandler("onClientRender",root,function() if getElementData(localPlayer,"typing") == true then -- dxDraw..... -- anything else you want end end) -- now this way the image (if you are using image) or the text will be only showing when the player has the 'typing' data, otherwise nothing would be shown. -- all you have to do is to detect whenever a player is typing and whenever he is not and change his data according to that.
TrickyTommy Posted August 23, 2017 Author Posted August 23, 2017 On 2017. 08. 19. at 23:44, SuperCroz said: I have not taken a look at your code but a very simple way to do this trick is by that; addEventHandler("onClientRender",root,function() if getElementData(localPlayer,"typing") == true then -- dxDraw..... -- anything else you want end end) -- now this way the image (if you are using image) or the text will be only showing when the player has the 'typing' data, otherwise nothing would be shown. -- all you have to do is to detect whenever a player is typing and whenever he is not and change his data according to that. Hi! I want other players to see each other's writing sign.
MTA Team Lpsd Posted August 23, 2017 MTA Team Posted August 23, 2017 (edited) So drawing upon @SuperCroz's idea, it'd be pretty simple. addEventHandler("onClientRender",root,function() for i,player in pairs(getElementsByType("player")) do if getElementData(player,"typing") == true then if not getElementData(player,"showtyping") then setElementData(player,"showtyping",true,true) end --here is your dxDrawImage3D chat bubble or such else if getElementData(player,"showtyping") then setElementData(player,"showtyping",false,true) end end end end) Well, I think that'd work. I don't use element data too often Edited August 23, 2017 by LopSided_
TrickyTommy Posted August 23, 2017 Author Posted August 23, 2017 but this is on client-side. my client side is able to get element data, from other clients? or what?
MTA Team Lpsd Posted August 23, 2017 MTA Team Posted August 23, 2017 Check out https://wiki.multitheftauto.com/wiki/SetElementData More specifically, the synchronize argument
TrickyTommy Posted August 23, 2017 Author Posted August 23, 2017 ohhh i did not know about that. you made my future days a lot easier, thanks for telling me about synchronizing
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