Acces environment variables in PAWN
Install to your project:
sampctl package install dakyskye/pawn-env
include in your code:
#include <env>
and start using it.
At development time, you can use .env
file, but in production it's not recommended.
MYSQL_USER=user
MYSQL_PASSWORD=password
MYSQL_HOST=localhost
MYSQL_DATABASE=database
MYSQL_USER=user MYSQL_PASSWORD=password MYSQL_HOST=localhost MYSQL_DATABASE=database sampctl package run
$env:MYSQL_USER="user"; $env:MYSQL_PASSWORD="password"; $env:MYSQL_HOST="localhost"; $env:MYSQL_DATABASE="database"; sampctl package run
docker run -d \
-e MYSQL_USER=user \
-e MYSQL_PASSWORD=password \
-e MYSQL_HOST=localhost \
-e MYSQL_DATABASE=database \
--name my-container my/image
native bool:Env_Has(const env[]);
native bool:Env_Get(const env[], dest[], size=sizeof(dest));
bool:Env_Has(const env[]);
It checks if an environment variable with passed name as env
exists or not and returns the result as true
or false
, hence the bool
tag.
bool:Env_Get(const env[], dest[], size=sizeof(dest));
It reads the value of the environment variable of passed name as env
, then packs it into dest
.
Example usage can be found in tests/tests.pwn
First of all, install GNU Make if you haven't already.
make build
docker build -t pawn-env .
docker run -v DISKLETTER:\path\to\pawn-env\plugins:/pawn-env/plugins --name pawn-env pawn-env
An example path from my case: X:\My-Workflow\pawn-env\plugins
- Southclaws - for inspiration (see his pawn-env)
- SyS - for boilerplate
- ZOTTCE - for samp-rs