Jump to content

GUI button and getPedOccupiedVehicle.


pa3ck

Recommended Posts

Posted

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!

Posted

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);  
  

Posted

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.

Posted

Maaan! I love you! Thanks :D 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... '?

Posted

Thank you very much for your quick help! I'm a noob scripter ( yet ! :D ), so dont judge me :D The last question I will be askin ( today xD ) 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...

Posted

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?

Posted

Hmm. I tried this:

distance = getDistanceBetweenPoints3D(mx, my, mz, px, py, pz) 
guiSetText(gpsDistance, math.round(distance, 3)) 

but its not working...

Posted

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!

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...