SHARE
TWEET

PurchaseVehicleRequest

SDOT Jul 15th, 2016 442 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Edit by Scorpi
  3.  * ExileServer_system_trading_network_purchaseVehicleRequest
  4.  *
  5.  * Exile Mod
  6.  * www.exilemod.com
  7.  * © 2015 Exile Mod Team
  8.  *
  9.  * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
  10.  * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
  11.  */
  12.  
  13. private["_sessionID","_parameters","_vehicleClass","_pinCode","_playerObject","_salesPrice","_playerMoney","_position","_vehicleObject","_responseCode","_nObject", "_position3d","_position2d"];
  14. _sessionID = _this select 0;
  15. _parameters = _this select 1;
  16. _vehicleClass = _parameters select 0;
  17. _pinCode = _parameters select 1;
  18. try
  19. {
  20.     _playerObject = _sessionID call ExileServer_system_session_getPlayerObject;
  21.     if (isNull _playerObject) then
  22.     {
  23.         throw 1;
  24.     };
  25.     if !(alive _playerObject) then
  26.     {
  27.         throw 2;
  28.     };
  29.     if (_playerObject getVariable ["ExileMutex",false]) then
  30.     {
  31.         throw 12;
  32.     };
  33.     _playerObject setVariable ["ExileMutex", true];
  34.     if !(isClass (missionConfigFile >> "CfgExileArsenal" >> _vehicleClass) ) then
  35.     {
  36.         throw 3;
  37.     };
  38.     _salesPrice = getNumber (missionConfigFile >> "CfgExileArsenal" >> _vehicleClass >> "price");
  39.     if (_salesPrice <= 0) then
  40.     {
  41.         throw 4;
  42.     };
  43.     _playerMoney = _playerObject getVariable ["ExileMoney", 0];
  44.     if (_playerMoney < _salesPrice) then
  45.     {
  46.         throw 5;
  47.     };
  48.     if !((count _pinCode) isEqualTo 4) then
  49.     {
  50.         throw 11;
  51.     };
  52.     if (_vehicleClass isKindOf "Ship") then
  53.     {
  54.         _position = [(getPosATL _playerObject), 80, 10] call ExileClient_util_world_findWaterPosition;
  55.         _vehicleObject = [_vehicleClass, _position, (random 360), false, _pinCode] call ExileServer_object_vehicle_createPersistentVehicle;
  56.     }
  57.     else
  58.     {
  59.     if (_vehicleClass isKindOf "Air") then
  60.     {
  61.         _nObject = nearestObject [(getPosATL _playerObject), "Land_HelipadSquare_F"];
  62.         if ( isNull _nObject ) then { throw 13; };
  63.         _position3d = getPos _nObject;
  64.         _position2d = [_position3d select 0, _position3d select 1];
  65.     }
  66.     else
  67.     {
  68.         _nObject = nearestObject [(getPosATL _playerObject), "Land_HelipadEmpty_F"];
  69.         if ( isNull _nObject ) then { throw 13; };
  70.         _position3d = getPos _nObject;
  71.         _position2d = [_position3d select 0, _position3d select 1];
  72.     };
  73.         _vehicleObject = [_vehicleClass, _position3d, (random 360), true, _pinCode] call ExileServer_object_vehicle_createPersistentVehicle;
  74.     };
  75.     _vehicleObject setVariable ["ExileOwnerUID", (getPlayerUID _playerObject)];
  76.     _vehicleObject setVariable ["ExileIsLocked",0];
  77.     _vehicleObject lock 0;
  78.     _vehicleObject call ExileServer_object_vehicle_database_insert;
  79.     _vehicleObject call ExileServer_object_vehicle_database_update;
  80.     _playerMoney = _playerMoney - _salesPrice;
  81.     _playerObject setVariable ["ExileMoney", _playerMoney, true];
  82.     format["setPlayerMoney:%1:%2", _playerMoney, _playerObject getVariable ["ExileDatabaseID", 0]] call ExileServer_system_database_query_fireAndForget;
  83.     [_sessionID, "purchaseVehicleResponse", [0, netId _vehicleObject, _salesPrice]] call ExileServer_system_network_send_to;
  84.     _logging = getNumber(configFile >> "CfgSettings" >> "Logging" >> "traderLogging");
  85.     if (_logging isEqualTo 1) then
  86.     {
  87.         _traderLog = format ["PLAYER: ( %1 ) %2 PURCHASED VEHICLE %3 FOR %4 POPTABS | PLAYER TOTAL MONEY: %5",getPlayerUID _playerObject,_playerObject,_vehicleClass,_salesPrice,_playerMoney];
  88.         "extDB2" callExtension format["1:TRADING:%1",_traderLog];
  89.     };
  90. }
  91. catch
  92. {
  93.     _responseCode = _exception;
  94.     [_sessionID, "purchaseVehicleResponse", [_responseCode, "", 0]] call ExileServer_system_network_send_to;
  95. };
  96. if !(isNull _playerObject) then
  97. {
  98.     _playerObject setVariable ["ExileMutex", false];
  99. };
  100. true
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top