Jump to content
code34

OO_EXTDB3 - A driver for extDB3 addon Mysql

Recommended Posts

OO_EXTDB3 - A driver for extDB3 addon Mysql
Lastest version : 0.2 by Code34


GitHub : https://github.com/code34/oo_extdb3.altis


OO_extDB3 is a driver for extDB3 addons

Features
    - Encapsulate totaly EXTDB3 commands through an object
    - Standardize methods name and return values

Licence
Under Gpl, you can share, modify, distribute this script but don't remove the licence and the name of the original author

 

	/*
	Author: code34 nicolas_boiteux@yahoo.fr
	Copyright (C) 2017-2018 Nicolas BOITEUX

	CLASS OO_EXTDB3
	
	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>. 
	*/

	Create a main bus message between clients & server
	
	Usage:
		install the extdb3 addon
		put the "oo_extdb3.sqf" and the "oop.h" files in your mission directory
		put this code into your mission init.sqf
		call compile preprocessFileLineNumbers "oo_extdb3.sqf";

	See example mission in directory: init.sqf
	
	Licence: 
	You can share, modify, distribute this script but don't remove the licence and the name of the original author

	logs:
		0.1 	- OO EXTDB3 - first release

 


	Author: code34 nicolas_boiteux@yahoo.fr
	Copyright (C) 2017-2018 Nicolas BOITEUX

	CLASS OO_EXTDB3
	
	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>. 

	--------------------------------------------------------------------------------------------------------------

	Function:  _extdb3 = "new" call OO_EXTDB3;
	Create a new extdb3 object
		
	Parameters: 
		string 

	--------------------------------------------------------------------------------------------------------------

	Function:  _version = "getVersion" call _extdb3;
	Return string extdb3 version
		
	--------------------------------------------------------------------------------------------------------------

	Function:  _bool = "isDllEnabled" call _extdb3;
	Return bool - is extdb3 is loaded

	--------------------------------------------------------------------------------------------------------------

	Function:   ["setEscapeChar", _string] call _extdb3;
	param string : "TEXT", "TEXT2", "NULL"

	--------------------------------------------------------------------------------------------------------------

	Function:  ["setSessionId", _string] call _extdb3;
	param string : unique string to identify the session (default "SQL")

	-------------------------------------------------------------------------------------------------------------

	Function:  ["setIniSectionDatabase", _string] call _extdb3;
	param string : set Ini Section concerning Database (default "Database")

	-------------------------------------------------------------------------------------------------------------

	Function:  ["setDatabaseName", _string] call _extdb3;
	param string : set the databasename used

	-------------------------------------------------------------------------------------------------------------

	Function:  ["setQueryType", _string] call _extdb3;
	param string : set the type of SQL queries (default SQL)
		"SQL" : Classic sql
		"SQL_CUSTOM" : SQL prepared statement
		 "LOG" : log

	-------------------------------------------------------------------------------------------------------------

	Function:  ["setSqlCustomIniFile", _string] call _extdb3;
	param string : set the SQL CUSTOM ini file

	-------------------------------------------------------------------------------------------------------------

	Function:  _bool = "connect" call _extdb3;
	connect to database
	Return bool -  true if connected

	-------------------------------------------------------------------------------------------------------------

	Function:  _return = ["executeQuery", [_query, _defaultreturnvalue]] call _extdb3;
	params: 
		string SQL query or SQL CUSTOM method
		default value return if nothing is return


	-------------------------------------------------------------------------------------------------------------

	Function:   _return = ["executeQuery", _query] call _extdb3;
	params: 
		string SQL query
		if nothing is return, return empty string

	-------------------------------------------------------------------------------------------------------------

	Function:   _array = ["lock", _string] call _extdb3;
	Disables all System Commands except for VERSION + LOCK_STATUS + various TIME/DATA Commands
	params: 
		string - password lock
	return array


	-------------------------------------------------------------------------------------------------------------

	Function:  _array = ["unlock", _string] call _extdb3;
	params: 
		string - password lock
	return array


	-------------------------------------------------------------------------------------------------------------

	Function:  _array = "lockStatus" call _extdb3;
	return array - lock status
		[0] // extension is unlocked.  
		[1] // extension is locked.


	-------------------------------------------------------------------------------------------------------------

	Function:  _array = "reset" call _extdb3;
	reset the dll when debug .dll is used

	return:
		return [0] or
		return [1] if success

	-------------------------------------------------------------------------------------------------------------

	Function:  _locatime = "getLocalTime" call _extdb3;
	return array - local time

	-------------------------------------------------------------------------------------------------------------

	Function:  _utctime = "getUtcTime" call _extdb3;
	return array - utc time

	-------------------------------------------------------------------------------------------------------------

	Function: _uptime =  ["getUptime", _string] call _extdb3;
	params : "SECONDS", "MINUTES", "HOURS"

	-------------------------------------------------------------------------------------------------------------

	Function: _array =  ["addDate", _array] call _extdb3;
	params : 
		param  [[0,0, Days, Hours, Minutes, Seconds], [+x Days, +x Hours, +x Minutes, +x Seconds]]

	-------------------------------------------------------------------------------------------------------------

	Function: _scalar =  "getOutPutSize" call _extdb3;
	
	return _scalar

	--------------------------------------------------------------------------------------------------------------
	
	Function:  ["delete", _extdb3] call OO_EXTDB3;
	Destroy the template object 
		
	Parameters:
		object - extdb3 object
	
	Return : nothing

 

 


Examples

	call compile preprocessFileLineNumbers "oo_extdb3.sqf";

	sleep 2;

	/* 
		SQL CUSTOM Example with prepared statements in test.ini files
		Call the query getAll

		private _extdb3 = "new" call OO_extDB3;
		["setDatabaseConfigName", "Database"] call _extdb3;
		["setDatabaseName", "extdb3"] call _extdb3;
		["setIniFile", "test.ini"] call _extdb3;
		["setDatabaseProtocol", "SQL_CUSTOM"] call _extdb3;
		_result = "connect" call _extdb3;
		private _query = ["getAll", []];
		_result = ["executeQuery", _query] call _extdb3;
		hintc format ["%1", _result];
	*/

	/*
		SQL CLASSIC QUERY

		private _extdb3 = "new" call OO_extDB3;
		["setDatabaseConfigName", "Database"] call _extdb3;
		["setDatabaseName", "extdb3"] call _extdb3;
		["setDatabaseProtocol", "SQL"] call _extdb3;
		_result = "connect" call _extdb3;
		private _query = "SELECT * FROM test LIMIT 10;";
		_result = ["executeQuery", _query] call _extdb3;
		hintc format ["%1", _result];
	*/

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

hi

 

just release the v 0.2

- add unique SQL id sessions

 

:don12:

Share this post


Link to post
Share on other sites

I am late to the party but I will be testing this soon. Thank you very much for your work.

  • Haha 1

Share this post


Link to post
Share on other sites

I am trying to use this wonderful plug-in and I have found it difficult to save player data.
on the server the code works perfectly to save date, time, climate etc but the player data does not save them.
Does the extdb3 mod have to be uploaded by local players too?

Share this post


Link to post
Share on other sites

Hello @Grenadier ITF

 

Yes you have to load it where you use it (client side or server side). Normaly, you should write or read on server side.

Share this post


Link to post
Share on other sites

I created a simple test.
loading climate, time and player data.
The former are invoked in an initserver.sqf file and it works,
the seconds, player data, are not loaded.
Where am I wrong?

initserver.sqf

Spoiler

call compile preprocessFileLineNumbers "oo_extdb3.sqf";

 

    sleep 2;

 

        //SQL CLASSIC QUERY

 

        private _extdb3 = "new" call OO_EXTDB3;

        ["setIniSectionDatabase", "itf_database"] call _extdb3;

        ["setDatabaseName", "extdb3"] call _extdb3;

        ["setQueryType", "SQL"] call _extdb3;

        _result = "connect" call _extdb3;

        private _query_data = "SELECT * FROM condizioni";

 

        _result = ["executeQuery", _query_data] call _extdb3;

 

if (_result isequalto [])then {

 

        private _query_data = "INSERT INTO condizioni (data, clima) VALUES" + format ["('%1', '%2')",date, overcast];

        _result = ["executeQuery", _query_data] call _extdb3;

 

}else{

 

        _data       = call compile (_result select 0 select 1);

        _clima      =  (_result select 0 select 2);

 

        [_data] remoteExec ["setDate"];

        [[], {setDate _data}] remoteExec ["call",0,"JIP_id_setDate"];

        //setDate _date;                        // data e ora

        0 setOvercast _clima; 

        forceWeatherChange;

 

};

 

[[], "initplayer.sqf"] remoteExec ["BIS_fnc_execVM",0,true];  // call data player


initplayer.sqf
 

Spoiler

if (! hasInterface ) exitWith {}; 
 

_UID        = getPlayerUID player;

 

        private _extdb3 = "new" call OO_EXTDB3;

        ["setIniSectionDatabase", "itf_database"] call _extdb3;

        ["setDatabaseName", "extdb3"] call _extdb3;

        ["setQueryType", "SQL"] call _extdb3;

        _result = "connect" call _extdb3;

        private _query = "SELECT * FROM players WHERE clientID =" + format ["'%1'",_UID];

 

        _result = ["executeQuery", _query] call _extdb3;

 

_pos        = call compile (_result select 0 select 3);

_uncons     = call compile (_result select 0 select 4);

_inventory  = (_result select 0 select 5);

_bullet_1   = call compile (_result select 0 select 6);

_bullet_2   = call compile (_result select 0 select 7);

_bullet_3   = call compile (_result select 0 select 8);

 

        player setPosATL _pos;

 

removeAllWeapons        player;

removeAllItems          player;

removeAllAssignedItems  player;

removeUniform           player;

removeVest              player;

removeBackpack          player;

removeHeadgear          player;

removeGoggles           player;

 

player setUnitLoadout   _inventory;     

player setAmmo [primaryWeapon player, _bullet_1];

player setAmmo [secondaryWeapon player, _bullet_2];

player setAmmo [handgunWeapon player, _bullet_3];

 

_damageVar = call compile (_result select 0 select 9);

 

Share this post


Link to post
Share on other sites
Just now, Grenadier ITF said:

I created a simple test.
locally it works, but on the server it works to halfway
loading climate, time and player data.
The former are invoked in an initserver.sqf file and it works,
the seconds, player data, are not loaded.
Where am I wrong?

initserver.sqf

  Reveal hidden contents

call compile preprocessFileLineNumbers "oo_extdb3.sqf";

 

    sleep 2;

 

        //SQL CLASSIC QUERY

 

        private _extdb3 = "new" call OO_EXTDB3;

        ["setIniSectionDatabase", "itf_database"] call _extdb3;

        ["setDatabaseName", "extdb3"] call _extdb3;

        ["setQueryType", "SQL"] call _extdb3;

        _result = "connect" call _extdb3;

        private _query_data = "SELECT * FROM condizioni";

 

        _result = ["executeQuery", _query_data] call _extdb3;

 

if (_result isequalto [])then {

 

        private _query_data = "INSERT INTO condizioni (data, clima) VALUES" + format ["('%1', '%2')",date, overcast];

        _result = ["executeQuery", _query_data] call _extdb3;

 

}else{

 

        _data       = call compile (_result select 0 select 1);

        _clima      =  (_result select 0 select 2);

 

        [_data] remoteExec ["setDate"];

        [[], {setDate _data}] remoteExec ["call",0,"JIP_id_setDate"];

        //setDate _date;                        // data e ora

        0 setOvercast _clima; 

        forceWeatherChange;

 

};

 

[[], "initplayer.sqf"] remoteExec ["BIS_fnc_execVM",0,true];  // call data player


initplayer.sqf
 

  Reveal hidden contents

if (! hasInterface ) exitWith {}; 
 

_UID        = getPlayerUID player;

 

        private _extdb3 = "new" call OO_EXTDB3;

        ["setIniSectionDatabase", "itf_database"] call _extdb3;

        ["setDatabaseName", "extdb3"] call _extdb3;

        ["setQueryType", "SQL"] call _extdb3;

        _result = "connect" call _extdb3;

        private _query = "SELECT * FROM players WHERE clientID =" + format ["'%1'",_UID];

 

        _result = ["executeQuery", _query] call _extdb3;

 

_pos        = call compile (_result select 0 select 3);

_uncons     = call compile (_result select 0 select 4);

_inventory  = (_result select 0 select 5);

_bullet_1   = call compile (_result select 0 select 6);

_bullet_2   = call compile (_result select 0 select 7);

_bullet_3   = call compile (_result select 0 select 8);

 

        player setPosATL _pos;

 

removeAllWeapons        player;

removeAllItems          player;

removeAllAssignedItems  player;

removeUniform           player;

removeVest              player;

removeBackpack          player;

removeHeadgear          player;

removeGoggles           player;

 

player setUnitLoadout   _inventory;     

player setAmmo [primaryWeapon player, _bullet_1];

player setAmmo [secondaryWeapon player, _bullet_2];

player setAmmo [handgunWeapon player, _bullet_3];

 

_damageVar = call compile (_result select 0 select 9);

 

 

  • Thanks 1

Share this post


Link to post
Share on other sites

it s not relative to oo_extDB3;

 

You should use the database on server side, and send date to client.

Share this post


Link to post
Share on other sites
1 hour ago, code34 said:

non è relativo a oo_extDB3;

 

È necessario utilizzare il database sul lato server e inviare la data al client.

I put the database on the server but how can I send it to the client?
What do you mean by sending?
thanks

Share this post


Link to post
Share on other sites

You have to send the data from the arma server to the arma clients through mp commands 🙂

 

Ask on scripts forum how to do that through command like publicvariable

 

Share this post


Link to post
Share on other sites
On 3/4/2021 at 15:54, code34 said:

Devi inviare i dati dal server arma ai client arma tramite i comandi mp 🙂

 

Chiedi sul forum degli script come farlo tramite comandi come publicvariable

 

thanks
Best regard 😊

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×