Skip to content
fromgate edited this page Jun 16, 2017 · 2 revisions

ReActions allows you to perform some actions with data store in MySQL database. This feature brings great ability to integrate your server with other plugins, web-services and applications.

Why it needed?

Suppose that some plugin stores data in a MySQL database. Plugin Jail, for example allows you to store information in database. Now you can use ReActions to correspond with this data (for example check is player jailed or not) and use this state for your activators. You just need to create SQL-query that will provide you necessary information.

How it implemented in ReActions

There are some flag (SQL_CHECK, SQL_RESULT) and actions (SQL_SELECT, SQL_UPDATE and SQL_INSERT).

Compares result of SQL-query with provided value.

Parameters:

  • query:{SELECT...} — SQL-query
  • value:<value> — value that will be compared with result
  • column:<column> — number of column (1 by default) to define field to compare with provided value.

Example:

BUTTON:
  sqltest:
    world: world
    x: -59
    y: 65
    z: 413
    flags:
    - SQL_CHECK=value:Russia query:{SELECT Name FROM country WHERE Capital="Moscow"}
    actions:
    - MESSAGE=&6ok
    reactions:
    - MESSAGE=&4not ok

Check if result of SQL-query returns data. If result is empty flag will return false.

Parameter:

  • query:{SELECT...} — SQL-query

Example:

BUTTON:
  sqltest:
    world: world
    x: -59
    y: 65
    z: 413
    flags:
    - SQL_RESULT=query:{SELECT Name FROM country WHERE Capital="Manchester"}
    actions:
    - MESSAGE=&6I know Moscow is a capital of... of... a country
    reactions:
    - MESSAGE=&4There is no countries with capital named Manchester

Execute SQL query and store field located in first row (and defined column) at variable. If player name is not provided data will stored in global variable, if player name is defined personal variable will used.

Parameters:

  • query:{SELECT... }
  • variable:<variable id> — result of query will be save in this variable
  • player:<varibale owner>
  • column:<column>

Activator example

BUTTON:
  sqlselect:
    world: world
    x: -58
    y: 65
    z: 412
    flags: []
    actions:
    - sql_select=variable:sqltest query:{SELECT Capital FROM country WHERE Name="Germany"}
    - message=Selected value: %var:sqltest%
    reactions: []

Execute update-query (update one field (or more) of table at MySQL database)

Parameter:

  • query:{UPDATE... }

Example:

BUTTON:
  sqlupdate:
    world: world
    x: -60
    y: 65
    z: 412
    flags: []
    actions:
    - sql_update=UPDATE country set Name="USA" where Code="Washington"
    reactions: []

Execute insert-query (insert new row in table at MySQL database)

Parameter:

  • query:{INSERT... }

Example:

BUTTON:
  sqlinsert:
    world: world
    x: -59
    y: 65
    z: 411
    flags: []
    actions:
    - sql_insert=INSERT INTO country (Name, Capital) set ("United States of Uryupinsk", "Uryupinsk")
    reactions: []

Configuration

To configure access to MySQL server you need edit config.yml file:

MySQL:
  server: localhost   # MySQL server address
  port: '3306'        # server port
  database: world     # internal database name
  username: root      # username
  password: root      # password
Clone this wiki locally