Hugo_Almeidowski Posted January 25, 2019 Share Posted January 25, 2019 function apagarRadar() setPlayerHudComponentVisible(source, "radar", false) setElementData(source, "semradar", radar) end addEventHandler("onPlayerJoin", root, apagarRadar) function mostrarRadar(thePlayer) local naoTemRadar = getElementData(thePlayer, "semradar") if naoTemRadar then setElementData(thePlayer, "comradar", radar) setPlayerHudComponentVisible(thePlayer, "radar", true) removeElementData(thePlayer, "semradar") else outputChatBox("Já tens um mapa.") end end addCommandHandler("mapa", mostrarRadar) So, the idea: whenever a player join he is given the Data "semradar" and his radar is erased. Whener he types /mapa, it will check if he has the Data "semradar" and if he does, he will erase it, give him the Data "comradar" and set his radar visible. If he already has the data "comradar", it will just send him an error message. The problem is that whenever I type /mapa I just the the error message. It works if I delete the if statement, but in that way I can't send him the error message. Link to comment
Peti Posted January 25, 2019 Share Posted January 25, 2019 (edited) Try this instead showPlayerHudComponent ( 'radar', false ); Edited January 25, 2019 by Peti Link to comment
Hugo_Almeidowski Posted January 25, 2019 Author Share Posted January 25, 2019 1 hour ago, Peti said: Try this instead showPlayerHudComponent ( 'radar', false ); Doesn't work. The map is showing whenever I enter the map and I get the same error message when I type /mapa. And the console tells me that that command is depracated. Thanks anyways! Link to comment
Erknneto Posted January 25, 2019 Share Posted January 25, 2019 I think you were setting the wrong element datas, try this code function apagarRadar () setPlayerHudComponentVisible(source,"radar",false) setElementData(source,"showRadar",false) end addEventHandler("onPlayerJoin",getRootElement(),apagarRadar) function mostrarRadar (source) if not ( getElementData(source,"showRadar") ) then setElementData(source,"showRadar",true) setPlayerHudComponentVisible(source,"radar",true) else outputChatBox("Já tens um mapa.",source) end end addCommandHandler("mapa",mostrarRadar) 1 Link to comment
Peti Posted January 25, 2019 Share Posted January 25, 2019 (edited) 3 hours ago, Hugo_Almeidowski said: Doesn't work. The map is showing whenever I enter the map and I get the same error message when I type /mapa. And the console tells me that that command is depracated. Thanks anyways! My bad, try this: setPlayerHudComponentVisible ( thePlayer, 'radar', false ) -- server-side. or setPlayerHudComponentVisible ( 'radar', false ) -- client-side. Edited January 25, 2019 by Peti Link to comment
Hugo_Almeidowski Posted January 26, 2019 Author Share Posted January 26, 2019 15 hours ago, Erknneto said: I think you were setting the wrong element datas, try this code function apagarRadar () setPlayerHudComponentVisible(source,"radar",false) setElementData(source,"showRadar",false) end addEventHandler("onPlayerJoin",getRootElement(),apagarRadar) function mostrarRadar (source) if not ( getElementData(source,"showRadar") ) then setElementData(source,"showRadar",true) setPlayerHudComponentVisible(source,"radar",true) else outputChatBox("Já tens um mapa.",source) end end addCommandHandler("mapa",mostrarRadar) It worked! Thanks! I just don't get why mine didn't work. 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