[Plugin] Bitmapper for object placement
#1

samp-bitmapper

For generating in-game coordinates from a bitmap.

See this thread for the primary reason that this plugin exists. It’s best used with MapAndreas or ColAndreas and a texture map so you can automatically place items in the game world in areas.

Create a bitmap image of the map then paint specific colours over it. Then, load the bitmap and specify which colours you want to cache with OpenBitmapCache. You can then get random points in the image of specific cached colours with GetRandomCachedRGB.

If you want to map larger or smaller bitmaps to areas of the map, use this library to create a virtual canvas to perform the scaling.

For example, this:



Generates this:



See the thread linked above for more examples.

Installation

Simply install to your project:

Код:
sampctl package install Southclaws/samp-bitmapper
Or, if you prefer GitHub:
Include in your code and begin using the library:

Код:
#include <bitmapper>
Usage

Functions

OpenBitmap(const filename[], &Bitmap:handle);

Opens the given file as a bitmap image and stores thefile handle in handle. Returns 0 on success or an error code.

OpenBitmapCache(const filename[], &Bitmap:handle, const colours[], len = sizeof colours);

Opens the given file and caches all pixels that match the colours listed in colours. Returns 0 on success or an error code.

CloseBitmap(Bitmap:handle);

Closes the specified file handle. Returns 0 on success, 1 if the handle is invalid.

GetRGB(Bitmap:handle, x, y, &r, &g, &b);

Looks up the red, green and blue values stored in the specified X and Y coordinates and stores them in the result parameters r, b and g.

GetRandomCachedRGB(Bitmap:handle, colour, &x, &y);

Provides coordinates and RGB information from a random pixel in the bitmap that contains the specified colour.

Testing

You can compile the plugin and test it in a Docker container all with one command:

Код:
make build-e2e
This will:
  • build the plugin inside a Debian docker image
  • build the Pawn package in test/ with sampctl
  • run the server in test/ as a container, also with sampctl
Or you can just do the build process with:

Код:
make build-debian
(thanks to maddinat0r for the Docker images!)
Reply
#2

southclaws moments before release

+rep
Reply
#3

+rep

Nice JOB!
Reply
#4

Nice! Thanks for clarifying
Reply
#5

Good.
Reply
#6

Nice one
Reply
#7

so what can i do with this bitmap for example?
Reply
#8

Quote:
Originally Posted by CodeStyle175
Посмотреть сообщение
so what can i do with this bitmap for example?
See the second sentence of the thread for example.
Reply
#9

still i dont get it why would i need to do something stupid like this, why would i need to add lagging objects randomly in some array with no reason?
Reply
#10

Quote:
Originally Posted by CodeStyle175
Посмотреть сообщение
still i dont get it why would i need to do something stupid like this, why would i need to add lagging objects randomly in some array with no reason?
I don't know about the lagging stuff but
Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
See this thread for the primary reason that this plugin exists.
Reply
#11

Not sure what you mean by "lagging objects randomly", this plugin doesn't deal with objects and the only randomness involved is the `GetRandomCachedRGB` function.

This plugin is - at the most basic level - for reading bitmap files. The primary use-case for this is for mapping pixels to positions in the game world. Why? So you can use a bitmap to control automated placement of objects across the map.

If you don't know if you need this plugin or not, you don't. If you don't understand what it's for, you also probably don't need it.
Reply
#12

well i understand but in samp this functionality is useless.
Reply
#13

Quote:
Originally Posted by CodeStyle175
Посмотреть сообщение
well i understand but in samp this functionality is useless.
Just because you don't have enough brain cells to understand this, this doesn't mean its useless. If u ask me, your reactions on every thread are useless.
Reply
#14

Amazing!
Reply
#15

Quote:
Originally Posted by CodeStyle175
Посмотреть сообщение
well i understand but in samp this functionality is useless.
Doubt it
Reply
#16

Quote:
Originally Posted by MikeC1
Посмотреть сообщение
Good job +rep!!
All your post literally is just you saying 'good job'..
Reply
#17

Quote:
Originally Posted by CodeStyle175
Посмотреть сообщение
well i understand but in samp this functionality is useless.
You couldn't be more wrong. This plugin is very powerful for a very specific set of actions in SA-MP which could not be achieved in an efficient manner otherwise. For example, randomly generating peyote/mushrooms among the game's countryside on server startup. This is a feature on my server which works wonderfully with minimal overhead thanks to this plugin. The only limit here is your creativity. Just because you're not creative enough to think of a use case for this plugin, it doesn't mean it's useless.
Reply
#18

Can this plugin be used to find grass land for drug system, where you can plant weed on grass only?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)