Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Releases Plugins [Plugin] pawn env

 
  • 1 Vote(s) - 5 Average
Plugin pawn env
dakyskye
Offline

open.mp Developer

Posts: 25
Threads: 4
Joined: Feb 2019
Reputation: 2
Location: Georgia
#1
2019-05-12, 03:41 PM (This post was last modified: 2020-01-26, 05:51 PM by dakyskye.)
pawn-env

[Image: sampctl-pawn--env-2f2f2f.svg?style=for-the-badge]

Access environment variables in PAWN

Installation

Install to your project:

Code:
sampctl package install dakyskye/pawn-env

include in your code:

Code:
#include <env>

and start using it.

Usage

At development time, you can use .env file, but in production it’s not recommended.

Example .env file content:

Code:
MYSQL_USER=user
MYSQL_PASSWORD=password
MYSQL_HOST=localhost
MYSQL_DATABASE=database

Using it in the recommended way:

Code:
MYSQL_USER=user MYSQL_PASSWORD=password MYSQL_HOST=localhost MYSQL_DATABASE=database sampctl package run

Code:
$env:MYSQL_USER="user"; $env:MYSQL_PASSWORD="password"; $env:MYSQL_HOST="localhost"; $env:MYSQL_DATABASE="database"; sampctl package run

Code:
docker run -d \
    -e MYSQL_USER=user \
    -e MYSQL_PASSWORD=password \
    -e MYSQL_HOST=localhost \
    -e MYSQL_DATABASE=database \
    --name my-container my/image

API

Code:
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

Building

First of all, install GNU Make if you haven’t already.

Code:
make build

Code:
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

Credits
  • Southclaws - for inspiration (see his pawn-env)
  • SyS - for boilerplate
  • ZOTTCE - for samp-rs
@dakyskye everywhere
javelin
Offline

Burgershot Member
Posts: 20
Threads: 0
Joined: Apr 2019
Reputation: 1
#2
2019-12-13, 05:43 PM
useful as always, thank you daky
dakyskye
Offline

open.mp Developer

Posts: 25
Threads: 4
Joined: Feb 2019
Reputation: 2
Location: Georgia
#3
2019-12-14, 03:36 PM
(2019-12-13, 05:43 PM)javelin Wrote: useful as always, thank you daky

Glad to hear
@dakyskye everywhere
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode