Skip to content

Maps and positions

Putting things on the map

Oxford publishes a map image of the whole map. oxrpy.map converts API positions to pixels on it:

from oxrpy.map import to_pixels, from_pixels, distance, nearest

px, py = to_pixels(player["Position"])                            # on the full-size image
px, py = to_pixels(player["Position"], width=1630, height=1260)   # on a resized copy

x, z = from_pixels(800, 600, width=1630, height=1260)    # a click on your map -> game position
api.create_incident("Police", 1, x, z, "Reported disturbance")

distance(player["Position"], vehicle["Position"])        # studs, ignoring height
nearest(player["Position"], api.get_catalogue()["Map"]["Places"])   # nearest named place