Jump to content

F11 Map, scriptable?


Atti

Recommended Posts

I personally would like to see an admin click and warp. Open the map click and POOF your there :P

I liked the idea, so I quickly coded a script that does exaclty that :wink:

It's a client-only script that is invoked by the command "radarteleport". It displays the map inside a window and teleports you (or the car you're in) to the clicked position on the ground. A check allows to toggle if you want to go on the water or below.

Works best if you bind a key to the command, like "bind n radarteleport".

The script is missing any sort of protection, all players can use it.

This is my first MTA script so don't be too hard :wink:

Download Radar Teleport v1.0 (300kb, sorry for the additional copy of the map)

@Devs:

Bugs I stumbled over while writing this, and suggestions:

- Relative GUI positioning seems a bit broken, placing the image at 0, 0, 1, 1 inside the window showed it cut-off at the top

- I'm really missing a function to convert absolute screen coords to control-relative coords and vice-versa

- Window alpha is only applied correctly if set after all controls are created

- When teleporting, the car gets quite a spin, which sometimes makes you fall off your bike

- getWaterLevel is a bit strange, as you basically need to know the water level before the call to get correct results

Link to comment

@Devs:

Bugs I stumbled over while writing this, and suggestions:

- Relative GUI positioning seems a bit broken, placing the image at 0, 0, 1, 1 inside the window showed it cut-off at the top

I'd guess it includes the titlebar in it's height. This is fairly common with GUI systems but not exactly ideal... Is the percentage you have to offset it by to get it right consistent across different resolutions?

- I'm really missing a function to convert absolute screen coords to control-relative coords and vice-versa

That's easy enough to do yourself with the screen width/height

- Window alpha is only applied correctly if set after all controls are created

I've reported this

- When teleporting, the car gets quite a spin, which sometimes makes you fall off your bike

Not seen this. Try setting the velocity to 0 and spawning a bit above ground level (you can get the height of the vehicle using getDistanceFromCenterOfMassToBaseOfModel)

- getWaterLevel is a bit strange, as you basically need to know the water level before the call to get correct results

Not sure what you mean, it should be very reliable. Got a test case? You might want to try using testLineAgainstWater instead.

It's worth noting that collision isn't loaded for areas you aren't in, so the processLineOfSight, getGroundPosition and getWaterLevel will be inaccurate.

You can easily protect your radarteleport function by setting it's 'restricted' boolean to true by default. This means admins have to allow it explicitly in their ACL for the users who should have it.

Link to comment

I'd guess it includes the titlebar in it's height. This is fairly common with GUI systems but not exactly ideal... Is the percentage you have to offset it by to get it right consistent across different resolutions?

I wonder why noone has reported this yet, as it seems even the devs of the included scripts had to struggle with this.

When using relative coords, it's not consistent. Tested on 1280x1024 and 800x600 and y position was different. However the absolute size seems to be fixed to 19.

That's easy enough to do yourself with the screen width/height

That's not what I meant. If you have a deeply nested GUI and want to convert absoluteX/absoluteY from a click event to pixel coords relative to the upper-left corner of the control, that currently involves quite some calculation.

Not seen this. Try setting the velocity to 0 and spawning a bit above ground level (you can get the height of the vehicle using getDistanceFromCenterOfMassToBaseOfModel)

Easy to reproduce. Start broph, enter a banshee and call "setpos 0 0 100". :wink:

Setting velocity/spin didn't seem to avoid this.

Not sure what you mean, it should be very reliable. Got a test case? You might want to try using testLineAgainstWater instead.

It's worth noting that collision isn't loaded for areas you aren't in, so the processLineOfSight, getGroundPosition and getWaterLevel will be inaccurate.

You can easily protect your radarteleport function by setting it's 'restricted' boolean to true by default. This means admins have to allow it explicitly in their ACL for the users who should have it.

I know about collision loading. However, when the data is loaded and call getWaterLevel(x, y, 50.0) it will return false even when the water level is 0 at (x, y). Perhaps testLineAgainstWater is the way to go, didn't test this.

Link to comment
  • 5 weeks later...
I personally would like to see an admin click and warp. Open the map click and POOF your there :P

I liked the idea, so I quickly coded a script that does exaclty that :wink:

It's a client-only script that is invoked by the command "radarteleport". It displays the map inside a window and teleports you (or the car you're in) to the clicked position on the ground. A check allows to toggle if you want to go on the water or below.

Works best if you bind a key to the command, like "bind n radarteleport".

The script is missing any sort of protection, all players can use it.

This is my first MTA script so don't be too hard :wink:

Download Radar Teleport v1.0 (300kb, sorry for the additional copy of the map)

can someone say me what is here wrong:

  
function keybind ( source ) 
    bindKey ( source, "r", "down", clientToggleGui ) 
end 
addEventHandler( "keybind", clientToggleGui ) 
  

i want to show the "Radar Teleport" when i pressing "r"

Link to comment

Read this: http://development.mtasa.com/index.php? ... entHandler

You forgot one parameter in addEventHandler. Also make sure you use this client side since "onClientResourceStart" is a client-side event.

  
function keybind () 
    bindKey ( "r", "down", clientToggleGui ) 
end 
addEventHandler( "onClientResourceStart", getRootElement(), keybind ) 
  

And btw, the client-side script doesn't need the source element. And type debugscript 3 in the console. It'll show all errors in your script

Link to comment

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...