Moin zusammen,
bin nun doch endlich am verzweifeln und weiß echt nicht mehr weiter.
Entweder sehe ich den Code vor lauter Code nicht mehr oder ich habe einfach Tomaten auf den Augen.
Ich bin dabei ein eigenes kleines Versicherungsscript zu basteln. Wenn jemand fragt warum, weil es ja schon welche gibt?
Weil ich Spaß dran habe und mich weiterbilden möchte
Nun mal eben zu meinem Problem:
Ich habe eine Datei zum abfragen eines Wertes in der Datenbank angelegt. Der Wert existiert auch in der DB und sollte eine einfach 0 zurück geben.
#include "..\..\script_macros.hpp"
/*
File: fn_fetchInsurance.sqf
Author: Samero Richter @RP-INFINITY
Description:
Fetch the insurancestatus
*/
private ["_vehicle","_vehicleLife","_vid","_pid"];
disableSerialization;
if ((lbCurSel 2802) isEqualTo -1) exitWith {hint localize "STR_Global_NoSelection"};
_vehicle = lbData[2802,(lbCurSel 2802)];
_vehicle = (call compile format ["%1",_vehicle]) select 0;
_vehicleLife = _vehicle;
_vid = lbValue[2802,(lbCurSel 2802)];
_pid = getPlayerUID player;
_class = [_this,0,"",[""]] call BIS_fnc_param;
if (_class isEqualTo "") exitWith {[]}; //Bad class passed.
if (!isClass (configFile >> "CfgVehicles" >> _class)) exitWith {[]}; //Class doesn't exist in CfgVehicles
//Fetch
if (life_HC_isActive) then {
_statusReq = [_vid,_pid,player,life_garage_type] remoteExecCall ["HC_fnc_vehicleInsuranceStatus",HC_Life];
} else {
_statusReq = [_vid,_pid,player,life_garage_type] remoteExecCall ["TON_fnc_vehicleInsuranceStatus",RSERV];
_status = _return;
diag_log "----------------------------";
diag_log format ["Status %1",_status];
diag_log format ["StatusReq %1",_statusReq];
diag_log format ["RETURN %1",_return];
diag_log "----------------------------";
if (isNil "_status") then {
hint format ["%1",(_status select 0)];
diag_log "----------------------------";
diag_log format ["Status %1",_status];
diag_log format ["StatusReq %1",_statusReq];
diag_log "----------------------------";
} else {
hint format ["Komisch ... %1",_status];
};
};
Alles anzeigen
Die hint's habe ich einfach nur mal provisorisch eingefügt, damit ich eine kleine Rückmeldung der Werte habe. Dazu später mehr
Dann habe ich eine Datei im life_server erstellt um die Datenbank abfrage zu machen und mir einen return zu liefern.
#include "\life_server\script_macros.hpp"
/*
FETCH Insurance Status
*/
private ["_vid", "_pid", "_unit", "_type"];
_vid = [_this,0,-1,[0]] call BIS_fnc_param;
_pid = [_this,1,"",[""]] call BIS_fnc_param;
_unit = [_this,2,objNull,[objNull]] call BIS_fnc_param;
_type = [_this,3,"",[""]] call BIS_fnc_param;
if (_vid isEqualTo -1 || _pid isEqualTo "" || isNull _unit || _type isEqualTo "") exitWith {};
_unit = owner _unit;
_query = format ["SELECT insurance_status FROM vehicles WHERE pid='%1' AND id='%2'",_pid,_vid];
_queryResult = [_query,2] call DB_fnc_asyncCall;
if (_queryResult isEqualTo "") exitWith {};
_return = (_queryResult select 0);
if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then {
_tickTime = diag_tickTime;
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 - Status: %2",(_queryResult),_return];
diag_log "------------------------------------------------";
};
_return;
Alles anzeigen
Mein Problem ist nun, dass ich nicht den korrekten Wert von dem _return abfragen kann.
Als Ausgabe bekomme ich immer folgendes:
für den ersten Quellcode:
23:20:40 "----------------------------"
23:20:40 "Status any"
23:20:40 "StatusReq "
23:20:40 "RETURN any"
23:20:40 "----------------------------"
23:20:40 "----------------------------"
23:20:40 "Status any"
23:20:40 "StatusReq "
23:20:40 "----------------------------"
für den 2. :
"------------- Client Query Request -------------"
"QUERY: SELECT insurance_status FROM vehicles WHERE pid='76561198202839964' AND id='25'"
"Time to complete: 0 (in seconds)"
"Result: [0] - Status: 0"
"------------------------------------------------"
Die Dateien sind auch korrekt in der CfgRemoteExec.hpp und in der config.cpp hinzugefügt.
Hat da jemand eine Idee und kann mir weiter helfen? Würde mich MEGA freuen, wenn das dann doch mal funktioniert
Grund und vielen Dank
Samero