Advertisement
Guest User

Untitled

a guest
Mar 12th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.54 KB | None | 0 0
  1. scriptName "fn_aapps_sellObject";
  2. /*
  3.  *
  4.  *  @File:      fn_aapps_changeObjectOwner.sqf
  5.  *  @Author:    AllianceApps
  6.  *  @Date:      17.12.2017
  7.  *
  8.  *  You are not allowed to use this script or remove the credits of the script without written permission of the author.
  9.  *  You are not allowed to use this script without a valid license. License terms apply.
  10.  *
  11.  *  Du darfst dieses Script nicht nutzen oder diesen Copyright-Hinweis nicht entfernen, wenn du keine schriftliche Bestätigung des Autors hast.
  12.  *  Du darfst dieses Script nicht ohne gültige Lizenz nutzen. Die Lizenzbestimmungen für Scripts sind zu beachten.
  13.  *  
  14.  */
  15. _type = [_this, 0, -1] call bis_fnc_param;
  16. _newuid = [_this, 1, -1] call bis_fnc_param;
  17. _newside = [_this, 2, sideUnknown] call bis_fnc_param;
  18. _olduid = [_this, 3, -1] call bis_fnc_param;
  19. _oldside = [_this, 4, sideUnknown] call bis_fnc_param;
  20. _index = [_this, 5, -1] call bis_fnc_param;
  21. _object = [_this, 6, objNull] call bis_fnc_param;
  22. if((_type isEqualTo -1) OR {_newUid isEqualTo -1} OR {sideUnknown isEqualTo _newside} OR {_olduid isEqualTo -1} OR {sideUnknown isEqualTo _oldside} OR {_index isEqualTo -1}) exitWith {diag_log format["Object_sell: Error - serverside parameters are wrong. Info: %1",_this]};
  23.  
  24. _query = format["INSERT INTO sold_objects (olduid, newuid, index_value, object_classname) VALUES('%1','%2','%3','%4')",_olduid,_newuid,_index,typeof _object];
  25. [_query,1] call DB_fnc_asyncCall;
  26. if(_type isEqualTo 0) then {
  27.     _query = format["UPDATE houses SET pid='%1' WHERE pid='%2' AND id='%3';",_newuid,_olduid,_index];
  28.     [_query,1] call DB_fnc_asyncCall;
  29.     _container = _object getVariable ["containers",[]];
  30.     _query = "";
  31.     {
  32.         _id = _x getVariable ["container_id",-1];
  33.         _owner = _x getVariable ["container_owner",[]];
  34.         if(!(_id isEqualTo -1) && {!(_owner isEqualTo [])}) then {
  35.             _query = format["UPDATE containers SET pid='%1' WHERE id='%2';",_newuid,_id];
  36.             [_query,1] call DB_fnc_asyncCall;
  37.             _x setVariable ["container_owner",[_newuid],true];
  38.         };
  39.     } forEach _container;
  40. } else {
  41.     _query = format["UPDATE vehicles SET pid='%1' WHERE pid='%2' AND plate='%3';",_newuid,_olduid,_index];
  42.     [_query,1] call DB_fnc_asyncCall;
  43. };
  44. if(isNull _object) exitWith {};
  45. _arr = missionNamespace getVariable [format ["%1_KEYS_%2",_olduid,_oldside],[]];
  46. _arr = _arr - [_object];
  47. missionNamespace setVariable [format ["%1_KEYS_%2",_olduid,_oldside],_arr];
  48. _arr = missionNamespace getVariable [format ["%1_KEYS_%2",_olduid,_oldside],[]];
  49. _arr pushBack _object;
  50. missionNamespace setVariable [format ["%1_KEYS_%2",_newuid,_newside],_arr];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement