1. Dashboard
  2. Forum
    1. Unerledigte Themen
  3. Downloads
  4. Galerie
    1. Alben
  5. Toolbox
    1. Passwort Generator
    2. Portchecker
  6. Mitglieder
    1. Mitgliedersuche
    2. Benutzer online
    3. Trophäen
    4. Team
Do: 17 Juli 2025
  • Anmelden oder registrieren
  • Suche
Dieses Thema
  • Alles
  • Dieses Thema
  • Dieses Forum
  • Artikel
  • Forum
  • Dateien
  • Seiten
  • Bilder
  • Erweiterte Suche

Schön, dass du den Weg zu NodeZone.net gefunden hast! Aktuell bist du nicht angemeldet und kannst deshalb nur eingeschränkt auf unsere Community zugreifen. Um alle Funktionen freizuschalten, spannende Inhalte zu entdecken und dich aktiv einzubringen, registriere dich jetzt kostenlos oder melde dich mit deinem Account an.

Anmelden oder registrieren
    1. Nodezone.net Community
    2. Forum
    3. Gameserver & Hosting
    4. ArmA Series - ArmA 3 / Reforger
    5. Hilfeforum
    6. Archiv

    Datenbankabfrage

    • IN005
    • 27. Juli 2016 um 18:22
    • Geschlossen
    • IN005
      Schüler
      Reaktionen
      52
      Trophäen
      11
      Beiträge
      124
      Bilder
      12
      • 27. Juli 2016 um 18:22
      • #1

      Guten Abend,

      arbeite momentan an nem Script mit DB Abfrage. Nun ist das Problem, dass ich jetzt nicht genau weiß, wie ich die Variable richtig abrufe.

      Code: live_server\Functions\MySQL\ fn_queryRequest.sqf
      #include "\life_server\script_macros.hpp"
      /*
      	File: fn_queryRequest.sqf
      	Author: Bryan "Tonic" Boardwine
      	Description:
      	Handles the incoming request and sends an asynchronous query
      	request to the database.
      	Return:
      	ARRAY - If array has 0 elements it should be handled as an error in client-side files.
      	STRING - The request had invalid handles or an unknown error and is logged to the RPT.
      */
      private["_uid","_side","_query","_return","_queryResult","_qResult","_handler","_thread","_tickTime","_loops","_returnCount"];
      _uid = [_this,0,"",[""]] call BIS_fnc_param;
      _side = [_this,1,sideUnknown,[civilian]] call BIS_fnc_param;
      _ownerID = [_this,2,ObjNull,[ObjNull]] call BIS_fnc_param;
      if(isNull _ownerID) exitWith {};
      _ownerID = owner _ownerID;
      /*
      	_returnCount is the count of entries we are expecting back from the async call.
      	The other part is well the SQL statement.
      */
      _query = switch(_side) do {
      	case west: {_returnCount = 12; format["SELECT playerid, name, cash, bankacc, adminlevel, donatorlvl, cop_licenses, coplevel, cop_gear, blacklist, cop_stats, voted FROM players WHERE playerid='%1'",_uid];};
      	case civilian: {_returnCount = 11; format["SELECT playerid, name, cash, bankacc, adminlevel, donatorlvl, civ_licenses, arrested, civ_gear, civ_stats, voted FROM players WHERE playerid='%1'",_uid];};
      	case independent: {_returnCount = 11; format["SELECT playerid, name, cash, bankacc, adminlevel, donatorlvl, med_licenses, mediclevel, med_gear, med_stats, voted FROM players WHERE playerid='%1'",_uid];};
      };
      _tickTime = diag_tickTime;
      _queryResult = [_query,2] call DB_fnc_asyncCall;
      if(EXTDB_SETTING(getNumber,"DebugMode") == 1) then {
      	diag_log "------------- Client Query Request -------------";
      	diag_log format["QUERY: %1",_query];
      	diag_log format["Time to complete: %1 (in seconds)",(diag_tickTime - _tickTime)];
      	diag_log format["Result: %1",_queryResult];
      	diag_log "------------------------------------------------";
      };
      if(typeName _queryResult == "STRING") exitWith {
      	[] remoteExecCall ["SOCK_fnc_insertPlayerInfo",_ownerID];
      };
      if(count _queryResult == 0) exitWith {
      	[] remoteExecCall ["SOCK_fnc_insertPlayerInfo",_ownerID];
      };
      //Blah conversion thing from a2net->extdb
      private["_tmp"];
      _tmp = _queryResult select 2;
      _queryResult set[2,[_tmp] call DB_fnc_numberSafe];
      _tmp = _queryResult select 3;
      _queryResult set[3,[_tmp] call DB_fnc_numberSafe];
      //Parse licenses (Always index 6)
      _new = [(_queryResult select 6)] call DB_fnc_mresToArray;
      if(typeName _new == "STRING") then {_new = call compile format["%1", _new];};
      _queryResult set[6,_new];
      //Convert tinyint to boolean
      _old = _queryResult select 6;
      for "_i" from 0 to (count _old)-1 do
      {
      	_data = _old select _i;
      	_old set[_i,[_data select 0, ([_data select 1,1] call DB_fnc_bool)]];
      };
      _queryResult set[6,_old];
      _new = [(_queryResult select 8)] call DB_fnc_mresToArray;
      if(typeName _new == "STRING") then {_new = call compile format["%1", _new];};
      _queryResult set[8,_new];
      //Parse data for specific side.
      switch (_side) do {
      	case west: {
      		_queryResult set[9,([_queryResult select 9,1] call DB_fnc_bool)];
      		//Parse Stats
      		_new = [(_queryResult select 10)] call DB_fnc_mresToArray;
      		if(typeName _new == "STRING") then {_new = call compile format["%1", _new];};
      		_queryResult set[10,_new];
      	};
      	case civilian: {
      		_queryResult set[7,([_queryResult select 7,1] call DB_fnc_bool)];
      		//Parse Stats
      		_new = [(_queryResult select 9)] call DB_fnc_mresToArray;
      		if(typeName _new == "STRING") then {_new = call compile format["%1", _new];};
      		_queryResult set[9,_new];
      		_houseData = [_uid] spawn TON_fnc_fetchPlayerHouses;
      		waitUntil {scriptDone _houseData};
      		_queryResult pushBack (missionNamespace getVariable[format["houses_%1",_uid],[]]);
      		_gangData = _uid spawn TON_fnc_queryPlayerGang;
      		waitUntil{scriptDone _gangData};
      		_queryResult pushBack (missionNamespace getVariable[format["gang_%1",_uid],[]]);
      	};
      	case independent: {
      		//Parse Stats
      		_new = [(_queryResult select 9)] call DB_fnc_mresToArray;
      		if(typeName _new == "STRING") then {_new = call compile format["%1", _new];};
      		_queryResult set[9,_new];
      	};
      };
      _keyArr = missionNamespace getVariable [format["%1_KEYS_%2",_uid,_side],[]];
      _queryResult set[14,_keyArr];
      _queryResult remoteExec ["SOCK_fnc_requestReceived",_ownerID];
      Alles anzeigen

      In den Zeilen 23-25 habe ich je am Ende voted hinzugefügt. Jetzt ist mein Problem, ich weiß nicht als was für eine Nummer ich das in der fn_requestReceived abrufen muss.


      Code
      life_voted = _this select (Welche Zahl jetzt bei welcher der drei Seiten??)
      Code: .tanoa\core\sessions\ fn_requestReceived.sqf
      #include "..\..\script_macros.hpp"
      /*
      	File: fn_requestReceived.sqf
      	Author: Bryan "Tonic" Boardwine
      
      
      
      
      	Description:
      	Called by the server saying that we have a response so let's
      	sort through the information, validate it and if all valid
      	set the client up.
      */
      private["_array"];
      life_session_tries = life_session_tries + 1;
      if(life_session_completed) exitWith {}; //Why did this get executed when the client already initialized? F**** arma...
      if(life_session_tries > 3) exitWith {cutText[localize "STR_Session_Error","BLACK FADED"]; 0 cutFadeOut 999999999;};
      
      
      
      
      0 cutText [localize "STR_Session_Received","BLACK FADED"];
      0 cutFadeOut 9999999;
      
      
      
      
      //Error handling and junk..
      if(isNil "_this") exitWith {[] call SOCK_fnc_insertPlayerInfo;};
      if(EQUAL(typeName _this,"STRING")) exitWith {[] call SOCK_fnc_insertPlayerInfo;};
      if(EQUAL(count _this,0)) exitWith {[] call SOCK_fnc_insertPlayerInfo;};
      if(EQUAL(SEL(_this,0),"Error")) exitWith {[] call SOCK_fnc_insertPlayerInfo;};
      if(!(EQUAL(steamid,SEL(_this,0)))) exitWith {[] call SOCK_fnc_dataQuery;};
      
      
      
      
      //Lets make sure some vars are not set before hand.. If they are get rid of them, hopefully the engine purges past variables but meh who cares.
      if(!isServer && (!isNil "life_adminlevel" OR !isNil "life_coplevel" OR !isNil "life_donator")) exitWith {
      	[profileName,getPlayerUID player,"VariablesAlreadySet"] remoteExecCall ["SPY_fnc_cookieJar",RSERV];
      	[profileName,format["Variables set before client initialization...\nlife_adminlevel: %1\nlife_coplevel: %2\nlife_donator: %3",life_adminlevel,life_coplevel,life_donator]] remoteExecCall ["SPY_fnc_notifyAdmins",RCLIENT];
      	sleep 0.9;
      	failMission "SpyGlass";
      };
      
      
      
      
      //Parse basic player information.
      CASH = parseNumber (SEL(_this,2));
      BANK = parseNumber (SEL(_this,3));
      CONST(life_adminlevel,parseNumber (SEL(_this,4)));
      CONST(life_donator,0);
      
      
      
      
      //Loop through licenses
      if(count (SEL(_this,6)) > 0) then {
      	{SVAR_MNS [SEL(_x,0),SEL(_x,1)];} foreach (SEL(_this,6));
      };
      
      
      
      
      life_gear = SEL(_this,8);
      [true] call life_fnc_loadGear;
      
      
      
      
      //Parse side specific information.
      switch(playerSide) do {
      	case west: {
      		CONST(life_coplevel, parseNumber(SEL(_this,7)));
      		CONST(life_medicLevel,0);
      		life_blacklisted = SEL(_this,9);
      		life_voted = _this select (WELCHE ZAHL??); //Switch x to the correct number in the array, every server is different!!!
      		if(EQUAL(LIFE_SETTINGS(getNumber,"save_playerStats"),1)) then {
      			life_hunger = SEL(SEL(_this,10),0);
      			life_thirst = SEL(SEL(_this,10),1);
      		};
      	};
      
      
      
      
      	case civilian: {
      		life_is_arrested = SEL(_this,7);
      		CONST(life_coplevel, 0);
      		CONST(life_medicLevel, 0);
      		life_houses = SEL(_this,10);
      		life_voted = _this select (WELCHE ZAHL??); //Switch x to the correct number in the array, every server is different!!!
      		life_governor = if(getPlayerUID player == (life_rules select 0)) then {true} else {false};
      			if(life_governor) then {
      				player setVariable["governor",true,true];
      				systemChat "Du bist der Präsident von Tanoa!";
      			};
      		if(EQUAL(LIFE_SETTINGS(getNumber,"save_playerStats"),1)) then {
      			life_hunger = SEL(SEL(_this,9),0);
      			life_thirst = SEL(SEL(_this,9),1);
      		};
      		{
      			_house = nearestBuilding (call compile format["%1", SEL(_x,0)]);
      			life_vehicles pushBack _house;
      		} foreach life_houses;
      
      
      
      
      		life_gangData = SEL(_this,11);
      		if(!(EQUAL(count life_gangData,0))) then {
      			[] spawn life_fnc_initGang;
      		};
      		[] spawn life_fnc_initHouses;
      	};
      
      
      
      
      	case independent: {
      		CONST(life_medicLevel, parseNumber(SEL(_this,7)));
      		CONST(life_coplevel,0);
      		life_voted = _this select (WELCHE ZAHL??); //Switch x to the correct number in the array, every server is different!!!
      		if(EQUAL(LIFE_SETTINGS(getNumber,"save_playerStats"),1)) then {
      			life_hunger = SEL(SEL(_this,9),0);
      			life_thirst = SEL(SEL(_this,9),1);
      		};
      	};
      };
      
      
      
      
      if(count (SEL(_this,13)) > 0) then {
      	{life_vehicles pushBack _x;} foreach (SEL(_this,13));
      };
      
      
      
      
      life_session_completed = true;
      Alles anzeigen


      Es wäre toll, wenn sich damit jemand auskennt.
      Falls in einer der beiden Files noch etwas geändert werden muss, bitte sagt es mir.


      LG
      IN005

    • nox 25. März 2023 um 00:57

      Hat das Thema aus dem Forum Hilfeforum - ArmA 3 nach Archiv verschoben.

    Registrieren oder Einloggen

    Du bist noch kein Mitglied von NodeZone.net? Registriere dich kostenlos und werde Teil einer großartigen Community!

    Registrieren

    Ähnliche Themen

    • hint von life_server aus anzeigen

      • John Hannibal Smith
      • 6. Juli 2017 um 12:45
      • Hilfeforum
    • Neue Datenbankabfrage einfügen

      • Pr3datoR
      • 20. April 2017 um 00:45
      • Hilfeforum
    • Einfache Datenbankabfrage

      • sirbenson
      • 10. April 2017 um 18:54
      • Hilfeforum
    • Fehler in der RequestRecieved

      • x33Pingu
      • 23. August 2016 um 15:11
      • Hilfeforum

    Tags

    • Hilfe
    • Datenbank
    • Abfrage
    • fn_queryRequest
    • fn_requestReceived

    Benutzer online in diesem Thema

    • 1 Besucher

    Wichtige Links & Informationen

    Server & Hosting-Ressourcen

      Server Administration & Hosting Basics

      Windows Server Support & Guides

      Linux Server Configuration & Help

      Setting up TeamSpeak 3 & VoIP Servers

      Domains & Web Hosting for Beginners & Professionals

      Cloud Hosting, Docker & Kubernetes Tutorials

    Gameserver & Modding-Ressourcen

      ArmA 3 Tutorials & Script Collection

      Renting & Operating Gameservers

      DayZ Server Management & Help

      FiveM (GTA V) Server & Script Development

      Rust Server Modding & Administration

      Setting up & Optimizing ARK Survival Servers

    NodeZone.net – Deine Community für Gameserver, Server-Hosting & Modding

      NodeZone.net ist dein Forum für Gameserver-Hosting, Rootserver, vServer, Webhosting und Modding. Seit 2015 bietet unsere Community eine zentrale Anlaufstelle für Server-Admins, Gamer und Technikbegeisterte, die sich über Server-Management, Hosting-Lösungen und Spielemodding austauschen möchten.


      Ob Anleitungen für eigene Gameserver, Hilfe bei Root- und vServer-Konfigurationen oder Tipps zu Modding & Scripting – bei uns findest du fundiertes Wissen und praxisnahe Tutorials. Mit einer stetig wachsenden Community findest du hier Antworten auf deine Fragen, Projektpartner und Gleichgesinnte für deine Gaming- und Serverprojekte. Schließe dich NodeZone.net an und werde Teil einer aktiven Community rund um Server-Hosting, Gameserver-Management und Modding-Ressourcen.

    Wer jetzt nicht teilt ist selber Schuld:
    1. Nutzungsbestimmungen
    2. Datenschutzerklärung
    3. Impressum
    4. Urheberrechts- oder Lizenzverstoß melden
  • Trimax Design coded & layout by Gino Zantarelli 2023-2025©
    Community-Software: WoltLab Suite™