johny46 Posted July 22, 2013 Share Posted July 22, 2013 Hi. I want to execute some function whenever a player opens his map. According to the "MTA hard-coded commands" section of Control names i should be able to use "radar" as a command. Then why this code: addCommandHandler("radar", function() outputDebugString("Command handler executed!") end) does not work? No debug string is outputted no matter if I press the F11 key or actually type "radar" on the console, but the map is shown in both situations. Link to comment
50p Posted July 22, 2013 Share Posted July 22, 2013 As far as I remember, you can't have custom command handlers for hard-coded commands. Link to comment
johny46 Posted July 22, 2013 Author Share Posted July 22, 2013 Then how can I execute some code whenever a player opens his map without having to check whether isPlayerMapVisible "onClientRender"? Link to comment
50p Posted July 22, 2013 Share Posted July 22, 2013 I don't think there is any other way. You can try: https://wiki.multitheftauto.com/wiki/Ge ... dToCommand to get the key for "radar" command then bindKey your own function to that key. Link to comment
johny46 Posted July 22, 2013 Author Share Posted July 22, 2013 Then how can i know when player changes his bindings? Afaik there's no event for that so i'd have to run 'getKeyBoundToCommand' onClientRender Link to comment
50p Posted July 22, 2013 Share Posted July 22, 2013 Do people change their keys during playing? Well, I don't, especially the key for radar. If you really need that then you can use a timer instead of onClientRender. Link to comment
johny46 Posted July 22, 2013 Author Share Posted July 22, 2013 It basically is meant to hide all player blips whenever they open their map and show them again when map is closed, so it has to be fast. I think i'll make a timer to call 'getKeyBoundToCommand' every second, because I don't think it's possible to save settings, press the OK button, then press Esc and then open the map in less than one second thanks. Link to comment
qaisjp Posted July 23, 2013 Share Posted July 23, 2013 https://wiki.multitheftauto.com/wiki/IsPlayerMapVisible onRender - isPlayerMapVisible() - show else - hide probably inefficient but meh Link to comment
50p Posted July 23, 2013 Share Posted July 23, 2013 https://wiki.multitheftauto.com/wiki/IsPlayerMapVisibleonRender - isPlayerMapVisible() - show else - hide probably inefficient but meh That is exactly what johny46 wanted to avoid. Link to comment
qaisjp Posted July 23, 2013 Share Posted July 23, 2013 How does customblips do this? Taking a long look at the code it looks like you will have to use a render event, but to make things more streamlined you could just use customblips. 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