Jump to content

Recommended Posts

ive been having issues with my server saving things i got it to save everything but now houses wont save... if anyone can help me figure out how to fix it i would be very grateful!

What would you say is your understanding of SQF and or SQL on a scale of 1/10: 2.5(dabbled in all types of coding though)

server rpt: https://pastebin.com/MTN1uess

extdb log: No errors

client RPT: https://pastebin.com/WybrKmSR

Edited by Outlaw

Share this post


Link to post
Share on other sites

It would look like it's having problems converting things to arrays then inserting said arrays into the database.

Quote

 0:56:22 Error in expression <[0,<null>,0]>
 0:56:23   Error position: <<null>,0]>
 0:56:23   Error Invalid number in expression
 0:56:23 Error in expression <[0,<null>,0]>
 0:56:23   Error position: <<null>,0]>
 0:56:23   Error Invalid number in expression
 0:56:23 Error in expression <ay = call compile format["%1", _array];
_array;>
 0:56:23   Error position: <_array;>
 0:56:23   Error Undefined variable in expression: _array
 0:56:23 File \life_server\Functions\MySQL\fn_mresToArray.sqf [DB_fnc_mresToArray], line 26
 0:56:23 Error in expression <playtime_values_request pushBack [_uid, _new];
};
[_uid,_new select 2] call TON_>
 0:56:23   Error position: <_new];
};
[_uid,_new select 2] call TON_>
 0:56:23   Error Undefined variable in expression: _new
 0:56:23 File \life_server\Functions\MySQL\fn_queryRequest.sqf [DB_fnc_queryRequest], line 178
 0:56:23 Error in expression <) isEqualTo _uid) exitWith {
_x set [1, _time_gathered];
_x set [2, time];
};
} >
 0:56:23   Error position: <_time_gathered];
_x set [2, time];
};
} >
 0:56:23   Error Undefined variable in expression: _time_gathered
 0:56:23 File \life_server\Functions\PlayTime\fn_setPlayTime.sqf [TON_fnc_setPlayTime], line 24
 0:56:23 Error in expression <elect 12)] call DB_fnc_mresToArray;
if (_new isEqualType "") then {_new = call c>
 0:56:23   Error position: <_new isEqualType "") then {_new = call c>
 0:56:23   Error Undefined variable in expression: _new
 0:56:23 File \life_server\Functions\MySQL\fn_queryRequest.sqf [DB_fnc_queryRequest], line 171

 


Check if your fn_mresToArray.sqf (@life_server > Functions > MySQL) looks like this:

Quote

 

/*
    File: fn_mresToArray.sqf
    Author: Bryan "Tonic" Boardwine";

    Description:
    Acts as a mres (MySQL Real Escape) for arrays so they
    can be properly inserted into the database without causing
    any problems. The return method is 'hacky' but it's effective.
*/
private["_array"];
_array = [_this,0,"",[""]] call BIS_fnc_param;
if (_array isEqualTo "") exitWith {[]};
_array = toArray(_array);

for "_i" from 0 to (count _array)-1 do
{
    _sel = _array select _i;
    if (_sel == 96) then
    {
        _array set[_i,39];
    };
};

_array = toString(_array);
_array = call compile format["%1", _array];
_array;

 


And check if your fn_queryRequest.sqf (@life_server\Functions\MySQL) looks like this:

Quote

 

#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","_queryResult","_tickTime","_tmp"];
_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;

_query = switch (_side) do {
    // West - 11 entries returned
    case west: {format["SELECT playerid, name, cash, bankacc, adminlevel, donorlevel, cop_licenses, coplevel, cop_gear, blacklist, cop_stats, playtime FROM players WHERE playerid='%1'",_uid];};
    // Civilian - 12 entries returned
    case civilian: {format["SELECT playerid, name, cash, bankacc, adminlevel, donorlevel, civ_licenses, arrested, civ_gear, civ_stats, civ_alive, civ_position, playtime FROM players WHERE playerid='%1'",_uid];};
    // Independent - 10 entries returned
    case independent: {format["SELECT playerid, name, cash, bankacc, adminlevel, donorlevel, med_licenses, mediclevel, med_gear, med_stats, playtime FROM players WHERE playerid='%1'",_uid];};
};

_tickTime = diag_tickTime;
_queryResult = [_query,2] call DB_fnc_asyncCall;

if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 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 (_queryResult isEqualType "") exitWith {
    [] remoteExecCall ["SOCK_fnc_insertPlayerInfo",_ownerID];
};

if (count _queryResult isEqualTo 0) exitWith {
    [] remoteExecCall ["SOCK_fnc_insertPlayerInfo",_ownerID];
};

//Blah conversion thing from a2net->extdb
_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 (_new isEqualType "") 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 (_new isEqualType "") 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 (_new isEqualType "") then {_new = call compile format["%1", _new];};
        _queryResult set[10,_new];

        //Playtime
        _new = [(_queryResult select 11)] call DB_fnc_mresToArray;
        if (_new isEqualType "") then {_new = call compile format["%1", _new];};
        _index = TON_fnc_playtime_values_request find [_uid, _new];
        if (_index != -1) then {
            TON_fnc_playtime_values_request set[_index,-1];
            TON_fnc_playtime_values_request = TON_fnc_playtime_values_request - [-1];
            TON_fnc_playtime_values_request pushBack [_uid, _new];
        } else {
            TON_fnc_playtime_values_request pushBack [_uid, _new];
        };
        [_uid,_new select 0] call TON_fnc_setPlayTime;
    };

    case civilian: {
        _queryResult set[7,([_queryResult select 7,1] call DB_fnc_bool)];

        //Parse Stats
        _new = [(_queryResult select 9)] call DB_fnc_mresToArray;
        if (_new isEqualType "") then {_new = call compile format["%1", _new];};
        _queryResult set[9,_new];

        //Position
        _queryResult set[10,([_queryResult select 10,1] call DB_fnc_bool)];
        _new = [(_queryResult select 11)] call DB_fnc_mresToArray;
        if (_new isEqualType "") then {_new = call compile format["%1", _new];};
        _queryResult set[11,_new];

        //Playtime
        _new = [(_queryResult select 12)] call DB_fnc_mresToArray;
        if (_new isEqualType "") then {_new = call compile format["%1", _new];};
        _index = TON_fnc_playtime_values_request find [_uid, _new];
        if (_index != -1) then {
            TON_fnc_playtime_values_request set[_index,-1];
            TON_fnc_playtime_values_request = TON_fnc_playtime_values_request - [-1];
            TON_fnc_playtime_values_request pushBack [_uid, _new];
        } else {
            TON_fnc_playtime_values_request pushBack [_uid, _new];
        };
        [_uid,_new select 2] call TON_fnc_setPlayTime;

        _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 (_new isEqualType "") then {_new = call compile format["%1", _new];};
        _queryResult set[9,_new];

        //Playtime
        _new = [(_queryResult select 10)] call DB_fnc_mresToArray;
        if (_new isEqualType "") then {_new = call compile format["%1", _new];};
        _index = TON_fnc_playtime_values_request find [_uid, _new];
        if (_index != -1) then {
            TON_fnc_playtime_values_request set[_index,-1];
            TON_fnc_playtime_values_request = TON_fnc_playtime_values_request - [-1];
            TON_fnc_playtime_values_request pushBack [_uid, _new];
        } else {
            TON_fnc_playtime_values_request pushBack [_uid, _new];
        };
        [_uid,_new select 1] call TON_fnc_setPlayTime;
    };
};

publicVariable "TON_fnc_playtime_values_request";

_keyArr = missionNamespace getVariable [format["%1_KEYS_%2",_uid,_side],[]];
_queryResult set[15,_keyArr];

_queryResult remoteExec ["SOCK_fnc_requestReceived",_ownerID];

 

Here is a Pastebin containing both of the above files (it may be easier to compare to)

The problem may also be in your fn_addHouse.sqf (@life_server > Functions > Housing) check if yours matches this:

Quote

 

#include "\life_server\script_macros.hpp"
/*
    File: fn_addHouse.sqf
    Author: Bryan "Tonic" Boardwine

    Description:
    Inserts the players newly bought house in the database.
*/
private["_housePos","_query"];
params [
    ["_uid","",[""]],
    ["_house",objNull,[objNull]]
];
if (isNull _house || _uid isEqualTo "") exitWith {};

_housePos = getPosATL _house;

_query = format["INSERT INTO houses (pid, pos, owned) VALUES('%1', '%2', '1')",_uid,_housePos];
if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then {
    diag_log format["Query: %1",_query];
};

[_query,1] call DB_fnc_asyncCall;

uiSleep 0.3;

_query = format["SELECT id FROM houses WHERE pos='%1' AND pid='%2' AND owned='1'",_housePos,_uid];
_queryResult = [_query,2] call DB_fnc_asyncCall;
//systemChat format["House ID assigned: %1",_queryResult select 0];
_house setVariable["house_id",(_queryResult select 0),true];

 


If it's not in any of those files then it could be an issue with your fn_buyHouse.sqf  (missionfile > core > housing) here is the default one to compare:

Quote

 

#include "..\..\script_macros.hpp"
/*
    File: fn_buyHouse.sqf
    Author: Bryan "Tonic" Boardwine

    Description:
    Buys the house?
*/
private["_house","_uid","_action","_houseCfg"];
_house = param [0,ObjNull,[ObjNull]];
_uid = getPlayerUID player;

if (isNull _house) exitWith {};
if (!(_house isKindOf "House_F")) exitWith {};
if (_house getVariable ["house_owned",false]) exitWith {hint localize "STR_House_alreadyOwned";};
if (!isNil {(_house getVariable "house_sold")}) exitWith {hint localize "STR_House_Sell_Process"};
if (!license_civ_home) exitWith {hint localize "STR_House_License"};
if (count life_houses >= (LIFE_SETTINGS(getNumber,"house_limit"))) exitWith {hint format[localize "STR_House_Max_House",LIFE_SETTINGS(getNumber,"house_limit")]};
closeDialog 0;

_houseCfg = [(typeOf _house)] call life_fnc_houseConfig;
if (count _houseCfg isEqualTo 0) exitWith {};

_action = [
    format[localize "STR_House_BuyMSG",
    [(_houseCfg select 0)] call life_fnc_numberText,
    (_houseCfg select 1)],localize "STR_House_Purchase",localize "STR_Global_Buy",localize "STR_Global_Cancel"
] call BIS_fnc_guiMessage;

if (_action) then {
    if (BANK < (_houseCfg select 0)) exitWith {hint format [localize "STR_House_NotEnough"]};
    BANK = BANK - (_houseCfg select 0);

    if (life_HC_isActive) then {
        [_uid,_house] remoteExec ["HC_fnc_addHouse",HC_Life];
    } else {
        [_uid,_house] remoteExec ["TON_fnc_addHouse",RSERV];
    };

    [1] call SOCK_fnc_updatePartial;

    if (LIFE_SETTINGS(getNumber,"player_advancedLog") isEqualTo 1) then {
        if (LIFE_SETTINGS(getNumber,"battlEye_friendlyLogging") isEqualTo 1) then {
            advanced_log = format ["bought a house for $%1. Bank Balance: $%2  On Hand Cash: $%3",[(_houseCfg select 0)] call life_fnc_numberText,[BANK] call life_fnc_numberText,[CASH] call life_fnc_numberText];
        } else {
            advanced_log = format ["%1 - %2 bought a house for $%3. Bank Balance: $%4  On Hand Cash: $%5",profileName,(getPlayerUID player),[(_houseCfg select 0)] call life_fnc_numberText,[BANK] call life_fnc_numberText,[CASH] call life_fnc_numberText];
        };
        publicVariableServer "advanced_log";
    };

    _house setVariable ["house_owner",[_uid,profileName],true];
    _house setVariable ["locked",true,true];
    _house setVariable ["containers",[],true];
    _house setVariable ["uid",floor(random 99999),true];

    life_vehicles pushBack _house;
    life_houses pushBack [str(getPosATL _house),[]];
    _marker = createMarkerLocal [format["house_%1",(_house getVariable "uid")],getPosATL _house];
    _houseName = FETCH_CONFIG2(getText,"CfgVehicles",(typeOf _house), "displayName");
    _marker setMarkerTextLocal _houseName;
    _marker setMarkerColorLocal "ColorBlue";
    _marker setMarkerTypeLocal "loc_Lighthouse";
    _numOfDoors = FETCH_CONFIG2(getNumber,"CfgVehicles",(typeOf _house),"numberOfDoors");
    for "_i" from 1 to _numOfDoors do {
        _house setVariable [format["bis_disabled_Door_%1",_i],1,true];
    };
};

 

Q1: Did your files look like the ones I posted? If they didn't please, Pastebin those files and post them.

Share this post


Link to post
Share on other sites

Please post fn_getPlayTime.sqf (@life_server\Functions\PlayTime).

Q1: Before you started having these issues did you add/remove anything? If so, what?

Share this post


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

so i deleted my line again and when i joined it set it to the right format

a9b6722b62ac2752bbcdc9f8e653d06a.png
https://gyazo.com/a9b6722b62ac2752bbcdc9f8e653d06a

but when i synced and left and came back it went back to this

31af7fbbff0ba77371cc29d3001110c0.png
https://gyazo.com/31af7fbbff0ba77371cc29d3001110c0

Ah, that's not the same issue then, as @Fawks said, you seem to have issues with arrays converting to DB strings in general. I would recommend download a fresh 5.0 copy: https://github.com/AsYetUntitled/Framework/archive/master.zip

Then try using that and see if you have the same issues.

Share this post


Link to post
Share on other sites
3 minutes ago, Outlaw said:

im using 4.4R4 my server host said 5.0 isnt stable is that true?

 

Depends what you mean by stable. In software, Stable often refers to unchanging, so no major things will change, and functions will be equivalent. 5.0 is not that, as it's still in development. It doesn't crash or do anything odd though, so if that's what you mean by stable, it is. 4.4R4 is over 2 years old, you should be using 5.0 and then just making whatever changes (commits) happen in the official repository to your own project to keep things up to date: https://github.com/AsYetUntitled/Framework/commits/master

Share this post


Link to post
Share on other sites

i managed to fix the stuff saving and houses by just reinstalling the debit card script on a new life_server file but im still getting a playtime error which will probably cause issues later down the road

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×