Smartphone SQL v5.0.0

#1

Salut à tous !

Aujourd’hui je met à jour un ancien tutoriel pour les version 4.4R1 : Sauvegarde des SMS !

Dans un premier temps je vous prierais de ne pas copier / coller certain fichiers, mais de plutôt faire les changement manuellement un par un.

Ce tutoriel va vous ajouter une fonctionnalité de sauvegarde des SMS envoyer entre les joueurs.

Je tiens à remercier GetSomePanda pour ce script.

text alternatif


Côté mission !

  1. Créer un dossier dans core appellé : cellphone

  2. Dans ce dossier créer les fichiers suivant :

fn_cellPhoneCheck.sqf
fn_deleteMessage.sqf
fn_lbChanged.sqf
fn_messagesMenu.sqf
fn_replyMessage.sqf
fn_setupCellPhone.sqf

  1. fn_cellPhoneCheck.sqf
/*
    Author: GetSomePanda / Panda
    Modified: Sezon
    SteamID: 76561198145366418
    File Name: fn_cellPhoneCheck.sqf
    Information: Checks players cellphone for messages on player init.
*/
if (life_HC_isActive) then {
    [player] remoteExecCall ["HC_fnc_cellPhoneRequest",HC_Life];
} else {
    [player] remoteExecCall ["DB_fnc_cellPhoneRequest",2];
};
  1. fn_deleteMessage.sqf
/*
    Author: GetSomePanda / Panda
    Modified: Sezon
    SteamID: 76561198145366418
    File Name: fn_messagesMenu.sqf
    Information: Sets up message menu.
*/
private["_messages","_lbSelectedData","_name","_msg","_time"];
disableSerialization;
_messages = player getVariable "cellphone_messages";
_lbSelectedData = lbData[98112,lbCurSel (98112)];
_lbSelectedData = call compile _lbSelectedData;
_name = _lbSelectedData select 0;
_msg = _lbSelectedData select 1;
_time = _lbSelectedData select 2;

_messages = _messages - [[_name,_msg,_time]];

player setVariable ["cellphone_messages", _messages];
closeDialog 0;
[] spawn life_fnc_messagesMenu;
    
hint format["You have removed a message from %1 saying %2", _name, _msg];
  1. fn_lbChanged.sqf
/*
    Author: GetSomePanda / Panda
    Modified: Sezon V2
    Helped: BoGuu
    SteamID: 76561198145366418
    File Name: fn_lbChanged.sqf
    Information: When new player is selected on the messages list.
*/
private["_message","_data","_nameOnPList","_text", "_delButton","_replyButton","_time","_timeArray","_year","_month","_day","_hour","_minutes"];
disableSerialization;
_text = ((findDisplay 98111) displayCtrl 98113);
_data = lbData[98112,lbCurSel (98112)];
_delButton = ((findDisplay 98111) displayCtrl 98114);
_replyButton = ((findDisplay 98111) displayCtrl 98115);
if (_data == "You have no messages.") then 
{
    _text ctrlSetText "You have no messages.";
} 
else
{
    _data = call compile _data;

    _nameOnPList = _data select 0;
    _message = _data select 1;
    
    _time = _data select 2;
    _timeArray = _time select 1;
    _year = _timeArray select 0;
    _month = _timeArray select 1;
    _day = _timeArray select 2;
    _hour = _timeArray select 3;
    _minutes = _timeArray select 4;
    
    _minutes = toArray(str _minutes);
    if (count _minutes isEqualTo 1) then 
    {
        _minutes = [48,(_minutes select 0)];
        _minutes = toString(_minutes);
    } 
    else 
    {
        _minutes = toString(_minutes);
    };

    _text ctrlSetText format ["""%1"" - %2 \n \nMessage received at %6:%7 on %3/%4/%5 . ", _message, _nameOnPList, _day, _month, _year, _hour, _minutes];
    _delButton ctrlShow true;
    _replyButton ctrlShow true;
};
  1. fn_messagesMenu.sqf
/*
    Author: GetSomePanda / Panda
    Modified: Sezon
    Helped: BoGuu
    SteamID: 76561198145366418
    File Name: fn_messagesMenu.sqf
    Information: Sets up message menu.
*/
private["_messages","_playerList","_infoToPass","_delButton","_replyButton","_time","_timeArray","_year","_month","_day","_hour","_minutes"];

disableSerialization;

createDialog "life_cell_old_msgs";
waitUntil {!isNull (findDisplay 98111)};
_playerList = ((findDisplay 98111) displayCtrl 98112);
_delButton = ((findDisplay 98111) displayCtrl 98114);
_delButton ctrlShow false;
_replyButton = ((findDisplay 98111) displayCtrl 98115);
_replyButton ctrlShow false;

_messages = player getVariable "cellphone_messages";

lbClear _playerlist;

if (count _messages < 1) then {
    _playerList lbAdd format["No Messages Found!"];
    _playerList lbSetdata [(lbSize _playerList)-1, "You have no messages."];
} else {
    {
        _time = _x select 2;
        _timeArray = _time select 1;
        _year = _timeArray select 0;
        _month = _timeArray select 1;
        _day = _timeArray select 2;
        _hour = _timeArray select 3;
        _minutes = _timeArray select 4;
        
        _minutes = toArray(str _minutes);
        if (count _minutes isEqualTo 1) then {
            _minutes = [48,(_minutes select 0)];
            _minutes = toString(_minutes);
        } else {
            _minutes = toString(_minutes);
        };
        
        _infoToPass = format["%1", _x];
        _playerList lbAdd format["%1 - %2:%3 %4/%5/%6", _x select 0, _hour, _minutes, _day, _month, _year];
        _playerList lbSetdata [(lbSize _playerList)-1, _infoToPass];
    } foreach _messages;
};
  1. fn_replyMessage.sqf
/*
    Author: GetSomePanda / Panda
    Modified: Sezon
    SteamID: 76561198145366418
    File Name: fn_replyMessage.sqf
    Information: Reply to the message in my messages.
*/
private["_lbSelectedData","_name","_found"];
disableSerialization;
_lbSelectedData = lbData[98112,lbCurSel (98112)];
_lbSelectedData = call compile _lbSelectedData;
_name = _lbSelectedData select 0;
_found = "";

{
    if (_x getVariable "realname" == _name) then {
        _found = "True";
    }
} foreach playableUnits;

if (_found == "") exitWith { hint "This person is not online at the moment!"};

closeDialog 0;

if (_found == "True") then {
    [_name] call life_fnc_cellphone;
};
  1. fn_setupCellPhone.sqf
/*
    Author: GetSomePanda / Panda
    Modified: Sezon
    SteamID: 76561198145366418
    File Name: fn_setupCellPhone.sqf
    Information: Sets up players cellphone.
*/
private["_informationFound","_messages"];
_informationFound = _this select 0;

if (count _informationFound < 1) exitWith {
    player setVariable ["cellphone_messages",[]];
};

_messages = _informationFound select 2;
_messages = call compile format["%1",_messages];
player setVariable ["cellphone_messages",_messages];
  1. Maintenant dans core / pmenu créer un fichier fn_cellphone.sqf

  2. fn_cellphone.sqf

#include "..\..\script_macros.hpp"
/*
    File: fn_cellphone.sqf
    Author: Alan
    Modified: Sezon
    
    Description:
    Opens the cellphone menu?
*/
private["_display","_units","_type","_name","_lbNum","_msgsButton"];
_name = [_this,0,"",[""]] call BIS_fnc_param;

disableSerialization;
waitUntil {!isNull findDisplay 3000};
_display = findDisplay 3000;
_units = _display displayCtrl 3004;
_msgsButton = _display displayCtrl 3029;

//Hides the messages button if disabled in cfg.
if (getNumber(missionConfigFile >> "CellPhone_Settings" >> "sqlMessages_toggle") == 0) then {
    _msgsButton ctrlShow false;
};

ctrlSetText [3003, ""];
lbClear _units;


if ((FETCH_CONST(life_adminlevel) < 1)) then {
    ctrlShow[3020,false];
    ctrlShow[3021,false];
};
{
    if (alive _x && _x != player) then {
        _type = switch (side _x) do {
            case independent: {"Cop"};
            case west: {"NATO"};
            case civilian: {"Civ"};
            case east: {"Med"};
        };
        _units lbAdd format["%1 (%2)",_x getVariable ["realname",name _x],_type];
        _units lbSetData [(lbSize _units)-1,str(_x)];
        
        if (_name != "") then {
            if (name _x isEqualTo _name) then {
                _lbNum = lbSize(_units);
            };
        };
    };
} forEach playableUnits;

if (_name == "") then {
    lbSetCurSel [3004,0];
} 
else {
    lbSetCurSel [3004,_lbNum];
};
  1. Maintenant dans core / session modifié le fichier fn_updateRequest.sqf en ajoutant à la fin :
_messages = player getVariable "cellphone_messages";

if (life_HC_isActive) then {
    [getPlayerUid player, _messages] remoteExecCall ["HC_fnc_saveCellPhone",HC_Life];
} else {
    [getPlayerUid player, _messages] remoteExecCall ["DB_fnc_saveCellPhone",2];
};
  1. Maintenant dans core modifié le fichier init.sqf en ajoutant à la fin :
[] call life_fnc_cellPhoneCheck;
  1. Maintenant dans dialog modifié le fichier MasterHandler.hpp en ajoutant à la fin :
#include "oldmessages.hpp"
  1. Maintenant dans dialog remplacé le fichier cell_phone.hpp

  2. cell_phone.hpp

https://hastebin.com/qarotezosa.scala

  1. Maintenant dans dialog créer le fichier oldmessages.hpp

  2. oldmessages.hpp

https://hastebin.com/deyofewute.scala

  1. Maintenant dans CfgRemoteExec.hpp modifié le fichier en rajoutant :
F(DB_fnc_cellPhoneRequest,SERVER)
F(DB_fnc_saveCellPhone,SERVER)	
F(DB_fnc_getRealTime,SERVER)
F(life_fnc_setupCellPhone,CLIENT)
F(HC_fnc_cellPhoneRequest,HC)
F(HC_fnc_saveCellPhone,HC)
  1. Maintenant dans Functions.h modifié le fichier en rajoutant :
class CellPhone {
        file = "core\cellphone";
        class cellPhoneCheck {};
        class setupCellPhone {};
        class messagesMenu {};
        class lbChanged {};
        class deleteMessage {};
        class replyMessage {};
};

Côté serveur !

  1. Maintenant dans life_server / Functions / MySQL créer les fichiers suivant :

fn_cellPhoneRequest.sqf
fn_getRealTime.sqf
fn_saveCellPhone.sqf

  1. fn_cellPhoneRequest.sqf
/*
    Author: GetSomePanda / Panda
    Modified: Sezon
    SteamID: 76561198145366418
    File Name: fn_cellPhoneRequest.sqf
    Information: Get phone information from db.
*/
private["_queryResult","_query","_player","_playerName","_playerUid","_cleanMsgs"];

_player = _this select 0;
_playerName = name _player;
_playerUid = getPlayerUid _player;

_query = format["SELECT pid, playerName, messages FROM cellphone WHERE pid='%1'",_playerUid];

_queryResult = [_query,2] call DB_fnc_asyncCall;

if (typeName _queryResult == "STRING") exitWith {
    _cleanMsgs = [(_queryResult select 2)] call DB_fnc_mresToArray;
    _queryResult set[2,_cleanMsgs];
    [_queryResult] remoteExecCall ["life_fnc_setupCellPhone",(owner _player)];
};

if (count _queryResult != 0) exitWith {
    _cleanMsgs = [(_queryResult select 2)] call DB_fnc_mresToArray;
    _queryResult set[2,_cleanMsgs];
    [_queryResult] remoteExecCall ["life_fnc_setupCellPhone",(owner _player)];
};

_query = format["INSERT INTO cellphone (pid, playerName, messages) VALUES('%1', '%2', '""[]""')",
    _playerUid,
    _playerName
];

[_query,1] call DB_fnc_asyncCall;
_queryResult = [];
[_queryResult] remoteExecCall ["life_fnc_setupCellPhone",(owner _player)];
  1. fn_getRealTime.sqf
/*
    Author: GetSomePanda / Panda
    Modified: Sezon
    Helped: BoGuu
    SteamID: 76561198145366418
    File Name: fn_getRealTime.sqf
    Information: Get the real time.
*/
realTime = "extDB3" callExtension "9:LOCAL_TIME";
(owner _this) publicVariableClient "realTime";
  1. fn_getRealTime.sqf
/*
    Author: GetSomePanda / Panda
    Modified: Sezon
    SteamID: 76561198145366418
    File Name: fn_saveCellPhone.sqf
    Information: Saves messages on cellphone to cellphone db.
*/
private["_pid","_msgs"];
_pid = _this select 0;
_msgs = _this select 1;

_msgs = [_msgs] call DB_fnc_mresArray;

_query = format["UPDATE cellphone SET messages='%1' WHERE pid='%2'",_msgs,_pid];
[_query,1] call DB_fnc_asyncCall;
  1. Maintenant dans life_server / config.cpp ajouté dans la class class MySQL ceci :
class cellPhoneRequest {};
class saveCellPhone {};
class getRealTime {};
  1. Maintenant remplacer le contenu de life_server / functions.sqf par :

https://hastebin.com/fukimayovi.sm


Côté SQL !

  1. Executer ce code dans la console sur votre base de donnée :
CREATE TABLE IF NOT EXISTS `cellphone` (
  `pid` varchar(64) NOT NULL,
  `playerName` varchar(32) NOT NULL,
  `messages` text NOT NULL,
  `insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`pid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

MERCI A TOUS, MERCI DE LAISSER LES CREDIT SUR LES FICHIERS

0 Likes

#2

DAP Please test and tell me if there are any errors :wink:

1 Like

#3

Blayfix_Scott Thank you! I will test

0 Likes

#4

Yop, merci pour ton tuto Blayfix Scott, dis moi pense qu’il serait adaptable avec ca ?
https://altisdev.com/topic/7123/nouvelle-interface-menu-y/84

je me doute que je vais devoir faire pas mal d’edite

0 Likes

#5

Kovix5519 bien-sur moi par exemple :

text alternatif

0 Likes

#6

Blayfix_Scott No delete keys Изображение - savepic.net — сервис хранения изображений

0 Likes

#7

DAP Button ?

0 Likes

#8

Blayfix_Scott Yes

0 Likes

#9

DAP

class DeleteButton: Life_RscButtonMenu {
            idc = 98114;
            text = "Delete";
            colorBackground[] = {0.7, 0, 0, 0.7};
            onButtonClick = "[] spawn life_fnc_deleteMessage";
            x = 0.4175 * safezoneW + safezoneX;
            y = 0.643 * safezoneH + safezoneY;
            w = 0.0644531 * safezoneW;
            h = 0.022 * safezoneH;
        };
0 Likes

#10

my oldmessages.hpp https://hastebin.com/udenojuyit.scala

0 Likes

#11

DAP Do you have an ip (private message) that I connect to watch?

0 Likes

#12

Fix 1 !

  1. fn_lbChanged.sqf
/*
    Author: GetSomePanda / Panda
    Modified: Sezon V2
    Helped: BoGuu
    SteamID: 76561198145366418
    File Name: fn_lbChanged.sqf
    Information: When new player is selected on the messages list.
*/
private["_message","_data","_nameOnPList","_text", "_delButton","_replyButton","_time","_timeArray","_year","_month","_day","_hour","_minutes"];
disableSerialization;
_text = ((findDisplay 98111) displayCtrl 98113);
_data = lbData[98112,lbCurSel (98112)];
_delButton = ((findDisplay 98111) displayCtrl 98114);
_replyButton = ((findDisplay 98111) displayCtrl 98115);
if (_data == "You have no messages.") then 
{
    _text ctrlSetText "You have no messages.";
} 
else
{
    _data = call compile _data;

    _nameOnPList = _data select 0;
    _message = _data select 1;
    
    _time = _data select 2;
    _timeArray = _time select 1;
    _year = _timeArray select 0;
    _month = _timeArray select 1;
    _day = _timeArray select 2;
    _hour = _timeArray select 3;
    _minutes = _timeArray select 4;
    
    _minutes = toArray(str _minutes);
    if (count _minutes isEqualTo 1) then 
    {
        _minutes = [48,(_minutes select 0)];
        _minutes = toString(_minutes);
    } 
    else 
    {
        _minutes = toString(_minutes);
    };

    _text ctrlSetText format ["""%1"" - %2 \n \nMessage received at %6:%7 on %3/%4/%5 . ", _message, _nameOnPList, _day, _month, _year, _hour, _minutes];
    _delButton ctrlShow true;
    _replyButton ctrlShow true;
};
0 Likes

#13

Blayfix_Scott Thank you! You are the best !

1 Like

#14

Some nice ! Comme je dit ça vas aidé beaucoup de personne

1 Like

#15

Apparemment une erreur sur l’affichage des messages en flic et Medic , je suis déçu … Mais je trouve pas vraiment

0 Likes

#16

Blayfix_Scott Arf ! Je ne peut pas trop t’aidé je suis plus dans la modélisation :wink:

0 Likes

#17

Ouep ouep :stuck_out_tongue:

0 Likes

#18

Normal que ca ne marche pas tes messages flic et medic :slight_smile:

case 1 : {
            if (side player != independent) exitWith {};   // EUH par défaut c'est plutot west les flics
case 5: {
            if (side player != east) exitWith {};  // Plutot independent pour les medecins

Faut jamais copier/coller les fichiers communs au AltisLife mais simplement indiquer les changements a apporter sinon c’est le meilleurs moyen de tout niquer :slight_smile:

0 Likes

#19

Ouaip on a déjà résolu ça :wink: mais il y a d’autre erreur

0 Likes

#20

The cop button send message to medic and medic button didn’t send message. Have you already fixed this?

0 Likes