Шесть дней назад решил прикрутить базу данных к своей миссии писал код для inidbi или inidbi2, пробовал обе проблема в том что запись в базу данных есть а вот чтения нету. То есть я захожу на сервер, лутаюсь, файл создается в раз в N секунд перезаписывается, выхожу файл остается, при повторном входе на сервер чистый пользователь в точке респавна, файл перезаписывался на чистого пользователя , устал извращаться может кто писал для миссии себе поделитесь реализацией. Перепробовал все примеры и бубны с форума бисов ну чето то не как.
Нужно сохранить в БД, и при повторном заходе на сервер считать для каждого игрока:
- Позицию
- Вектор
- Здоровье
- Кислород
- Униформа
- Униформа предметы
- Рюкзак
- Рюкзак предметы
- Жилет
- Жилет предметы
- Головной убор
- Очки
- Гаджеты (карта, компас, GPS, ПНВ, часы и т.д.)
- Оружие включая примари и секондари
- Модули оружия
- Магазины
- Позиция техники (Не обязательно)
За ранее спасибо если кто может помочь. ![]()
Вот такая фигня для inidbi получилась:
init.sqf
call compile preProcessFile "\inidbi\init.sqf";
call compile preProcessFile "iniDB\Arma3functions.sqf";
execVM "iniDB\DeleteItems.sqf";
abc_LoadplayerPos = {
private ["_loadpos"];
_loadpos = _this select 0;
_Profile = format["%1", getPlayerUID _loadpos];
//============ Load Stats
//PLAYER
_playerPos = [_Profile, "location", "ARRAY"] call iniDB_read;
_playerHealth = [_Profile, "health", "SCALAR"] call iniDB_read;
_playerOxygen = [_Profile, "oxygen", "SCALAR"] call iniDB_read;
//INVENTORY
_playerBackpack = [_Profile, "backpack", "STRING"] call iniDB_read;
_playerBackpackGear = [_Profile, "backpackGear", "ARRAY"] call iniDB_read;
_playerVest = [_Profile, "vest", "STRING"] call iniDB_read;
_playerVestGear = [_Profile, "vestGear", "ARRAY"] call iniDB_read;
_playerUniform = [_Profile, "uniform", "STRING"] call iniDB_read;
_playerUniformGear = [_Profile, "uniformGear", "ARRAY"]call iniDB_read;
_playerGadgets = [_Profile, "gadgets", "ARRAY"] call iniDB_read;
_playerHeadgear = [_Profile, "headgear", "STRING"] call iniDB_read;
_playerGoggles = [_Profile, "goggles", "STRING"] call iniDB_read;
_playerWep = [_Profile, "weapons", "ARRAY"] call iniDB_read;
_playerPrimWepAttach = [_Profile, "primWeaponAttachments", "ARRAY"] call iniDB_read;
_playerSecWepAttach = [_Profile, "secWeaponAttachments", "ARRAY"] call iniDB_read;
_playerMagazines = [_Profile, "magazines", "ARRAY"] call iniDB_read;
_loadpos setpos _playerPos;
_loadpos setdamage _playerHealth;
_loadpos setOxygenRemaining _playerOxygen;
_loadpos addBackpack _playerBackpack;
for "_i" from 0 to (count _playerBackpack) do {_loadpos addItemToBackpack (_playerBackpack (select _i)}; //ошибка
_loadpos addVest _playerVest;
for "_i" from 0 to (count _playerVestGear) do {_loadpos addItemToVest (_playerVestGear (select _i)}; //ошибка
_loadpos forceAddUniform _playerUniform;
for "_i" from 0 to (count _playerUniformGear) do {_loadpos addItemToUniform (select _i)}; //ошибка
for "_i" from 0 to (count _playerGadgets) do {_loadpos linkItem (_playerGadgets (select _i)};//ошибка
_loadpos addHeadgear _playerHeadgear;
_loadpos addGoggles _playerGoggles;
for "_y" from 0 to (count _playerWep) do {_loadpos addWeapon (_playerWep (select _y)}; //ошибка
for "_y" from 0 to (count _PrimWepAttach) do {_loadpos addWeapon (_PrimWepAttach (select _i)}; //ошибка
for "_y" from 0 to (count _playerSecWepAttach) do {_loadpos addWeapon (_playerSecWepAttach (select _i)}; //ошибка
for "_i" from 0 to (count _playerMagazines) do {_loadpos addMagazine (_playerMagazines (select _i)}; //ошибка
//_loadpos setSpeaker "rhs_Male01RUS"; //RHS
};
if(isServer) then {
[] execVM "iniDB\SavePlayer.sqf";
};
if(isServer) then {
[] execVM "iniDB\SavePlayer.sqf";
};
Arma3functions.sqf
// Do not edit this file!
// This file may only be edited by Engima's ASCOM Editor!
//
// <ASCOM version="1">
// <Prefix>abc_</Prefix>
// <Functions>
// <Function Name="LoadplayerPos" Params="loadpos" Ret="false" A="false" C="false" S="true" O="false" OC="false" P="false" />
// <Function Name="LoadPlayerWeapon" Params="weapon" Ret="false" A="false" C="false" S="true" O="false" OC="false" P="false" />
// </Functions>
// </ASCOM>
ASCOM_ClientID = 0;
ASCOM_CallID = 0;
ASCOM_LastCallID = 0;
ASCOM_LockCallID = 0;
"abc_LoadplayerPosEventArgs" addPublicVariableEventHandler {
private ["_array"];
_array = _this select 1;
_array spawn {
if ((_this select 0 == "A") || (_this select 0 == "C" && !isDedicated)) then {
(_this select 1) call abc_LoadplayerPos;
};
if (_this select 0 == "S" && isServer) then {
(_this select 1) call abc_LoadplayerPos;
};
};
};
abc_LoadplayerPosServer = {
if (isNil "_this") then { _this = []; };
if (isServer) then {
_this call abc_LoadplayerPos;
}
else {
abc_LoadplayerPosEventArgs = ["S", _this];
publicVariable "abc_LoadplayerPosEventArgs";
abc_LoadplayerPosEventArgs = [];
};
};
"abc_LoadPlayerWeaponEventArgs" addPublicVariableEventHandler {
private ["_array"];
_array = _this select 1;
_array spawn {
if ((_this select 0 == "A") || (_this select 0 == "C" && !isDedicated)) then {
(_this select 1) call abc_LoadPlayerWeapon;
};
if (_this select 0 == "S" && isServer) then {
(_this select 1) call abc_LoadPlayerWeapon;
};
};
};
abc_LoadPlayerWeaponServer = {
if (isNil "_this") then { _this = []; };
if (isServer) then {
_this call abc_LoadPlayerWeapon;
}
else {
abc_LoadPlayerWeaponEventArgs = ["S", _this];
publicVariable "abc_LoadPlayerWeaponEventArgs";
abc_LoadPlayerWeaponEventArgs = [];
};
};
if (isServer) then {
"ASCOM_AskForClientID" addPublicVariableEventHandler {
private ["_unit"];
_unit = _this select 1;
ASCOM_AskForClientID = [];
ASCOM_LastCallID = ASCOM_LastCallID + 1;
ASCOM_ClientIDResponse = [_unit, ASCOM_LastCallID];
publicVariable "ASCOM_ClientIDResponse";
};
ASCOM_ServerInitialized = true;
publicVariable "ASCOM_ServerInitialized";
ASCOM_Initialized = true;
}
else {
"ASCOM_ClientIDResponse" addPublicVariableEventHandler {
private ["_array"];
_array = _this select 1;
ASCOM_ClientIDResponse = [];
if (player == (_array select 0)) then {
ASCOM_ClientID = _array select 1;
ASCOM_Initialized = true;
};
};
waitUntil {!isNull player};
ASCOM_AskForClientID = player;
publicVariable "ASCOM_AskForClientID";
};
DeleteItems.sqf
removeAllWeapons player; removeAllItems player; removeAllAssignedItems player; removeUniform player; removeVest player; removeBackpack player; removeHeadgear player; removeGoggles player; [player] call abc_LoadplayerPosServer; //ошибка
SavePlayer.sqf
if(isServer) then {
while{true} do {
{
if(isPlayer _x) then {
sleep 5;
_Profile = format ["%1", getPlayerUID _x];
//============ Save Stats
//PLAYER
[_Profile, "playerData", "name", name _x] call iniDB_write;
[_Profile, "playerData", "location", position _x] call iniDB_write;
[_Profile, "playerData", "oxygen", getOxygenRemaining _x] call iniDB_write;
[_Profile, "playerData", "health", damage _x] call iniDB_write;
//INVENTORY
[_Profile, "playerData", "backpack", backpack _x] call iniDB_write;
[_Profile, "playerData", "backpackGear", backpackItems _x] call iniDB_write;
[_Profile, "playerData", "vest", vest _x] call iniDB_write;
[_Profile, "playerData", "vestGear", vestItems _x] call iniDB_write;
[_Profile, "playerData", "uniform", uniform _x] call iniDB_write;
[_Profile, "playerData", "uniformGear", uniformItems _x] call iniDB_write;
[_Profile, "playerData", "gadgets", assignedItems _x] call iniDB_write;
[_Profile, "playerData", "headgear", headgear _x] call iniDB_write;
[_Profile, "playerData", "goggles", goggles _x] call iniDB_write;
[_Profile, "playerData", "weapons", weapons _x] call iniDB_write;
[_Profile, "playerData", "primWeaponAttachments", primaryWeaponItems _x] call iniDB_write;
[_Profile, "playerData", "secWeaponAttachments", secondaryWeaponItems _x] call iniDB_write;
[_Profile, "playerData", "magazines", magazinesAmmoFull _x] call iniDB_write;
systemChat "Сохранение...";
};
} forEach allUnits;
}
};
Че ей не так не пойму
сделано вроде по рабочему примеру:
Сообщение отредактировал Shadow_last: 24 March 2016 - 05:45











