pa3ck Posted July 29, 2013 Share Posted July 29, 2013 Hi guys, I'm making a GPS system, but I just can't make the script show a variable in the guiCreateButton... Is there any way to do that? I tried with the guiSetText, no success. The thing I want to do is, to show the real time in a GUI button. Also, I will bind the GPS to a specified button, and if the client is in a vehicle and is driver he will be able to open the GUI, othwerwise the GUI wont show up. But, the problem is that getPedOccupiedVehicle is server function and the GUI is client. Any idea how can I get this done? Any help would be highly appreciated! Link to comment
Castillo Posted July 29, 2013 Share Posted July 29, 2013 getPedOccupiedVehicle is a client and server side function, you can use it both on the client and the server side. Link to comment
Vector Posted July 29, 2013 Share Posted July 29, 2013 getPedOccupiedVehicle is client-side as well. and you can hide/show your GUI with this... addEventHandler ("onClientVehicleEnter", getRootElement (), function (thePlayer) if thePlayer ~= getLocalPlayer() then return; end; guiSetVisible (gui, true); -- show the gui. end); addEventHandler ("onClientVehicleExit", getRootElement (), function (thePlayer) if thePlayer ~= getLocalPlayer () then return; end; guiSetVisible (gui, false); -- hide gui. end); Link to comment
pa3ck Posted July 29, 2013 Author Share Posted July 29, 2013 Thanks for the quick reply guys! I just made a mistake there, I meant the getPedOccupiedVehicleSeat, because, I want the GUI to be used by the vehicle drivers. Link to comment
Castillo Posted July 29, 2013 Share Posted July 29, 2013 Use: getVehicleOccupant or getVehicleController to see if the player is the driver of the vehicle he is in. Link to comment
pa3ck Posted July 29, 2013 Author Share Posted July 29, 2013 Maaan! I love you! Thanks And what about using a variable in buttons? Like showing the real time in a GUI button? Is that possible? Or do I have to make a script like ' if time == 13:20 then guiSetText... '? Link to comment
Castillo Posted July 29, 2013 Share Posted July 29, 2013 getRealTime guiSetText setTimer or onClientRender Link to comment
pa3ck Posted July 29, 2013 Author Share Posted July 29, 2013 Thank you very much for your quick help! I'm a noob scripter ( yet ! ), so dont judge me The last question I will be askin ( today ) is, that I want to play a 3D sound whenever the driver hits the marker, I use the playSound3D. I've done that, its working, no problem. But I want to "attach" this sound to the driver, so if he leaves the marker the sound will be "following him", if you know what I mean. How could I do that? First I tought I would do it with onClientRender, so it will update the getElementPosition(), but it would play the sound over and over again... Link to comment
Castillo Posted July 29, 2013 Share Posted July 29, 2013 Simple, just attach it with attachElements. Link to comment
pa3ck Posted July 29, 2013 Author Share Posted July 29, 2013 Thank you! I got it working now, I really appreciate your help mate. Link to comment
pa3ck Posted July 29, 2013 Author Share Posted July 29, 2013 The last, last question > . < I made a button for showing the distance between the car and marker using getDistanceBetweenPoints3D, but its showing me a long-long number. How can I set it to show me like 12442.2? So 1 decimal? Link to comment
Castillo Posted July 29, 2013 Share Posted July 29, 2013 You can use math.floor to remove all decimals, or use this function to leave just 2 decimals or how much you want. https://wiki.multitheftauto.com/wiki/Math.round Link to comment
pa3ck Posted July 29, 2013 Author Share Posted July 29, 2013 Hmm. I tried this: distance = getDistanceBetweenPoints3D(mx, my, mz, px, py, pz) guiSetText(gpsDistance, math.round(distance, 3)) but its not working... Link to comment
Castillo Posted July 29, 2013 Share Posted July 29, 2013 You copied the function source code, right? because math.round is not a native function. Link to comment
pa3ck Posted August 1, 2013 Author Share Posted August 1, 2013 I'm not sure what you mean by that now, but thats the exact function I have in my resource. Its not even working with this. Any idea? Any help would be higly appreciated! 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